3 Replies Latest reply on Aug 15, 2012 1:11 AM by user9127700

    Bypassing Error Messages With Component Interface

    user10480127
      Hi,

      Does anyone know how to bypass error/warning messages when creating a Component Interface so that the App Engine that is executing the CI does not error out. i.e. if you use search match with CI you sometimes get no match, we're finding that if you want an App Engine to run a CI that the App Engine errors when a match is not found. Does anyone have any workarounds for this type of scenario?
        • 1. Re: Bypassing Error Messages With Component Interface
          HakanBiroglu
          Hi,

          Use the default Try - Catch statements to catch all errors from CI's and decide what should happen based on the error, ignore, write logfile or error.
          When you catch an error you can decide to not trow an error in the Application Engine, since this usually runs CI's in loops and you do not want the Application Engine to crash or rollback all data changes when one row is not processed.

          See below, default generated PeopleCode with some adjustments.
             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;
                    throw CreateException((0, 0, &sErrType | " (" | &sErrMsgSetNum | "," | &sErrMsgNum | ") - " | &sErrMsgText);
               End-For;
               rem ***** Delete the Messages from the collection *****;
               &oPSMessageCollection.DeleteAll();
             End-Function;
          
             try
                     rem ***** Get current PeopleSoft Session *****;
                      &oSession = %Session;
                      
                      rem ***** Set the PeopleSoft Session Error Message Mode *****;
                      rem ***** 0 - None *****;
                      rem ***** 1 - PSMessage Collection only (default) *****;
                      rem ***** 2 - Message Box only *****;
                      rem ***** 3 - Both collection and message box *****;
                      &oSession.PSMessagesMode = 1;
                      
                      rem ***** Get the Component Interface *****;
                      &oMyCi = &oSession.GetCompIntfc(CompIntfc.MyCi);
                      If &oMyCi = Null Then
                         throw CreateException(0, 0, "GetCompIntfc failed");
                      End-If;
                      
                      rem ***** Set the Component Interface Mode *****;
                      &oMyCi .InteractiveMode = True;
                      &oMyCi .GetHistoryItems = True;
                      &oMyCi .EditHistoryItems = True;
          
                     rem ***** Execute Get or Create *****;
                      If Not &oMyCi .Get() Then
                         rem ***** Execute Create ******;
                         If Not &oMyCi .Create() Then;
                            throw CreateException(0, 0, "Create failed");
                         End-If;
                      End-If;
          
                     /* Do some processing here */
          
                      rem ***** Execute Save *****;
                      If Not &oMyCi .Save() Then
                         errorHandler();
                      End-If;
           
             catch exception &ex
             /* catch errors and decide what to do */
               rem &fileLog.WriteLine(&ex.ToString());
             end-try;
          • 2. Re: Bypassing Error Messages With Component Interface
            user9127700
            I have same problem.
            App Engine still return a error.
            • 3. Re: Bypassing Error Messages With Component Interface
              user9127700
              i found workaround

              ref this
              http://tech.groups.yahoo.com/group/peoplesoft-fans/message/24515