Rowset Examples

The following code example traverses up to four levels of rowsets and could easily be modified to do more. This example only processes the first record in every rowset. To process every record, set up another For loop (For &R = 1 to &LEVELX.RECORDCOUNT, and so on). Notice the use of the ChildCount function (to process all children rowsets within a rowset), ActiveRowCount, IsChanged, and dot notation.

In the following example, ellipses indicate where application-specific code should go.

&Level0_ROWSET = GetLevel0();
For &A0 = 1 To &Level0_ROWSET.ActiveRowCount

    ... 

/***************************/
/* Process Level 1 Records */
/*-------------------------*/
   If &Level0_ROWSET(&A0).ChildCount > 0 Then
   For &B1 = 1 To &Level0_ROWSET(&A0).ChildCount
      &LEVEL1_ROWSET = &Level0_ROWSET(&A0).GetRowset(&B1);
      For &A1 = 1 To &LEVEL1_ROWSET.ActiveRowCount
      If &LEVEL1_ROWSET(&A1).GetRecord(1).IsChanged Then

          ... 

 /***************************/
 /* Process Level 2 Records */
 /*-------------------------*/
         If &LEVEL1_ROWSET(&A1).ChildCount > 0 Then
         For &B2 = 1 To &LEVEL1_ROWSET(&A1).ChildCount
            &LEVEL2_ROWSET = &LEVEL1_ROWSET(&A1).GetRowset(&B2);
            For &A2 = 1 To &LEVEL2_ROWSET.ActiveRowCount
            If &LEVEL2_ROWSET(&A2).GetRecord(1).IsChanged Then

               ... 

/***************************/
/* Process Level 3 Records */
/*-------------------------*/
               If &LEVEL2_ROWSET(&A2).ChildCount > 0 Then
               For &B3 = 1 To &LEVEL1_ROWSET(&A2).ChildCount
                  &LEVEL3_ROWSET = &LEVEL2_ROWSET(&A2).GetRowset(&B3);
                  For &A3 = 1 To &LEVEL3_ROWSET.ActiveRowCount
                  If &LEVEL3_ROWSET(&A3).GetRecord(1).IsChanged Then

                      ...
                  End-If; /* A3 - IsChanged */
                  End-For; /* A3 - Loop */
               End-For; /* B3 - Loop */
               End-If; /* A2 - ChildCount > 0 */
/*--------------------------------*/
/* End of Process Level 3 Records */
/**********************************/

            End-If; /* A2 - IsChanged */
            End-For; /* A2 - Loop */
            End-For; /* B2 - Loop */
            End-If; /* A1 - ChildCount > 0 */
/*--------------------------------*/
/* End of Process Level 2 Records */
/**********************************/

      End-If; /* A1 - IsChanged */
      End-For; /* A1 - Loop */
   End-For; /* B1 - Loop */
   End-If; /* A0 - ChildCount > 0 */

/*--------------------------------*/
/* End of Process Level 1 Records */
/**********************************/
End-For; /* A0 - Loop */