Using the CopyTo Method

The CopyTo method copies like-named fields from a source rowset to a destination rowset. To perform the copy, it uses like-named records for matching, unless specified. It works on any rowset except the Application Engine state records. The following is an example:

Local Rowset &MYRS1, MYRS2; 
Local String &EMPLID; 
&MYRS1 = CreateRowset(RECORD.SOMEREC); 
&MYRS2 = CreateRowset(RECORD.SOMEREC); 
&EMPLID = '8001'; 
&MYRS1.Fill("where EMPLID = :1", &EMPLID); 
&MYRS1.CopyTo(&MYRS2);

After running the previous code segment, &MYRS2 contains that same data as &MYRS1. Both &MYRS1 and &MYRS2 were built using like-named records.

To use the CopyTo method where there are no like-named records, you must specify the source and destination records. The following code copies only like-named fields:

Local Rowset &MYRS1, MYRS2; 
Local String &EMPLID; 
&MYRS1 = CreateRowset(RECORD.SOMEREC1); 
&MYRS2 = CreateRowset(RECORD.SOMEREC2); 
&EMPLID = '8001'; 
&MYRS1.Fill("where EMPLID = :1", &EMPLID); 
&MYRS1.CopyTo(&MYRS2, RECORD.SOMEREC1, RECORD.SOMEREC2);