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 Topic.

  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 is invoked. These parameters are:

  • &P_EMPLID

    Identifies the EMPLID for which a trigger should be generated. Use field EMPLID for &P_EMPLID.

  • &P_FIXED_DT

    Holds the value of the trigger effective date for records with a Trigger Effective Date Type of Fixed Date. It is ignored for records with a Trigger Effective Date 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 the case of Fixed Date type 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 invokes this function only if certain conditions are met, as discussed in example 2 below.

The following examples are taken from PeopleCode delivered with the database. They illustrate how to configure the PeopleCode for additional records in the system.

Example 1: 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 Effective Date Type for the Payee Supporting Element Override table (GP_PYE_SOVR) is not Fixed Date.

Example 2: Trigger Record = GP_PI_MNL_DATA (Manual Positive Input)

This record has a Trigger Effective Date Type of Fixed Date.

Sample PeopleCode:

PeopleCode on GP_PI_MNL_DATA.LASTUPDDTTM.SavePostChange
Declare Function Generate_Triggers PeopleCode 
FUNCLIB_GP.TRGR_FUNCTIONS FieldFormula;
  Local date &L_DT;
  Local Rowset &L_RS0;
  Component datetime &C_CAL_IDNT_TS;
  /*-----Function to generate Triggers for Global Payroll---*/
  &L_RS0 = GetLevel0();
  &L_DT = &L_RS0(1).GP_PI_MNL_D.PRD_END_DT.Value;
  If All(&C_CAL_IDNT_TS) Then
   Generate_Triggers(EMPLID, &L_DT);
  End-If;

In this example, &L_DT must be set to a value to be used as the trigger effective date for triggers generated from positive input.

With positive input, triggers must be generated with the period end date for the calendar that has the positive input. So, &L_DT is set as follows:

&L_RS0 = GetLevel0();
&L_DT = &L_RS0(1).GP_PI_MNL_D.PRD_END_DT.Value;

Note: GP_PI_MNL_D.PRD_END_DT has been assigned the value of PRD_END_DT for the calendar through earlier PeopleCode on GP_PI_MNL_DATA.ENTRY_TYPE_ID.RowInit.

The function can now be invoked. In the case of positive input, the trigger-generation mechanism needs to be invoked only if the calendar that has positive input has been identified:

If All(&C_CAL_IDNT_TS) Then
  Generate_Triggers(EMPLID, &L_DT);
End-If;

Note: PeopleSoft recommends that when you define a retroactive or segmentation trigger, you also define an iterative trigger. If a calendar group has been calculated and data changes are subsequently made, unless an iterative trigger is defined, any retroactive or segmentation triggers generated from the data changes aren't processed until the next Identify phase.