Midware Ltd.

Manipulating Subfiles


Sign-up for e-mail notifications

Take our weekly poll

Dow Jones Intraday

Nasdaq Intraday



A common requirement when writing subfiles is the ability to position the subfile at will.  This is done fairly easily by defining a 4-digit field in the subfile control record with the SFLRCDNBR(CURSOR) keyword.  Simply set the field to the desired subfile record number prior to writing the control record.

A problem however is determining where the subfile is positioned when enter or a function key is pressed and control passes back to the program.

Normally, the keyword SFLCSRRRN is used in the display file to assign a field that will be set to the subfile record number the cursor is positioned to.  For example:

A                            SFLCSRRRN(&CSRRRN)
A      CSRRRN       5S 0H

When ever control returns to the program, CSRRRN will be set to the relative record number that the cursor is positioned to.

The problem arises however when the cursor is not actually positioned on the subfile itself - for example in the control record.  In this case, CSRRRN will be set to zero.

A consistent method to determine the current subfile relative record number displayed at the top of the screen is to use the File Information Data Structure for the display file.  In RPG IV, the F-spec for the display file would be coded as follows:

Fdisplayf  cf   e             workstn infds(@WSDS)
F                                     sfile(sflrec: @SflRRN)

You then need to code the work station data structure in the D-specs.  The subfile RRN displayed at the top of the screen when control passes back to the program is defined as a binary field in positions 378-379:

D @WSDS           DS
D  @ScreenRRN           378    379b 0

Home Feedback Contents Search

Send mail to midware@midwareservices.com with questions or comments about this web site.
Copyright 2000 Midware, Ltd.

Last Modified:  September 14, 2000