This appendix provides sample PeopleCode for business attributes service operations. This sample PeopleCode calls functions from the PeopleSoft-delivered subscription library which processes rowset-based transactions. The sample code can be copied into an application class for Business Data Attributes handlers.
Sample PeopleCode is provided for these cases:
Case 1: A nonrowset-based message does not exist for the service operation in PeopleSoft Applications Portal.
Case 2: A nonrowset-based message exists in PeopleSoft Applications Portal for the same-name service operation in PeopleSoft HCM.
Examples are provided for full synchronization and incremental synchronization.
Full Synchronization
Use this example for full synchronization:
/* Start of sample code */ import PS_PT:Integration:INotificationHandler; class BusUnitTblHRFullSync implements PS_PT:Integration:INotificationHandler method BusUnitTblHRFullSync(); method OnNotify(&_MSG As Message); end-class; Declare Function Subscribe_FullReplication PeopleCode FUNCLIB_EO⇒ EIP.SUBSCRIBE_MSG_PC FieldFormula; Declare Function Delete_Existing_Data PeopleCode FUNCLIB_EO⇒ EIP.SUBSCRIBE_MSG_PC FieldFormula; /* constructor */ method BusUnitTblHRFullSync end-method; method OnNotify /+ &_MSG as Message +/ /+ Extends/implements PS_PT:Integration:INotificationHandler.OnNotify +/ /* Variable Declaration */ Local Message &msg; Local Rowset &msgRowset; &msg = &_MSG; &msgRowset = &msg.GetRowset(); Evaluate &msgRowset(1).PSCAMA.MSG_SEQ_FLG.Value When "H" Delete_Existing_Data(&msg); Break; When "T" rem ********** put code for cleanup here *******************; Break; When-Other Subscribe_FullReplication(&msg); Break; End-Evaluate; end-method; /* End of sample code */
Incremental Synchronization
Use this example for full synchronization:
/* Start of sample code */ import PS_PT:Integration:INotificationHandler; class BusUnitTblHRSync implements PS_PT:Integration:INotificationHandler method BusUnitTblHRSync(); method OnNotify(&_MSG As Message); end-class; Declare Function Subscribe_IncrReplication PeopleCode FUNCLIB_EO⇒ EIP.SUBSCRIBE_MSG_PC FieldFormula; /* constructor */ method BusUnitTblHRSync end-method; method OnNotify /+ &_MSG as Message +/ /+ Extends/implements PS_PT:Integration:INotificationHandler.OnNotify +/ /* Variable Declaration */ Local Message &msg; &msg = &_MSG; Subscribe_IncrReplication(&msg); end-method; /* End of sample code */
Examples of these service operations are ones used by the Resource Finder feature where the service operation is defined with a rowset-based message in PeopleSoft HCM but uses a nonrowset-based message in PeopleSoft Applications Portal, such as COMPANY_FULLSYNC, DEPT_FULLSYNC, LOCATION_FULLSYNC, PERSON_BASIC_FULLSYNC. To leverage the PeopleSoft subscription utilities which process rowset-based transactions:
Create a rowset-based message in PIA (this message will be used in the handler PeopleCode.
Because the message needs to be assigned to a default service operation, create a “dummy” service and service operation of the same name for the message (no routing and handler need to be defined). For example, for the Company business data integration, use COMPANY_FULLSYNC_RS VERSION_1 as there is already a message with the name COMPANY_FULLSYNC VERSION_1
Insert this message name in string variable &sMsgName and the version in &sMsgVer in the sample code below.
Peoplecode examples are provided below for full synchronization and incremental synchronization.
Full Synchronization
The following sample is for full synchronization:
/* Start of sample code */ import PS_PT:Integration:INotificationHandler; class CompanyFullSync implements PS_PT:Integration:INotificationHandler method CompanyFullSync(); method OnNotify(&_MSG As Message); end-class; Declare Function Subscribe_FullReplication PeopleCode FUNCLIB_EO⇒ EIP.SUBSCRIBE_MSG_PC FieldFormula; Declare Function Delete_Existing_Data PeopleCode FUNCLIB_EO⇒ EIP.SUBSCRIBE_MSG_PC FieldFormula; /* constructor */ method CompanyFullSync end-method; method OnNotify /+ &_MSG as Message +/ /+ Extends/implements PS_PT:Integration:INotificationHandler.OnNotify +/ /* Variable Declaration */ Local Message &msg; Local Rowset &msgRowset; Local XmlDoc &inXMLDoc; Local boolean &ret; Local string &sMsgName = "<insert rowset-based message name>"; Local string &sMsgVer = "<insert message version>"; /* instantiate variable for rowset-based message */ &msg = CreateMessage(@("Message." | &sMsgName)); &msgRowset = &msg.GetRowset(); /* substitute incoming XML root name to rowset-based message name */ &inXMLDoc = &_MSG.GetXmlDoc(); &inXMLDoc.DocumentElement.NodeName = &sMsgName; /* copy XML to message rowset */ &ret = &inXMLDoc.CopyToRowset(&msgRowset, &sMsgName, &sMsgVer); /* call library function to update table */ Evaluate &msgRowset(1).PSCAMA.MSG_SEQ_FLG.Value When "H" /* If the current message is the header msg, then prepare the table⇒ for insert */ Delete_Existing_Data(&msg); Break; When "T" rem ********** put code for cleanup here *******************; Break; When-Other Subscribe_FullReplication(&msg); Break; End-Evaluate; end-method; /* End of sample code */
Incremental Synchronization
The following sample is for full synchronization:
/* Start of sample code */ import PS_PT:Integration:INotificationHandler; class CompanySync implements PS_PT:Integration:INotificationHandler method CompanySync (); method OnNotify(&_MSG As Message); end-class; Declare Function Subscribe_IncrReplication PeopleCode FUNCLIB_EO⇒ EIP.SUBSCRIBE_MSG_PC FieldFormula; /* constructor */ method CompanySync end-method; method OnNotify /+ &_MSG as Message +/ /+ Extends/implements PS_PT:Integration:INotificationHandler.OnNotify +/ /* Variable Declaration */ Local Message &msg; Local Rowset &msgRowset; Local XmlDoc &inXMLDoc; Local boolean &ret; Local string &sMsgName = "<insert rowset-based message name>"; Local string &sMsgVer = "<insert message version>"; /* instantiate variable for rowset-based message */ &msg = CreateMessage(@("Message." | &sMsgName)); &msgRowset = &msg.GetRowset(); /* substitute incoming XML root name to rowset-based message name */ &inXMLDoc = &_MSG.GetXmlDoc(); &inXMLDoc.DocumentElement.NodeName = &sMsgName; /* copy XML to message rowset */ &ret = &inXMLDoc.CopyToRowset(&msgRowset, &sMsgName, &sMsgVer); Subscribe_IncrReplication(&msg); end-method; /* End of sample code */