GetRecord method: Row class

Syntax

GetRecord({n | RECORD.recname})

Description

The GetRecord method creates a record object that references the specified record within the current row object. This is the default method for a row object. This means that any row object, followed by a parameter list, acts as if GetRecord is specified.

Parameters

Parameter Description

n | RECORD.recname

Specify a record to be used for instantiating the record object. You can specify either n or RECORD.recname, Specifying n creates a record object for the nth record in the row. This might be used if writing code that needs to examine all records in a row without being aware of the record name. Specifying RECORD.recname creates a record object for the record recname.

Note:

There is no way to predict the order the records will be accessed. Use the n option only if the order in which the records are processed doesn’t matter.

Returns

A record object.

Example

The following example gets a record, then assigns the name of the record to the variable &TMP:

&REC = &ROW.GetRecord(RECORD.QEPC_LEVEL1_REC);

&TMP = &REC.NAME;  /* note that NAME is a property of the record class */

Because GetRecord is the default method for a row, the following code is identical to the previous:

&REC = &ROW.QEPC_LEVEL1_REC;

&TMP = &REC.NAME; 

The following example loops through all the records for a row:

Local rowset &LEVEL1;
Local row &ROW;
Local record &REC;

&LEVEL1 = GetRowset(SCROLL.EMPL_CHECKLIST);
For &I = 1 to &LEVEL1.ActiveRowCount
   &ROW = &LEVEL1.GetRow(&I);
   For &J = 1 to &ROW.RecordCount
      &REC = &ROW.GetRecord(&J);
         /* do processing */
   End-For;
End-For;

The following function takes a rowset and a record, passed in from another program. GetRecord won’t take a variable for the record, however, using the @ symbol you can convert the string to a component record name.

Function Get_My_Row(&PASSED_ROWSET, &PASSED_RECORD)
   For &ROWSET_ROW = 1 To &PASSED_ROWSET.RowCount
      &UNDERLYINGREC = "RECORD." | &PASSED_ROWSET.DBRecordName;
      &ROW_RECORD = &PASSED_ROWSET.GetRow(&ROWSET_ROW).GetRecord(@&UNDERLYINGREC);
      /* Do other processing */
   End-For;
End-Function;