PeopleCode Record Snapshot

The following is a bit of PeopleCode I came up with to get a snapshot of the contents of a given Record object through PeopleCode. You might find this useful as a way of inspecting a record and its contents at a given point in time during PeopleCode execution.

This code utilises the WriteToLog function to output the snapshot to the Application Server log directory as a tracesql file.

Local Record &rec_Snapshot = &rs(1).EXAMPLE_RECORD;
Local number &i;
Local number &fieldCount = &rec_Snapshot.FieldCount;
Local string &log = "";
WriteToLog(%ApplicationLogFence_Error, "--- BEGIN Record Snapshot for Record: " | &rec_Snapshot.Name | " ---");
For &i = 1 to &fieldCount
   &log = "... ";
   If &rec_Snapshot.GetField(&i).IsInBuf Then   
      &log = &log | &rec_Snapshot.GetField(&i).Name | '=' | &rec_Snapshot.GetField(&i).Value;  
      &log = &log | &rec_Snapshot.GetField(&i).Name | '=' | '(Not in Buffer)';
   WriteToLog(%ApplicationLogFence_Error, &log);
WriteToLog(%ApplicationLogFence_Error, "--- END Record Snapshot for Record: " | &rec_Snapshot.Name | " ---");

Also you'll notice that it uses the Field class IsInBuf method to check if the field is actually in the buffer (i.e. has some data ) and only report the value of the record's field if it has data in the buffer. If not it will report it as (Not In Buffer).


Add a New Comment
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License