Previous Topic: Separation of pre- and post-compilation commandsNext Topic: Global control data area YBRTPXA


Exit program call functionality

Users can define their own 'exit programs', to be automatically called before or after the source member is compiled. Exit programs are invoked through a new preprocessor directive identifier – the P directive.

In a fixed-format source member (such as RPG, COBOL or DSPF) an exit program preprocessor directive will have the following format:

P* [library-name/]program-name

In a free-format source member (such as CL), an exit program preprocessor directive will have the following format:

/*P: [library-name/]program-name */

If the library name is not specified, *LIBL is assumed.

All exit programs have the same parameter format, as follows:

  1. Compile command
  2. Source member
  3. Source file
  4. Source library

For instance, if the following compile preprocessor directive is found in an RPGLE source member called MYPGM in file QRPGLESRC in library MYLIB which is being compiled with the CRTBNDRPG command:

P* QGPL/EXITPGM

then the following command will be executed as part of the compilation process:

CALL PGM(QGPL/EXITPGM) PARM('CRTBNDRPG ' 'MYPGM     ' 'QRPGLESRC ' 'MYLIB     ')

Note that if an exit program is called before the source member is compiled, it can make changes to the source before the source member is compiled.

It is the responsibility of the user to create and test exit programs thoroughly before deploying them in a production environment.