User Exits

A user exit is a point in an online program at which a routine, written by a user, can be given control. Every online program has three standard user exit points:

  • At the beginning of the transaction state, after form fields are populated, but before the main program logic. Beginning user exits typically are used to perform additional edits on the data in the form fields.

  • In the middle of transaction processing, after the Lawson program has edited the transaction but before any updates occur. Middle user exits can be used to "refine" data before it is processed. You cannot use middle user exits for error messages.

  • At the end of the transaction state, after the main program logic, but before the form is redisplayed. End user exits are useful for additional update processing, such as adding data to another database field or table.

User exit points are built into the program shell (.cbl) by the bldsh program. The program checks for the presence of user exits with code and sets a flag if the user exits exist.

CALL "BegUsrExitExists" USING CRT-PROGRAM-CODE,
                              WS-BEG-UE-PGM,
                              WS-BEG-UE-FOUND.
CALL "MidUsrExitExists" USING CRT-PROGRAM-CODE,
                              WS-MID-UE-PGM,
                              WS-MID-UE-FOUND.
CALL "EndUsrExitExists" USING CRT-PROGRAM-CODE,
                              WS-END-UE-PGM,
                              WS-END-UE-FOUND.

At the appropriate points in the program, the program checks the value of the flags for user exits, and calls the user exit program if it exists.

PROC-TRANS.
    IF (WS-BEG-UE-FOUND = "Y")
        MOVE CRT-PROGRAM-CODE TO CRT-SV-PROGRAM-CODE
        CALL WS-BEG-UE-PGM USING CRT-CONTROL,
                                 CRT-TRANSACTION
Note: Batch programs do not have standard exit points. You can define a library to perform a routine in a batch program. For information, see Doc for Developers: Application Development Workbench.