The exit programs should be written in COBOL and compiled by the Micro Focus syntax checker. They can be executed normally or debugged like any other COBOL program. Please refer to the mainframe documentation for instructions on writing and testing exit programs.
COBOL Statements | Value |
---|---|
RECORD-FLAGS PIC 9(8) COMP. |
0 indicates the first record passed. 4 indicates subsequent records passed. 8 indicates the last record passed. |
ENTRY-BUFFER PIC X(n). |
Contents of the input record. Do not change this area. |
EXIT-BUFFER PIC X(n). |
Contents of the new or altered record provided by the exit. |
UNUSED-ENTRY PIC 9(8) COMP. |
Not used |
UNUSED-ENTRY PIC 9(8) COMP. |
Not used |
ENTRY-RECORD-LENGTH PIC 9(8) COMP. |
Length of the input record. |
EXIT-RECORD-LENGTH PIC 9(8) COMP. |
Length of the new or altered record provided by the exit. |
UNUSED-ENTRY PIC 9(8) COMP. |
Not used |
EXIT-AREA-LENGTH PIC 9(4) COMP. |
Length of the exit area scratchpad. Do not change this field. |
EXIT-AREA PIC X(n). |
Exit area scratchpad used by the exit to maintain variables between calls to the exit program. |
The EXIT-AREA defined in the LINKAGE-SECTION is only initialized on the start-up of the batch SEP process, and not the first time the E15/E35 user exit is called. This could mean that any subsequent call to an E15/E35 user exit, could potentially pick up data used in a previously called E15/E35 user exit.
To ensure that the EXIT-AREA is initialized on the first call to any E35 user exit, add the following WORKING-STORAGE item:
01 WS-INIT-ACTION-FLAG PIC X VALUE ‘Y’.
Then in the PROCEDURE DIVISION, place the following code as the first to be processed:
PROCEDURE DIVISION. MAIN SECTION. IF WS-INIT-ACTION-FLAG =’Y’ INITIALIZE EXIT-AREA MOVE ‘N’ WS-INIT-ACTION-FLAG END-IF.
Some customers redefine the EXIT-AREA, to define processing counts and flags; for example:
01 EXIT-AREA PIC X(256). 01 USER-EXIT-AREA REDEFINES EXIT-AREA. 03 UXIT-COUNT PIC 9(9). 03 UXIT-FLAG PIC X. 03 UXIT-FILLER PIC X(246)
Initializing EXIT-AREA will fill the area with spaces, which for UXIT-COUNT is invalid.
To control these counts and flags, they MUST be initialized separately.
PROCEDURE DIVISION. MAIN SECTION. IF WS-INIT-ACTION-FLAG =’Y’ INITIALIZE EXIT-AREA INITIALIZE UXIT-COUNT INITIALIZE UXIT-FLAG MOVE ‘N’ WS-INIT-ACTION-FLAG END-IF.
As the E15/E35 user exit is loaded into memory at the beginning of the SORT process, the WORKING-STORAGE remains available each time it is called, until the SORT has finished. This allows the necessary control to initialize the EXIT-AREA only once and maintain the user data for each subsequent call to the E15/E35 user exit.
Return Code | Meaning |
---|---|
0 | No action required. |
4 | Delete the current record. For E15, the record is not sorted. For E35, the record is not written to the output data set. |
8 | Do not call this exit again; exit processing is no longer required. |
12 | Insert the current record. For E15, the record is inserted for sorting. For E35, the record is written to the output data set. |
16 | Terminate MFJSORT. The job step is terminated with the condition code set to 16. |
20 | Alter the current record. For E15, the altered record is passed to the sort. For E35, the altered record is written to the output data set. |