Following is a sample PeopleCode for the Asynchronous Integration broker service operation handler, which loads message data into target record. In this Sample PeopleCode “TEST_DATA_TBL” is the record name which is target record and same used in the IB Message. This is simple example of integration broker service handler which takes care of only zero level data.
import PS_PT:Integration:INotificationHandler;
class TEST_HANDLER implements PS_PT:Integration:INotificationHandler
method OnNotify(&_Msg As Message);
private
method CopyFieldsToFunc(&SourceRec As Record, &TargetRec As Record);
end-class;
method OnNotify
/+ &_Msg as Message +/
/+ Extends/implements PS_PT:Integration:INotificationHandler.OnNotify +/
Local integer &i;
Local Rowset &RsMsgHdr, &RsRecHdr;
Local Row &RwMsgHdr;
Local Record &RcMsgHdr;
Local Record &RcStgHdr;
Local Message &Msg;
&Msg = &_Msg;
&RsMsgHdr = &Msg.GetRowset();
&RsRecHdr = CreateRowset(Record.TEST_DATA_TBL);
&RsMsgHdr.CopyTo(&RsRecHdr);
For &i = 1 To &RsRecHdr.ActiveRowCount
&RwMsgHdr = &RsRecHdr.GetRow(&i);
&RcMsgHdr = &RwMsgHdr.GetRecord(Record.TEST_DATA_TBL);
&RcStgHdr = CreateRecord(Record.TEST_DATA_TBL);
%This.CopyFieldsToFunc(&RcMsgHdr, &RcStgHdr);
End-For;
end-method;
method CopyFieldsToFunc
/+ &SourceRec as Record, +/
/+ &TargetRec as Record +/
Local integer &i, &j;
Local string &Empl, &EmplFound;
For &i = 1 To &SourceRec.FieldCount
For &j = 1 To &TargetRec.FieldCount
If &SourceRec.GetField(&i).Name = &TargetRec.GetField(&j).Name Then
&TargetRec.GetField(&j).Value = &SourceRec.GetField(&i).Value;
End-If;
End-For;
End-For;
&Empl = &TargetRec.GetField(Field.EMPLID).Value;
SQLExec("SELECT 'Y' FROM PS_TEST_DATA_TBL WHERE EMPLID = :1 ", &Empl, &EmplFound);
If All(&EmplFound) Then
&TargetRec.Update();
Else
&TargetRec.Insert();
End-If;
end-method;
No comments:
Post a Comment