Processing Inbound Errors
This section discusses how to:
Use the Exit built-in function.
Correct messaging errors.
You validate data differently depending on the PeopleCode class that you’re using to receive the message.
XMLDoc Class Validation
You can validate incoming XML DOM-compliant messages by using the XmlDoc document type definition (DTD) that is delivered with your PeopleSoft application.
SoapDoc Class Validation
You can validate SOAP-compliant messages by using the ValidateSoapDoc method in the PeopleCode SoapDoc class.
Message Class Validation
Have a message receiving process validate incoming data by:
Using the ExecuteEdits method in the code to invoke the definitional edits.
Calling PeopleCode validation built-in functions (if they already exist, for example in a FUNCLIB record, or if validation logic can be encapsulated within a small set of built-in functions) from within the receiving PeopleCode.
Calling a component interface or Application Engine program from the receiving process (for complex validation logic).
This enables you to reuse logic that is embedded in the component.
The ExecuteEdits method uses the definitional edits to validate the message. You can specify the following system variables alone or in combination. If you don’t specify a variable, all of the edits are processed.
The following example processes all edits for all levels of data in the message structure:
The following example processes the Required Field and Prompt Table edits:
&RECPURCHASEORDER.ExecuteEdits(%Edit_Required + %Edit_PromptTable);
ExecuteEdits uses set processing to validate data. Validation by using a component interface or a PeopleCode built-in function is usually done with row-by-row processing. If a message contains a large number of rows per rowset, consider writing the message to a staging table and calling an Application Engine program to do set processing if you want additional error checking.
ExecuteEdits sets several properties on several objects if there are any errors:
IsEditError is set on the Message, Rowset, Row, and Record objects if any fields contain errors.
EditError, MessageNumber, and MessageSetNumber are set on the Field object that contains the error.
If you don’t want to use ExecuteEdits, you can set your own errors by using the field properties. Setting the EditError property to True automatically sets the IsEditError message property to True. You can also specify your own message number, message set number, and so on, for the field. If you use the Exit(1) built-in function, the message status changes to Error when you finish setting the fields that are in error.
Use the Exit built-in function to invoke a messaging error process when the application finds an error. This works only when you use the PeopleCode Message class to process inbound transactions. The same error processing is invoked automatically if PeopleTools finds an unexpected error, such as a Structured Query Language (SQL) error. The Exit built-in function has an optional parameter that affects how the error is handled.
To handle error processing in application tables, use the Exit built-in function with no parameter, or just let the notification process finish normally. This marks the message receipt as successful and commits the data.
To handle the error tracking and correction with PeopleSoft Integration Broker, use the Exit built-in function with 1 as a parameter to log the errors, perform a rollback, and stop processing.
Using the Exit Built-in Function Without Parameters
Exit( ) form (that
is, Exit without any parameters specified), all data is committed
and the message is marked as complete. Use this to indicate that everything
processed correctly and to stop program processing. Note, though,
that the message status is set to Complete; therefore, you can’t detect
or access errors in the Service Operations Monitor. If errors did
occur, the subscription code should write them to a staging table,
and then you must handle all of the error processing.
The Exit built-in function:
Sets the message status in the application message queue for the subscription to Done.
Commits the transaction.
Following is an example of using Exit without a parameter:
&MSG.ExecuteEdits(); If &MSG.IsEditError then App_Specific_Error_Processing(); Exit(); Else Specific_Message_Processing(); End-if;
Using the Exit Built-in Function with Parameters
When you supply a 1 as a parameter for the Exit built-in function, the function:
Processes a rollback.
Sets the message status in the message queue for the subscription to Error.
Writes the errors to the subscription contract error table.
You can view all errors that have occurred for this message in the Service Operations Monitor, even those errors that are detected by ExecuteEdits.
Following is an example of using the Exit function with 1 as a parameter:
&MSG.ExecuteEdits(); If &MSG.IsEditError then Exit(1); Else Process_Message(); End-if;