This section contains an example of using direct Adabas calls in FORTRAN. The previously defined Adabas files are used in each example.
C *** CONTROL BLOCK *** INTEGER*4 CB(20),CID,ISN,ISNL,ISNQ INTEGER*4 ADD1(2),ADD2,ADD3(2),ADD4(2),ADD5(2) INTEGER*4 CTIME,UAREA INTEGER*2 CBI(40),CCODE,FNR,RC,FBL,RBL,SBL,VBL,IBL LOGICAL*1 CBL(80),COPT1,COPT2 EQUIVALENCE (CB(1),CBI(1),CBL(1)) EQUIVALENCE (CID,CB(2)),(ISN,CB(4)) EQUIVALENCE (ISNL,CB(5)),(ISNQ,CB(6)) EQUIVALENCE (ADD1(1),CB(10)),(ADD2,CB(12)),(ADD3(1),CB(13)) EQUIVALENCE (ADD4(1),CB(15),(ADD5(1),CB(17)) EQUIVALENCE (CTIME,CB(19)),(UAREA,CB(20)) EQUIVALENCE (CCODE,CBI(2)),(FNR,CBI(5)),(RC,CBI(6)) EQUIVALENCE (FBL,CBI(13)),(RBL,CBI(14)),(SBL,CBI(15)) EQUIVALENCE (VBL,CBI(16)),(IBL,CBI(17)) EQUIVALENCE (COPT1,CBL(35)),(COPT2,CBL(36)) C *** USER BUFFER AREAS *** INTEGER*4 FB(25),RB(50),SB(10),VB(10),IB(50) * * C *** ADDITIONAL FIELDS USED IN THIS EXAMPLE *** LOGICAL*1 BLANK/1H /,COPH/1HH/,PERIOD/1H./,COPN/1HN/ INTEGER*2 S1/2HS1/,L1/2HL1/,CL/2HCL/ INTEGER*4 CID1/4HS101/,FB1/4H. /,FB2/4HRG. /,SB1/4HXB,3/ INTEGER*4 SB2/4H,U. /,VB1/4H099 /
Find the set of records in file 2 with XB = 99.
Read each record selected using the GET NEXT option.
c*** Initialize Control Block DO 5 I=1,80 CBL(I)=BLANK 5 CONTINUE DO 10 I=3,6 CB(I)=0 10 CONTINUE CBI(13)=100 CBI(14)=200 CBI(15)=40 CBI(16)=40 CBI(17)=200 CBI(19)=0
c***Issue FIND Command CCODE=S1 CID=CID1 FNR=2 ISNL=0 COPT1=COPH FB(1)=FB1 SB(1)=SB1 SB(2)=SB2 VB(1)=VB1 CALL ADABAS(CB,FB,RB,SB,VB,IB) IF(RC.NE.0) GO TO 50 IF(ISNQ.EQ.0) GO TO 100
c***Read Each Record Selected 15 CONTINUE CCODE=L1 ISN=0 COPT1=COPN FB(1)=FB2 CALL ADABAS(CB,FB,RB) IF(RC.EQ.0) GO TO 30 IF(RC.EQ.3) GO TO 100 PRINT 60,RC,CCODE 60 FORMAT(1H0,'ADABAS ERROR CODE',I4,' FROM '.A2,' COMMAND') GO TO 50 30 CONTINUE C ...PROCESS RECORD... GO TO 15 50 CONTINUE STOP 100 CONTINUE ...