User Exit Example

The following is an example of a middle user exit for GL40 (Journal Entry). After GL40 completes its normal editing, the program launches this user exit to restrict account numbers 6000-6500 to transaction amounts of $500.00 or less.

The source code file for the procedure in this example would be named GL40MPD, in the \glsrc directory. No specific working storage is needed for this user exit, so an empty file named GL40MWS was created.

GL40BS1-TRANSACTION             SECTION.
       GL40BS1-START.

           PERFORM
               VARYING I1              FROM 1 BY 1
               UNTIL  (I1              > 6)
               OR     (ERROR-FOUND)
                   IF  (GL40F1-LINE-FC     (I1) = "A" OR "C")
                   AND (GL40F1-GLT-ACCOUNT (I1) NOT < 6000)
                   AND (GL40F1-GLT-ACCOUNT (I1) NOT > 6500)
                       IF (GL40F1-GLT-TRAN-AMOUNT (I1) < -500.00)
                       OR (GL40F1-GLT-TRAN-AMOUNT (I1) > 500.00)
                           MOVE 888              TO CRT-ERROR-NBR
                           MOVE GL40F1-GLT-TRAN-AMOUNT-FN (I1)
                                                 TO CRT-FIELD-NBR
                       END-IF
                   END-IF
           END-PERFORM.

****   This edit must occur on forms 1 and 3 of GL40, because 
****   transactions are entered on both forms.
       GL40BS1-TRANSACTION-END.

****   GL40 has nine forms; an empty form control section must
****   be defined for each of forms 2, 4, 5, 6, 7, 8 and 9.

       GL40BS2-TRANSACTION             SECTION.
       GL40BS2-START.
       GL40BS2-TRANSACTION-END.

       GL40BS3-TRANSACTION             SECTION.
       GL40BS3-START.

           PERFORM
               VARYING I1              FROM 1 BY 1
               UNTIL  (I1              > 12)
               OR     (ERROR-FOUND)
                   IF  (GL40F3-LINE-FC     (I1) = "A" OR "C")
                   AND (GL40F3-GLT-ACCOUNT (I1) NOT < 6000)
                   AND (GL40F3-GLT-ACCOUNT (I1) NOT > 6500)
                       IF (GL40F3-GLT-TRAN-AMOUNT (I1) < -5000.00)
                       OR (GL40F3-GLT-TRAN-AMOUNT (I1) > 5000.00)
                           MOVE 888              TO CRT-ERROR-NBR
                           MOVE GL40F3-GLT-TRAN-AMOUNT-FN (I1)
                                                 TO CRT-FIELD-NBR
                       END-IF
                   END-IF
           END-PERFORM.

       GL40BS3-TRANSACTION-END.