Pages

Custom Search

How to flush an existing data from a grid placed on level 2

Local Rowset &rsLvl1, &rsLvl2;

/* Get Level 1 Rowset */
&rsLvl1 = GetLevel0()(1).GetRowset(Scroll.XXX1); /* Gets the current row of Level 0. */

For &i = 1 To &rsLvl1.ActiveRowCount
 
   /* Get Level 2 Rowset */
   &rsLvl2 = &rsLvl1(&i).GetRowset(Scroll.XXX2);
 
   /* Flush Record */
   &rsLvl2.Flush();
   /* Select Record */
   &rsLvl2.Select(Record.XXX2, "WHERE TERM = :1", &rsLvl1.GetRow(&i).XXX1.STRM.Value);
 
End-For;

Copying Rowsets

What I want is to copy the like-name fields between &rsExample and &rsExampleAudit (the fields EMPLID and NAME).

The following code will NOT work:
&rsExample.CopyTo(&rsExampleAudit)

Why? Because &rsExample consists of a record named EXAMPLE, but &rsExampleAudit consists of a record named AUDIT_EXAMPLE. Because the two rowsets do not have the same underlying record name, the copy does absolutely nothing.

In this scenario, we need to specify a record list, so it knows the source and target record names. This how I need to write this code to make it work:
&rsExample.CopyTo(&rsExampleAudit, Record.EXAMPLE, Record.AUDIT_EXAMPLE)

Generically the syntax is:
&rsSource.CopyTo(&rsTarget, Record.SOURCE_RECNAME, Record.TARGET_RECNAME)