Coding end of file procedure

To code an end of file procedure you need to use the *EOFPROC statement, as shown here:

*EOFPROC
If this statement is coded, then all the subsequent REXX statements are treated as procedural statements to be run once at normal completion of the function processing. This could be end of file, or when a processing limit has been been reached, or after a STOP condition has been issued from a REXX procedure. The input and output records will be positioned at the last record processed by the function. This end of file procedure is only run for the functions DSC, DSP, DSU, and DSEB. The procedure is ignored for any other functions. If you have previously coded an *FASTREXX ON statement, then this procedure must be eligible for FASTREXX processing, as described in the given example, to avoid syntax errors. If internal FASTREXX processing is not required, then File Manager chooses either the internal or REXX processing, for the end of file procedure. So one procedure could be running under REXX, while the the other could be FASTREXX. See given examples for usage scenarios.
Example 1.
Perform a copy with a record processing REXX procedure and end of file procedure.
$$FILEM DSC PROC=*
SAY 'NORMAL PROCESS RECORD NUMBER' SUBSTR(INREC,5,2)
*EOFPROC
SAY 'END OF FILE PROC INREC' SUBSTR(INREC,8)
Example 2.
Perform a copy with a FASTREXX end of file procedure.
$$FILEM DSC PROC=*
*EOFPROC
SETC(PRTVAR,' ')                                        /* CLEAR IT */
SETC(INSUB,'&ZINREC(8)')                                /* SUBSTR   */
OVLY_VAR(PRTVAR,'END OF FILE PROC INREC ',1)            /* LITERAL  */
OVLY_VAR(PRTVAR,'&INSUB',0)                             /* EOF VALUE*/
PRT_VAR(PRTVAR)                                         /* PRINT IT */
Example 3.
Perform a copy using *FASTPROC, *REXXPROC, and *EOFPROC statements.
$$FILEM DSC PROC=*
*FASTPROC
OMIT    COND=(68,2,CH,EQ,C'XX')
*REXXPROC
SAY 'NORMAL PROCESS RECORD NUMBER' SUBSTR(INREC,5,2)
*EOFPROC
SAY 'END OF FILE PROC INREC' SUBSTR(INREC,8)