Understanding Data Buffer Access

This section discusses:

  • Data buffer access.

  • Access classes.

  • Data buffer model and data access objects.

In addition to the built-in functions you use to access the component buffer, classes of objects are available that provide access to structured data buffers using the PeopleCode object syntax.

The data buffers accessed by these classes are typically the component buffers that are loaded when you open a component. However, these classes may also be used to access data from general data buffers, loaded by an Application Engine program, a component interface, and so on.

The methods and properties of these classes provide functionality that is similar to what has been available using built-in functions. However, they also provide improved consistency, flexibility, and new functionality.

The four data buffer classes are: Rowset, Row, Record, and Field. These four classes are the foundation for accessing component buffer data through the new object syntax.

A field object, which is instantiated from the Field class, is a single instance of data within a record. It is based on a field definition.

A record object, which is instantiated from the Record class, is a single instance of a data within a row. It is based on a record definition. A record object consists of one to n fields.

A row object, which is instantiated from the Row class, is a single row of data that consists of one to n records of data. A single row in a component scroll area is a row. A row may have one to n child rowsets. For example, a row in a level two scroll area may have n level three child rowsets.

A rowset object is a data structure used to describe hierarchical data. It is made up of a collection of rows. A component scroll area is a rowset. You can also have a level zero rowset.

The data model assumed by the data buffer classes is that of a PeopleTools component, where scroll bars or grids are used to describe a hierarchical, multiple-occurrence data structure. You can access these classes using dot notation.

The four data buffer classes relate to each other in a hierarchical manner. The main points to understand these relationships are:

  • A record contains one or more fields.

  • A row contains one or more records and zero or more child rowsets.

  • A rowset contains one or more rows.

For component buffers, think of a rowset as a scroll area on a page that contains all of the data in that scroll area. A level zero rowset contains all the data for the entire component. You can use rowsets with application messages, file layouts, business interlinks, and other definitions in addition to components. A level zero rowset from a component buffer only contains one row: the keys that the user specifies to initiate that component. A level zero rowset from data that is not a component, such as a message or a file layout, might contain more than one level zero row.

The following is basic PeopleCode that traverses through a two-level component buffer using dot notation syntax. Level zero is based on record QA_INVEST_HDR, and level one is based on record QA_INVEST_LN.

Local Record &HDR_REC, &LINE_REC;
&HDR_ROWSET = GetLevel0();

For &I = 1 to &HDR_ROWSET.RowCount
   &LINE_ROWSET = &HDR_ROWSET(&I).GetRowset(1);
   For &J = 1 to &LINE_ROWSET.RowCount

Each rowset is declared and instantiated. In general, your code is easier to read and maintain if you follow this practice.