Creating a User Exit Routine

Online programs run user exits at predefined points in their execution, based upon the existence of a user exit program in the user object directory, with the specified naming convention.

To create a user exit program, you create procedure description and working storage program segments that follow Lawson 4GL syntax. A user exit program has access to all form fields of the base program. Any Lawson 4GL statement or Application Program Interface may be used. The user exit program segments are compiled into a program which runs automatically when the base program is launched. For more detail on creating Lawson 4GL program segments, see Doc for Developers: Application Development Workbench and Doc for Developers: Lawson 4GL Application Program Interfaces.

User exit programs must have the same number of form control sections as the base application program. For example, if the program GL40 has nine form control sections, so must a user exit for GL40. A form control section is named ProgramCode S n -TRANSACTION, where n is the form number. For example, the form control section for the first form of GL40 would be named GL40S1-TRANSACTION.

While a user exit program must follow all Lawson 4GL syntax rules, an entry in Program Definition is not required. When the base program is launched, it automatically checks for the existence of one or more user exits.

Note: If the base program is already running, you will need to stop and restart the program to execute a newly created user exit.

To create a user exit routine

  1. Create the user exit procedure division and working storage file segments in the user objects directory, using the following naming conventions.
    Create these files For

    $LAWDIR/productline/systemcodesrc/ProgramCodeBPD

    $LAWDIR/productline/systemcodesrc/ProgramCodeBWS

    A user exit that runs at the beginning of the transaction state.

    $LAWDIR/productline/systemcodesrc/ProgramCodeMPD

    $LAWDIR/productline/systemcodesrc/ProgramCodeMWS

    A user exit that runs in the middle of the transaction state.

    $LAWDIR/productline/systemcodesrc/ProgramCodeEPD

    $LAWDIR/productline/systemcodesrc/ProgramCodeEWS

    A user exit that runs at the end of the transaction state.

    For example, you could use the following sequence of commands to create the program segments of a middle user exit for the program GL40 in the TEST product line:

    cd $LAWDIR/test/glsrc

    touch GL40MPD

    touch GL40MWS

  2. Create the same number of form control sections in the user exit procedure source file as in the base program, using a text editor such as one of the Lawson Editors, lx or led.

    For example, GL40 has nine form control sections. You would use the following naming conventions for the form control sections in GL40MPD:

    • GL40MS1-TRANSACTION

      GL40MS2-TRANSACTION

      GL40MS3-TRANSACTION

      GL40MS4-TRANSACTION

      GL40MS5-TRANSACTION

      GL40MS6-TRANSACTION

      GL40MS7-TRANSACTION

      GL40MS8-TRANSACTION

      GL40MS9-TRANSACTION

  3. Modify the program logic as desired, adding any necessary working storage fields to the user exit WS program segment.
  4. If the user exit requires any new messages, define those messages in the Message Maintenance utility (msgmnt).
  5. Compile and test the user exit program.

    For instructions, see Compiling User Exits.