@ Operator

The @ operator converts a string storing a definition reference into the definition. This is useful, for example, if you want to store definition references in the database as strings and retrieve them for use in PeopleCode; or if you want to obtain a definition reference in the form of a string from the operator using the Prompt function.

To take a simple example, if the record field EMPLID is currently equal to 8001, the following expression evaluates to 8001:

@"EMPLID"

The following example uses the @ operator to convert strings storing a record reference and a record field reference:

&STR1 = "RECORD.BUS_EXPENSE_PER"; 
&STR2 = "BUS_EXPENSE_DTL.EMPLID"; 
&STR3 = FetchValue(@(&STR1), CurrentRowNumber(1), @(&STR2), 1); 
WinMessage(&STR3, 64); 

Note:

String literals that reference definitions are not maintained by PeopleTools. If you store definition references as strings, then convert them with the @ operator in the code, this creates maintenance problems whenever definition names change.

The following function takes a rowset and a record, passed in from another program, and performs some processing. The GetRecord method does not take a variable for the record, however, you can dereference the record name using the @ symbol. Because the record name is never hard-coded as a string, if the record name changes, this code does not have to change.

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;