Implementing Triggers

To implement the trigger definitions you have defined, you must set up your system so that the records used in these definitions declare and call the function Generate_Triggers in one of their field's SavePostChange PeopleCode. This PeopleCode has already been added to most of the records for which you are likely to define triggers—such as JOB—so it is unlikely that you will have to perform this step more than a few times. However, if you do need to add a trigger to a record, complete these steps.

Note: We provide a list of the records to which the SavePostChange PeopleCode has been added at the end of this documentation.

  1. Declare the function that generates triggers:

    Declare Function Generate_Triggers PeopleCode 
    FUNCLIB_GP.TRGR_FUNCTIONS FieldFormula;
  2. Declare a local date variable as:

    Local date &L_DT;
  3. Invoke the function as:

    Generate_Triggers(EMPLID, &L_DT);

The function Generate_Triggers is defined in FUNCLIB_GP.TRGR_FUNCTIONS.FieldFormula and needs two parameters when it's invoked. The parameters are:

  1. &P_EMPLID

    Indicates the EMPLID for which the triggers are to be generated. Use field EMPLID for &P_EMPLID.

  2. &P_FIXED_DT

    Holds the value of the trigger effective date for records with a Trigger Effdt Type of Fixed Date. It is ignored for records with a Trigger Effdt Type of Effdt or Begin-End Date. Use &L_DT for &P_FIXED_DT.

The variable &L_DT needs to be assigned a value only in case of the Fixed Date type of triggers. Examples are the positive input records, the Manual Positive Input table (GP_PI_MNL_DATA) and the Manual Positive Input Supporting Element Override table (GP_PI_MNL_SOVR).

Note: You can enter PeopleCode that can invoke the function only if certain conditions are met, as discussed in example 2 below.

The following example is from PeopleCode that's delivered with the database. The example shows changes necessary for any additional records that are to generate triggers.

Example: Trigger Record = GP_PYE_SOVR

Sample PeopleCode:

PeopleCode on GP_PYE_SOVR.EMPLID.SavePostChange
Declare Function Generate_Triggers PeopleCode 
FUNCLIB_GP.TRGR_FUNCTIONS FieldFormula;
Local date &L_DT;
/*-----Function to generate Triggers for Global Payroll---*/
Generate_Triggers(EMPLID, &L_DT);

In this example, &L_DT isn't assigned a value, because the Trigger Effdt Type for the Payee Supporting Element Override table (GP_PYE_SOVR) is not Fixed Date.