6/16/2015

Component Interface - Calling Find() method

It doesn't seem to be a big deal, calling the Find method should be a piece of cake, but I didn't find any example on the net.  So, here is my explanation :

I. Generate the code to call a CI - simply drag a CI into a blank Peoplecode window.

II. Declare ApiObjects for results of the find :
Local ApiObject &FindKeyCollection, &FindKeyRec;

III. In the code calling the component interface, enter values in keys (optional)
&oCiSsrSsenrlList.STRM = "2151";

IV. Call the Find method; it returns a collection of rows in the search record
&FindKeyCollection = &oCiSsrSsenrlList.Find();

V. Travel through the collection of rows and process each row as needed (stock in an array, select a row, call Get method)
   Local integer &ixyz;
   For &ixyz = 1 To &FindKeyCollection.Count;
      &FindKeyRec = &FindKeyCollection.Item(&ixyz);
      MessageBox(0, "", 0, 0, "INSTITUTION=[" | &FindKeyRec.INSTITUTION | "];ACAD_CAREER=[" | &FindKeyRec.ACAD_CAREER | "];STRM=[" | &FindKeyRec.STRM | "]");
   End-For;


Code : 

[...]  

   &fileLog.WriteLine("Begin");
   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 *****;
   &oCiSsrSsenrlList = &oSession.GetCompIntfc(CompIntfc.CI_SSR_SSENRL_LIST);
   If &oCiSsrSsenrlList = Null Then
      errorHandler();
      throw CreateException(0, 0, "GetCompIntfc failed");
   End-If;
   
   rem ***** Set the Component Interface Mode *****;
   &oCiSsrSsenrlList.InteractiveMode = False;
   &oCiSsrSsenrlList.GetHistoryItems = True;
   &oCiSsrSsenrlList.EditHistoryItems = False;
   

   &oCiSsrSsenrlList.STRM = "2151";
   
   &FindKeyCollection = &oCiSsrSsenrlList.Find();
   
   Local integer &ixyz;
   For &ixyz = 1 To &FindKeyCollection.Count;
      &FindKeyRec = &FindKeyCollection.Item(&ixyz);
      MessageBox(0, "", 0, 0, "INSTITUTION=[" | &FindKeyRec.INSTITUTION | "];ACAD_CAREER=[" | &FindKeyRec.ACAD_CAREER | "];STRM=[" | &FindKeyRec.STRM | "]");
   End-For;

[...]  
 

No comments:

Post a Comment