2015年4月12日星期日

PeopleCode Examples for Traversing Level 0 to Level 3

PeopleCode Examples for Traversing Level 0 to Level 3
0Publish On June 2, 2013 In PeopleCode
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;

没有评论:

发表评论