This program retrieves exit point and exit program information. After retrieving the exit point information, the program calls each exit program. The Retrieve Exit Information API returns a continuation handle when it has more information to return than what fits in the receiver variable.
F*************************************************************** F*************************************************************** F* F* Program: Retrieve Exit Point and Exit Program Information F* F* Language: OPM RPG F* F* Description: This program retrieves exit point and exit F* program information. After retrieving the F* exit point information, the program calls each F* exit program. F* F* APIs Used: QUSRTVEI - Retrieve Exit Information F* F*************************************************************** F*************************************************************** F* FQPRINT O F 132 PRINTER UC I* I* Error Code parameter include. As this sample program I* uses /COPY to include the error code structure, only the first I* 16 bytes of the error code structure are available. If the I* application program needs to access the variable length I* exception data for the error, the developer should physically I* copy the QSYSINC include and modify the copied include to I* define additional storage for the exception data. I* I/COPY QSYSINC/QRPGSRC,QUSEC I* I* Formats for the Retrieve Exit Information API. I* I/COPY QSYSINC/QRPGSRC,QUSREG I* I* Miscellaneous data I* I DS I I 'EXAMPLE_EXIT_POINT ' 1 20 EPNTNM I I -1 B 21 240EPGMNB I I 3500 B 25 280RCVSZ I B 29 320X I B 33 360Y I 37 57 CALLPG IRCV DS 3500 C* C* Beginning of mainline C* C* Retrieve the exit point information first. If the current C* number of exit programs is not zero, retrieve the exit C* programs. It is not necessary to call for the exit point C* information to determine if the exit point has any exit C* programs. It is done here for illustrative purposes only. C* You can make one call to the API for the exit program C* information and check the number of exit program entries C* returned field to see if there are any exit programs to call. C* C* Initialize the error code to inform the API that all C* exceptions should be returned through the error code parameter. C* C Z-ADD16 QUSBNB C* C* Blank out the continuation handle to let the API know that this C* is a first attempt at the retrieve operation. C* C MOVE *BLANKS CONTHD 16 C* C* Call the API to retrieve the exit point information C* C CALL 'QUSRTVEI' C PARM CONTHD C PARM RCV C PARM RCVSZ C PARM 'EXTI0100'FORMAT 8 C PARM EPNTNM C PARM 'EXMP0100'EPTFMT 8 C PARM EPGMNB C PARM 0 QUSCCB C PARM QUSBN C* C* If an exception occurs, the API returns the exception in the C* error code parameter. The bytes available field is set to C* zero if no exception occurs and greater than zero if an C* exception does occur. C* C QUSBNC IFGT 0 C OPEN QPRINT C EXCPTERREPT C EXSR DONE C ENDIF C* C* If the call to retrieve exit point information is successful, C* check to see if there are any exit programs to call. C* C 36 SUBSTRCV:1 QUSCG C QUSCGG IFGT 0 C 1 ADD QUSCGF X C 201 SUBSTRCV:X QUSCF C QUSCFF IFGT 0 C* C* There are some exit programs to call. Blank out the continuation C* handle to let the API know that this is a first attempt at the C* retrieve operation. C* C MOVE *BLANKS CONTHD C* C* Call the exit programs C* C EXSR CUSREI C* C* If the continuation handle field in the receiver variable is C* not set to blanks, the API has more information to return than C* what could fit in the receiver variable. Call the API for C* more exit programs to call. C* C QUSCGD DOWNE*BLANKS C MOVELQUSCGD CONTHD C EXSR CUSREI C ENDDO C ENDIF C ENDIF C EXSR DONE C* C* End of MAINLINE C* C* Process exit programs in receiver variable C* C CUSREI BEGSR C* C* Call the API to retrieve the exit program information C* C CALL 'QUSRTVEI' C PARM CONTHD C PARM RCV C PARM RCVSZ C PARM 'EXTI0200'FORMAT 8 C PARM EPNTNM C PARM 'EXMP0100'EPTFMT 8 C PARM EPGMNB C PARM 0 QUSCCB C PARM QUSBN C* C* If an exception occurs, the API returns the exception in the C* error code parameter. The bytes available field is set to C* zero if no exception occurs and greater than zero if an C* exception does occur. C* C QUSBNC IFGT 0 C OPEN QPRINT C EXCPTERRPGM C EXSR DONE C ENDIF C* C* If the call to retrieve exit program information is successful, C* check to see if there are any exit programs to call. C* C* The receiver variable offers enough room for a minimum of one C* exit program entry because the receiver variable was declared C* as 3500 bytes. Therefore, this example only checks the C* number of exit programs returned field. If the receiver C* variable were not large enough to hold at least one entry, C* the bytes available field would need to be checked as well as C* the number of exit programs returned field. If the number of C* exit programs returned field is set to zero and the bytes C* available field is greater than the bytes returned field, the C* API had at least one exit program entry to return but was C* unable to because the receiver variable was too small. C* C 36 SUBSTRCV:1 QUSCJ C 1 ADD QUSCJF Y C 72 SUBSTRCV:Y QUSCH C DO QUSCJG C* C* Get the exit program name and library C* C MOVE *BLANKS CALLPG C MOVELQUSCHL CALLPG C CALLPG CAT '/':0 CALLPG C CALLPG CAT QUSCHK:0 CALLPG C* C* Call the exit program while ignoring failures on the call C* C CALL CALLPG 01 C PARM EXTPRM 10 C* C* Set Y to point to the next exit program entry C* C 1 ADD QUSCHB Y C 72 SUBSTRCV:Y QUSCH C ENDDO C ENDSR C* C* Return to programs caller C DONE BEGSR C SETON LR C RETRN C ENDSR O* OQPRINT E 106 ERREPT O 'Attempt to retrieve infor' O 'mation failed: ' O QUSBND OQPRINT E 106 ERRPGM O 'Attempt to retrieve Exit' O ' Programs failed: ' O QUSBND