The at @ Meta Operator


The @ (at) meta operator is a very useful meta programming operator in PeopleCode. When applied, the operator turns a string into a reference in PeopleCode.

For example, the follow PeopleCode snippet:

Local string &sEmplidField = "EMPLID";
Local string &sEmplid;

&sEmplid = GetField(@("Field." | &sEmplidField)).Value;

Effectively turns into the following code:

Local string &sEmplid;

&sEmplid = GetField(Field.EMPLID).Value;

This is a trivial example, however, hopefully you can see the power of doing something like this to generate dynamic code based on variables.

For example, say you want to get the value of a field passed to a method, but you don't know what field that will be. For such a scenario, you could use code like the above to dynamically cater for any field.

The @ operator can be used in methods/functions that expect a string that is a reference to a particular Definition or an Object (however I'm not sure if this is the case for all objects ).

Some of the common functions where it can be used include:

  • GetField
  • GetRecord
  • CreateRecord
  • GetRowset
  • CreateRowset
  • GetSQL, FetchSQL, DeleteSQL

However it can conceivably be used with any PeopleCode function or method that expects a definition or object reference as a string parameter, for example DoModal, Transfer, SetCursorPos, GenerateComponentPortalURL, and SQLExec.


Revision #2
Created Wed, Jul 31, 2019 12:01 AM by PeopleSoft Wiki
Updated Wed, Jul 31, 2019 12:05 AM by PeopleSoft Wiki