Get Latest Updates directly delivered in your Email

PeopleCode Examples for Traversing Level 0 to Level 3

Here is the Example Code , Please do modifications based on your requirements.

/*** Demo Code For Traversing Level 0 to Level 3 ***/

Local Rowset &rsLevel0, &rsLevel1, &rsLevel2, &rsLevel3;
Local Row &rowLevel0, &rowLevel1, &rowLevel2, &rowLevel3;
Local Field &fldLevel0, &fldLevel1, &fldLevel2, &fldLevel3;
Local integer &i, &j, &k;

&rsLevel0 = GetLevel0();

/** Get Level 0 Field **/
&fldLevel0 = &rsLevel0.GetRow(1).GetRecord(Record.L0_REC).GetField(Field.L0_FLD);
/** Get Level 0 Field Value **/
&Level0FldValue = &fldLevel0.Value;

&rowLevel0 = &rsLevel0.GetRow(1);
&rsLevel1 = &rowLevel0.GetRowset(Scroll.LEVEL1_RECORD);
For &i = 1 To &rsLevel1.ActiveRowCount

   /** Get Level 1 Field **/
   &fldLevel1 = &rsLevel1.GetRow(&i).GetRecord(Record.L1_REC).GetField(Field.L1_FLD);
   /** Get Level 1 Field Value **/
   &Level1FldValue = &fldLevel1.Value;

   &rowLevel1 = &rsLevel1.GetRow(&i);
   &rsLevel2 = &rowLevel1.GetRowset(Scroll.LEVEL2_RECORD);
   For &j = 1 To &rsLevel2.ActiveRowCount

      /** Get Level 2 Field **/
      &fldLevel2 = &rsLevel2.GetRow(&j).GetRecord(Record.L2_REC).GetField(Field.L2_FLD);
      /** Get Level 2 Field Value **/
      &Level2FldValue = &fldLevel2.Value;

      &rowLevel2 = &rsLevel2.GetRow(&j);
      &rsLevel3 = &rowLevel2.GetRowset(Scroll.LEVEL3_RECORD);
      For &k = 1 To &rs_level3.ActiveRowCount

         /** Get Level 3 Field **/
         &fldLevel3 = &rsLevel3.GetRow(&k).GetRecord(Record.L3_REC).GetField(Field.L3_FLD);
         /** Get Level 3 Field Value **/
         &Level3FldValue = &fldLevel3.Value;
         &rowLevel3 = &rsLevel3.GetRow(&k);

         /* Do Processing  **/
         /* If Any Summation Calculation */
         /* &sum = &sum + &Level3FldValue */

      End-For;
   End-For;
End-For;
Related Article you might like:
Publish:  12 years ago
Categorized:   PeopleCode
Previous:
Manipulation with Date Functions in MySQL
Next:
PeopleSoft PeopleCode Frequently Asked Question

8 comments on “PeopleCode Examples for Traversing Level 0 to Level 3

  1. Very precise code. And handy too. I’m a newbie w.r.t to AWE and am yet to look at the AWE post, but I think it would be a great reference.

    Appreciate your contributions towards the PeopleSoft community.

    Thanks.
    Mani

Leave a Reply

Your email address will not be published. Required fields are marked *

Write your code inside of code or pre tag

<code> your code resides here </code>