Understanding Current Context

Most PeopleCode programs run in a current context. The current context determines which buffer fields can be contextually referenced from PeopleCode, and which row of data is the current row on each scroll level at the time a PeopleCode program is running.

Image: Current context for rowsets

The current context for the data buffer access classes is similar to the current context for accessing the component buffer, as shown in the following diagram:

Current context for rowsets

In this example, a PeopleCode program is running in a buffer field on the second row of the level one rowset. The following code returns a row object for the second row of the level one rowset, because that is the row that is the current context.

Local Row &ROW
&ROW = GetRow();

The following code returns the B2 level two rowset because of the current context:

Local Rowset &ROWSET2
&ROWSET2 = &ROW.GetRowset(SCROLL.EMPL_CHKLST_ITM);

This code does not return either the C2 or the A2 rowsets. It returns only the rowset associated with the second row of the level one rowset.

Creating Records or Rowsets and Current Context

When you instantiate a record object using the CreateRecord function, you are only creating an area in the data buffers that has the same structure as the record definition. It does not contain any data. This record object does not have a parent rowset and is not associated with a row. It is a freestanding record object and, therefore, is not considered part of the current context.

The same concept applies when you instantiate a rowset object using the CreateRowset function. You are only creating an area in the data buffers that has the same structure as the records or rowset that the new rowset is based on. The rowset does not contain any data. This type of rowset does not have a parent rowset or row.