Record.Field Specification | KEVIN RESCHENBERG 10-17-2007 |
First, a reminder: The latest version of the SQR Debugger
is available for download. This update deals with the RELLANG.SQC monster.
In a previous post on navigating
the PeopleSoft component buffer, I talked about the different coding styles that can be used in finding
data within the buffer. Today I'd like to mention one particular topic that can cause confusion
(it definitely confused me).
The original sytax was RECORD.FIELD. To work with a value in
the MY_FIELD field of the MY_RECORD table, you would just code MY_RECORD.MY_FIELD.
When "version 2" of PeopleCode was released—the one
that supported certain objects and the "dot" syntax, but before the object-oriented
Application Packages—it supported both the old and new ways of addressing data
in the buffer. Now we can get a reference to a row, a record, a field, or any of a
number of other object types. (For documentation on these objects, head to the
API Reference instead of the PeopleCode Reference.) There is a "GetRecord" method
that returns a reference to a record (table, view, or derived record). One would
think that we could code:
&Rec = GetRecord(MY_RECORD); Wrong
But that doesn't work. The system thinks that MY_RECORD is a field
name, even though we are asking for a record reference! It appends the record name
from the current context and you will get an error saying that SOME_RECORD.MY_RECORD
is not a defined field. Or, if it can't determine a context within a record, you will
get the "full record.field specification required" message.
The key to dealing with these issues is to be verbose. Instead of just asking for a reference
to a record object, say that you want the reference to this object and that yes, it
really is a record:
&Rec = GetRecord(Record.MY_RECORD);
&Fld = GetRecord(Record.MY_RECORD).GetField(Field.MY_FIELD);
Just remember that RECORD.FIELD is PeopleCode's default way of
specifying a field, and if it sees one name it will try to turn it into RECORD.FIELD
by appending the closest record name. This is the source of many confusing error
messages when you are getting started with the newer syntax. It explains why the
following variation works—but it looks ugly to me:
&Fld = GetRecord(MY_RECORD.MY_FIELD).GetField(MY_RECORD.MY_FIELD);
|