Error Handling

In your notification PeopleCode, you may want to validate the information received in the message. If you find that the data isn’t valid, use Exit(1) to end your PeopleCode program. This sets the status of the message to ERROR, logs any error messages to the Application Message Queues, and automatically rolls back any database changes you may have made.

There are many ways to validate the data and capture the error messages:

  • Use ExecuteEdits on the message object

  • Use ExecuteEdits on the record object

  • Use a Component Interface

Write your own validation PeopleCode in the notification program:

The following example validates the Business Unit of a message against an array of valid BU's:

For &I = 1 To &ROWSET.RowCount;

  &POSITION = &BUArray.Find(&ROWSET(&I).GetRecord(1).BUSINESS_UNIT.Value);
  If &POSITION = 0 Then
    &Status = "ERROR: BU not Found or not Active";
    &ROWSET(&I).BCT_ADJS_MSG_VW.BUSINESS_UNIT.MessageSetNumber = 11100;
    &ROWSET(&I).BCT_ADJS_MSG_VW.BUSINESS_UNIT.MessageNumber = 1230;
/* The error message 11100-1230 reads: This Business Unit is */
/* not a valid, open, Inventory Business Unit */



In the calling PeopleCode, the program calls Exit(1) based on the value of &Status.

Note: All errors for notification PeopleCode get logged to the application message error table, not to the PSMessages collection (on the session object.)