Ü  %EOF(filename)

·    This built-in function is used to detect end-of file, beginning of file, or subfile full conditions while performing a file operation similar to resulting indicator.

·    So, instead of checking any resulting indicator we simply use %EOF to check if the end of file is reached.

·    %EOF returns '1' if end-of file, beginning of file, or subfile full condition is found ; otherwise, it returns '0'.

·    READ, READC and READE return %EOF=*ON if the end of file is reached.

·    READP and READPE return %EOF=*ON if the beginning of file is reached.

·    WRITE operation returns %EOF=*ON if the WRITE operation to a subfile detail record returned a subfile-full condition.

·    If %EOF=*ON and we perform CHAIN operation, then CHAIN operation on successful search sets %EOF=*OFF.

·    OPEN, SETGT, SETLL on successful operations, sets %EOF=*OFF.

 

Example- I -%eof built-in function in rpgle

Checking EOF status of a file


0127.00 C*_______________FILL SUBFILE__________________
0128.00 C*_________________________________________________
0129.00 C*
0130.00 C     FILSFL1       BEGSR
0131.00 C                   EVAL      RRN=1
0132.00 C                   SETOFF                                       45
0133.00 C                   DOU       %EOF(MASTER) //The loop is executed until end of
0134.00 C                   READ(N)   REC1              file is reached
0135.00 C                   IF        %EOF(MASTER) //If end of file is reached then turn
0136.00 C                   EVAL      *IN45=%EOF(MASTER)    on the bottom indicator
0137.00 C                   LEAVESR
0138.00 C                   ENDIF
0139.00 C                   EVAL      S_ORG=%CHAR(ORG)
0140.00 C                   EVAL      S_ACC=ACC
0141.00 C                   EVAL      S_CCY=CCY
0142.00 C                   WRITE     EXPD_SFL
0143.00 C                   ADD       2             RRN
0144.00 C                   EVAL      LSTRRN=RRN
0145.00 C                   ENDDO
0146.00 C                   ENDSR

 

 

Example- II –%eof built-in function in rpgle

Checking successful CHAIN operation to set %EOF=*OFF

In the program below we are Checking successful CHAIN operation to set %EOF=*OFF

 


Columns . . . :    6  80        Edit                                AMITCC/QRPGLESRC
SEU==>                                                                      BIN_EOF
FMT FX FFilename++IPEASF.....L.....A.Device+.Keywords+++++++++++++++++++++++++++++
*************** Beginning of data ******************************************
0001.00 FACCOUNT   IF   E           K DISK
0002.00 C     KLST1         KLIST
0003.00 C                   KFLD                    ORG               3 0
0004.00 C                   KFLD                    ACC              12
0005.00 C                   KFLD                    CCY               3
0006.00 C     *HIVAL        SETLL     ACCOUNT
0007.00 C                   READ      ACCOUNT
0008.00 C                   IF        %EOF(ACCOUNT)
0009.00 C     'EOF'         DSPLY
0010.00 C                   EVAL      ORG=191
0011.00 C                   EVAL      ACC='A00000000002'
0012.00 C                   EVAL      CCY='EUR'
0013.00 C     KLST1         CHAIN     ACCOUNT
0014.00 C                   IF        %FOUND(ACCOUNT)
0015.00 C     'REC FOUND'   DSPLY
0016.00 C                   IF        NOT %EOF(ACCOUNT)
0017.00 C     'NOT EOF'     DSPLY
0018.00 C                   ENDIF
0019.00 C                   ENDIF
0019.00 C                   ENDIF
0020.00 C                   EVAL      ORG=191
0021.00 C                   EVAL      ACC='A00000000002'
0022.00 C                   EVAL      CCY='EUR'
0023.00 C     KLST1         CHAIN     ACCOUNT
0024.00 C                   IF        %FOUND(ACCOUNT)
0025.00 C     'REC FOUND'   DSPLY
0026.00 C                   IF        NOT %EOF(ACCOUNT)
0027.00 C     'NOT EOF'     DSPLY
0028.00 C                   ENDIF
0029.00 C                   ENDIF
0030.00 C                   ENDIF
0031.00 C                   SETON                                        LR
        ****************** End of data ***************************************

 

             

OUTPUT

 

DSPLY  EOF     

DSPLY  REC FOUND

DSPLY  NOT EOF 

 

 

 

 

 

Example- III –%eof built-in function in rpgle

%EOF with READP & SETLL operation

 


0065.00 C                   READP(N)  REC1
0066.00 C                   IF        %EOF
0067.00 C     *LOVAL        SETLL     REC1
0068.00 C                   ENDIF

 

 

 

Example- IV –%eof built-in function in rpgle

%EOF with READ operation


0131.00 C                   READ(N)   REC1
0132.00 C                   IF        %EOF(MASTER)
0133.00 C                   EVAL      *IN45=%EOF(MASTER)
0134.00 C                   LEAVESR
0135.00 C                   ENDIF

 

 

Example- V –%eof built-in function in rpgle

%EOF with READC operation


0035.00 C                   READC     EXPD_SFL
0036.00 C                   DOW       NOT %EOF()
0038.00 C                   SELECT
0039.00 C                   WHEN      S_OPT='1'
0040.00 C                   EXSR      ENTSR
0041.00 C                   EXSR      CLROPT
0056.00 C                   WHEN      S_OPT=' '
0057.00 C                   LEAVESR
0058.00 C                   OTHER
0059.00 C*                  EXSR      VALIDATE
0060.00 C*                  SETON                                        56
0061.00 C*                  EXSR      CLROPT
0062.00 C                   SETON                                        9192
0063.00 C                   ENDSL
0064.00 C                   READC     EXPD_SFL
0065.00 C                   ENDDO

 

 

Example- VI –%eof built-in function in rpgle

%EOF with READE operation


0138.00 C     FILLWND       BEGSR
0139.00 C                   EVAL      RRN1=0
0140.00 C     S_PNUM        SETLL     REC5
0141.00 C                   IF        %EQUAL()
0142.00 C                   DOU       %EOF(ACCSUBPF)
0143.00 C                   READE     REC5
0144.00 C                   IF        %FOUND()
0145.00 C                   EVAL      RRN1=RRN1+1
0146.00 C                   EVAL      A_ORG=ORG
0147.00 C                   EVAL      A_ACCNO=ACC
0148.00 C                   EVAL      A_CCY=CCY
0149.00 C                   EVAL      A_ACCMNG=ACCMNGR
0150.00 C                   EVAL      A_CNTRY=COUNTRY
0151.00 C                   WRITE     ACC_SFL
0152.00 C                   ENDIF
0153.00 C                   ENDDO
0154.00 C                   ENDIF
0155.00 C                   SETON                                        26
0156.00 C                   ENDSR

 











User Comments:



Copyright © www.go4as400.com, 2013-2023. Copyright notice   Terms of services   Privacy policy