• Skip to main content
  • Skip to primary sidebar
  • Home
  • Connect
  • Contact
  • About Us

BareFoot PeopleSoft

Oracle PeopleSoft Tips and Tricks

Tip 002: Basic Rowset Processing

March 19, 2018

PeopleCode | Loop through and process a series of records in a rowset.

<< Previous  | Next >>

A. Everyday Rowsets

A common programming requirement asks that you loop through a list of records in a rowset. For current purposes, the rowset could be a grid or a scroll area on a page, or it could be data that you’ve loaded directly into memory for further processing.

Below is a simple block of code to carry out this requirement for a standalone rowset. This code consists of three parts: (a) declare variables, (b) define the standalone rowset, and (c) loop through each record in the rowset.

/* Variable Declarations */
Local integer &i;
Local Record &disabilityRec;
Local Rowset &disabilityRS;

/* Define the Rowset */
&disabilityRS = CreateRowset(Record.DISABILITY);
&disabilityRS.Fill("where EMPLID = '123456'");

/* Loop through each record in the rowset */
for &i = 1 to &disabilityRS.ActiveRowCount
   &disabilityRec = &disabilityRS.GetRow(&i).DISABILITY;

   /* PERFORM FURTHER PROCESSING HERE */
end-for;

Here is a slightly modified version of the above code to handle a rowset already located on the page (this code assumes the rowset is located at ‘Level 1’).

/* Variable Declarations */
Local integer &i;
Local Record &disabilityRec;
Local Rowset &disabilityRS;

/* Define the Rowset */
&disabilityRS = GetLevel0().GetRow(1).GetRowset(Scroll.DISABILITY);

/* Loop through each record in the rowset */
for &i = 1 to &disabilityRS.ActiveRowCount
   &disabilityRec = &disabilityRS.GetRow(&i).DISABILITY;

   /* PERFORM FURTHER PROCESSING HERE */
end-for;

In the second example, note the use of ‘GetRowset’ and ‘Scroll’ to define a variable based on a rowset already loaded on the page (or to use the correct lingo, already loaded into the ‘component buffer’).

 

See Also:

Tip 033: Sorting a Rowset

<< Previous  | Next >>

Filed Under: PeopleCode Tagged With: Loop, Rowset

Primary Sidebar

Categories

  • Administration
  • Application Engine
  • BI Publisher
  • COBOL
  • Data Mover
  • PeopleCode
  • PeopleTools
  • Portal
  • PS Query
  • Security
  • SQL
  • Utilities

Copyright © 2023 Elimbah Consulting Ltd