Loading CI from file where you would like the file to continue loading and not stop when an system error is generated.
Use Rowset instead of sql
/**************** Sample*****************/
/* ===>
This is a dynamically generated PeopleCode template to be used only as a helper
to the application developer.
You need to replace all references to '[*]' OR default values with references to
PeopleCode variables and/or a Rec.Fields. */
Local File &fileLog, &fileLogS, &fileLogE;
Local ApiObject /* All object required for CI*/;
Local SQL &SQL;
Function errorHandler()
Local ApiObject &oPSMessageCollection, &oPSMessage;
Local number &i;
Local string &sErrMsgSetNum, &sErrMsgNum, &sErrMsgText, &sErrType;
&oPSMessageCollection = &oSession.PSMessages;
For &i = 1 To &oPSMessageCollection.Count
&oPSMessage = &oPSMessageCollection.Item(&i);
&sErrMsgSetNum = &oPSMessage.MessageSetNumber;
&sErrMsgNum = &oPSMessage.MessageNumber;
&sErrMsgText = &oPSMessage.Text;
&fileLog.WriteLine(&sErrType | " (" | &sErrMsgSetNum | "," | &sErrMsgNum | ") - " | &sErrMsgText);
&fileLogE.WriteLine(&sErrType | " (" | &sErrMsgSetNum | "," | &sErrMsgNum | ") - " | &sErrMsgText);
End-For;
rem ***** Delete the Messages from the collection *****;
&oPSMessageCollection.DeleteAll();
End-Function;
rem ***** Set the Log File *****;
&fileLog = GetFile("CI_log_" | record_aet.PROCESS_INSTANCE | ".txt", "w", "a", %FilePath_Relative);
&fileLogS = GetFile("Success_" | record_aet.PROCESS_INSTANCE | ".txt", "w", "a", %FilePath_Relative);
&fileLogE = GetFile("Error_" | record_aet.PROCESS_INSTANCE | ".txt", "w", "a", %FilePath_Relative);
&fileLog.WriteLine("Begin");
rem ***** Get current PeopleSoft Session *****;
&oSession = %Session;
&oSession.PSMessagesMode = 1;
rem ***** Get the Component Interface *****;
&oAdmApplCi = &oSession.GetCompIntfc(CompIntfc.XX_ADM_APPL_CI);
If &oAdmApplCi = Null Then
errorHandler();
throw CreateException(0, 0, "GetCompIntfc failed");
End-If;
rem ***** Set the Component Interface Mode *****;
&oAdmApplCi.InteractiveMode = False;
&oAdmApplCi.GetHistoryItems = True;
&oAdmApplCi.EditHistoryItems = False;
&RS_Manual = CreateRowset(Record.XX_ADM_AP_RSLTS);
&Action = record_aet.PROG_ACTION;
&Reason = record_aet.PROG_REASON;
End-If;
&RS_Manual.Flush();
&rowcount = &RS_Manual.Fill("where OPRID =:1 AND RUN_CNTL_ID =:2", %OperatorId, record_aet.RUN_CNTL_ID);
For &i = 1 To &RS_Manual.ActiveRowCount
&Appl_nbr = &RS_Manual.GetRow(&i).XX_ADM_AP_RSLTS.ADM_APPL_NBR.value;
&Choice_nbr = &RS_Manual.GetRow(&i).XX_ADM_AP_RSLTS.UP_STUDYCHOICE_NBR.Value;
&Emplid = &RS_Manual.GetRow(&i).XX_ADM_AP_RSLTS.EMPLID.Value;
&Inst = "UP000";
&Appl_prog_nbr = &RS_Manual.GetRow(&i).XX_ADM_AP_RSLTS.APPL_PROG_NBR.Value;
&Career = &RS_Manual.GetRow(&i).XX_ADM_AP_RSLTS.ACAD_CAREER.Value;
&fileLog.WriteLine("Key &Appl_nbr = " | &Appl_nbr);
&fileLog.WriteLine("Key &Choice_nbr = " | &Choice_nbr);
&fileLog.WriteLine("Key &Emplid = " | &Emplid);
&fileLog.WriteLine("Key &Appl_prog_nbr = " | &Appl_prog_nbr);
&fileLog.WriteLine("Key &Career = " | &Career);
rem ***** Set Component Interface Get/Create Keys *****;
&oAdmApplCi.ADM_APPL_NBR = &Appl_nbr;
&oAdmApplCi.UP_STUDYCHOICE = &Choice_nbr;
&oAdmApplCi.EMPLID = &Emplid;
&oAdmApplCi.INSTITUTION = &Inst;
&oAdmApplCi.APPL_PROG_NBR = &Appl_prog_nbr;
&oAdmApplCi.ACAD_CAREER = &Career;
rem ***** Execute Get *****;
If Not &oAdmApplCi.Get() Then
rem ***** No rows exist for the specified keys.*****;
rem errorHandler();
rem throw CreateException(0, 0, "Get failed");
&fileLogE.WriteLine("ADM_APPL_NBR Get Error = " | &Appl_nbr);
Else
rem ***** Begin: Get/Set Component Interface Properties *****;
rem ***** Get/Set Level 0 Field Properties *****;
rem ***** Set/Get ADM_APPL_PROG Collection Field Properties -- Parent: PS_ROOT Collection *****;
&oAdmApplProgCollection = &oAdmApplCi.ADM_APPL_PROG;
&oAdmApplProg = &oAdmApplProgCollection.InsertItem(1);
If None(&oAdmApplProg.ACAD_PROG) Then
&fileLog.WriteLine("&oAdmApplProg.ACAD_PROG = " | &oAdmApplProg.ACAD_PROG);
End-If;
&oAdmApplProg.PROG_ACTION = &Action;
If None(&oAdmApplProg.PROG_ACTION) Then
&fileLog.WriteLine("&oAdmApplProg.PROG_ACTION = " | &Action);
End-If;
&oAdmApplProg.PROG_REASON = &Reason;
If None(&oAdmApplProg.PROG_REASON) Then
&fileLog.WriteLine("&oAdmApplProg.PROG_REASON = " | &Reason);
End-If;
rem ***** Set/Get UP_ADMAPPL_PROG Collection Field Properties -- Parent: ADM_APPL_PROG Collection *****;
&oUpAdmapplProgCollection = &oAdmApplProg.UP_ADMAPPL_PROG;
&oUpAdmapplProg = &oUpAdmapplProgCollection.Item(1);
rem ***** End: Get/Set Component Interface Properties *****;
rem ***** Execute Save *****;
If Not &oAdmApplCi.Save() Then;
&fileLogE.WriteLine("ADM_APPL_NBR Save Error = " | &Appl_nbr);
errorHandler();
Else
&fileLogS.WriteLine("ADM_APPL_NBR = " | &Appl_nbr | ", Action: " | &Action | ", Reason: " | &Reason | " Saved");
End-If;
rem ***** Execute Cancel *****;
If Not &oAdmApplCi.Cancel() Then;
errorHandler();
throw CreateException(0, 0, "Cancel failed");
End-If;
End-If;
End-For;
&fileLog.WriteLine(&ex.ToString());
&fileLog.WriteLine("End");
&fileLog.Close();
&fileLogS.Close();
&fileLogE.Close();
Use Rowset instead of sql
/**************** Sample*****************/
/* ===>
This is a dynamically generated PeopleCode template to be used only as a helper
to the application developer.
You need to replace all references to '[*]' OR default values with references to
PeopleCode variables and/or a Rec.Fields. */
Local File &fileLog, &fileLogS, &fileLogE;
Local ApiObject /* All object required for CI*/;
Local SQL &SQL;
Function errorHandler()
Local ApiObject &oPSMessageCollection, &oPSMessage;
Local number &i;
Local string &sErrMsgSetNum, &sErrMsgNum, &sErrMsgText, &sErrType;
&oPSMessageCollection = &oSession.PSMessages;
For &i = 1 To &oPSMessageCollection.Count
&oPSMessage = &oPSMessageCollection.Item(&i);
&sErrMsgSetNum = &oPSMessage.MessageSetNumber;
&sErrMsgNum = &oPSMessage.MessageNumber;
&sErrMsgText = &oPSMessage.Text;
&fileLog.WriteLine(&sErrType | " (" | &sErrMsgSetNum | "," | &sErrMsgNum | ") - " | &sErrMsgText);
&fileLogE.WriteLine(&sErrType | " (" | &sErrMsgSetNum | "," | &sErrMsgNum | ") - " | &sErrMsgText);
End-For;
rem ***** Delete the Messages from the collection *****;
&oPSMessageCollection.DeleteAll();
End-Function;
rem ***** Set the Log File *****;
&fileLog = GetFile("CI_log_" | record_aet.PROCESS_INSTANCE | ".txt", "w", "a", %FilePath_Relative);
&fileLogS = GetFile("Success_" | record_aet.PROCESS_INSTANCE | ".txt", "w", "a", %FilePath_Relative);
&fileLogE = GetFile("Error_" | record_aet.PROCESS_INSTANCE | ".txt", "w", "a", %FilePath_Relative);
&fileLog.WriteLine("Begin");
rem ***** Get current PeopleSoft Session *****;
&oSession = %Session;
&oSession.PSMessagesMode = 1;
rem ***** Get the Component Interface *****;
&oAdmApplCi = &oSession.GetCompIntfc(CompIntfc.XX_ADM_APPL_CI);
If &oAdmApplCi = Null Then
errorHandler();
throw CreateException(0, 0, "GetCompIntfc failed");
End-If;
rem ***** Set the Component Interface Mode *****;
&oAdmApplCi.InteractiveMode = False;
&oAdmApplCi.GetHistoryItems = True;
&oAdmApplCi.EditHistoryItems = False;
&RS_Manual = CreateRowset(Record.XX_ADM_AP_RSLTS);
&Action = record_aet.PROG_ACTION;
&Reason = record_aet.PROG_REASON;
End-If;
&RS_Manual.Flush();
&rowcount = &RS_Manual.Fill("where OPRID =:1 AND RUN_CNTL_ID =:2", %OperatorId, record_aet.RUN_CNTL_ID);
For &i = 1 To &RS_Manual.ActiveRowCount
&Appl_nbr = &RS_Manual.GetRow(&i).XX_ADM_AP_RSLTS.ADM_APPL_NBR.value;
&Choice_nbr = &RS_Manual.GetRow(&i).XX_ADM_AP_RSLTS.UP_STUDYCHOICE_NBR.Value;
&Emplid = &RS_Manual.GetRow(&i).XX_ADM_AP_RSLTS.EMPLID.Value;
&Inst = "UP000";
&Appl_prog_nbr = &RS_Manual.GetRow(&i).XX_ADM_AP_RSLTS.APPL_PROG_NBR.Value;
&Career = &RS_Manual.GetRow(&i).XX_ADM_AP_RSLTS.ACAD_CAREER.Value;
&fileLog.WriteLine("Key &Appl_nbr = " | &Appl_nbr);
&fileLog.WriteLine("Key &Choice_nbr = " | &Choice_nbr);
&fileLog.WriteLine("Key &Emplid = " | &Emplid);
&fileLog.WriteLine("Key &Appl_prog_nbr = " | &Appl_prog_nbr);
&fileLog.WriteLine("Key &Career = " | &Career);
rem ***** Set Component Interface Get/Create Keys *****;
&oAdmApplCi.ADM_APPL_NBR = &Appl_nbr;
&oAdmApplCi.UP_STUDYCHOICE = &Choice_nbr;
&oAdmApplCi.EMPLID = &Emplid;
&oAdmApplCi.INSTITUTION = &Inst;
&oAdmApplCi.APPL_PROG_NBR = &Appl_prog_nbr;
&oAdmApplCi.ACAD_CAREER = &Career;
rem ***** Execute Get *****;
If Not &oAdmApplCi.Get() Then
rem ***** No rows exist for the specified keys.*****;
rem errorHandler();
rem throw CreateException(0, 0, "Get failed");
&fileLogE.WriteLine("ADM_APPL_NBR Get Error = " | &Appl_nbr);
Else
rem ***** Begin: Get/Set Component Interface Properties *****;
rem ***** Get/Set Level 0 Field Properties *****;
rem ***** Set/Get ADM_APPL_PROG Collection Field Properties -- Parent: PS_ROOT Collection *****;
&oAdmApplProgCollection = &oAdmApplCi.ADM_APPL_PROG;
&oAdmApplProg = &oAdmApplProgCollection.InsertItem(1);
If None(&oAdmApplProg.ACAD_PROG) Then
&fileLog.WriteLine("&oAdmApplProg.ACAD_PROG = " | &oAdmApplProg.ACAD_PROG);
End-If;
&oAdmApplProg.PROG_ACTION = &Action;
If None(&oAdmApplProg.PROG_ACTION) Then
&fileLog.WriteLine("&oAdmApplProg.PROG_ACTION = " | &Action);
End-If;
&oAdmApplProg.PROG_REASON = &Reason;
If None(&oAdmApplProg.PROG_REASON) Then
&fileLog.WriteLine("&oAdmApplProg.PROG_REASON = " | &Reason);
End-If;
rem ***** Set/Get UP_ADMAPPL_PROG Collection Field Properties -- Parent: ADM_APPL_PROG Collection *****;
&oUpAdmapplProgCollection = &oAdmApplProg.UP_ADMAPPL_PROG;
&oUpAdmapplProg = &oUpAdmapplProgCollection.Item(1);
rem ***** End: Get/Set Component Interface Properties *****;
rem ***** Execute Save *****;
If Not &oAdmApplCi.Save() Then;
&fileLogE.WriteLine("ADM_APPL_NBR Save Error = " | &Appl_nbr);
errorHandler();
Else
&fileLogS.WriteLine("ADM_APPL_NBR = " | &Appl_nbr | ", Action: " | &Action | ", Reason: " | &Reason | " Saved");
End-If;
rem ***** Execute Cancel *****;
If Not &oAdmApplCi.Cancel() Then;
errorHandler();
throw CreateException(0, 0, "Cancel failed");
End-If;
End-If;
End-For;
&fileLog.WriteLine(&ex.ToString());
&fileLog.WriteLine("End");
&fileLog.Close();
&fileLogS.Close();
&fileLogE.Close();
Comments
Post a Comment