Example 1: Calculates the current balance of the account:

     Object           : Account (ACNT) 
Trigger Field    : "Account Balance" (ACCBAL)
Trigger Method   : Calculates the current balance of the account.
Trigger Event(s) : 1. AFTER READ when ACCBAL is REF (referenced)
 
Invoked By       : (i.e. How is an account balance retrieved ?)
                   FETCH FIELDS(....#ACCBAL....)
                         FROM_FILE(ACNT)
                or SELECT FIELDS(....#ACCBAL....)
                          FROM_FILE(ACNT)
Comments         : Quite efficient because ACCBAL is only
                   calculated when the requester asks for it.

Example 2: Submits batch order print job:

     Object           : Order (ORDR) 
Trigger Field    : "Print Required" (PRINT_REQ)
Trigger Method   : Submits batch order print job. Batch function
                   prints order and updates PRINT_REQ to 'N'.
Trigger Event(s) : 1. AFTER INSERT when PRINT_REQ EQ  'Y'
                  2. AFTER UPDATE when PRINT_REQ EQ  'Y'
                                   and  PRINT_REQ NEP PRINT_REQ
 
Invoked By       : (i.e. How is an order submitted for printing ?)
                    CHANGE #PRINT_REQ 'Y'
                    UPDATE FIELD(#PRINT_REQ) IN_FILE(ORDR)
 
Comments         : It may seem a little obscure as an IBM i
                   based trigger but what if the update
                   comes from a PC based application via
                   the LCOE facility, or from a batch job
                   that starts automatically every morning
                   and automatically selects certain
                   orders for printing ?
 

  • No labels