Easy Subfile Windowing
June 28, 2002 Timothy Prickett Morgan
I have a subfile application that requires more than 80 columns to display all the necessary information.
I don’t want the information folded to a second line but would like to window left and right, as the Display Physical File Member (DSPPFM) command does.
It would be better if I could lock into place the far-left side of a screen to allow a selection field, even when panning left or right.
Can this be done easily with a subfile?
Yes, David. You only need to think of building subfiles in a way that you’re probably not accustomed to doing. Instead of defining each individual field in the subfile record, define one long text field. Load pieces of this long text field with values from your database.
Let’s assume you have a file called CUSTOMER with the following description:
A UNIQUE A R CUSTREC A COMPANY 3P 0 A CUSTNBR 5P 0 A CUSTNAME 20 A CADDRESS1 18 A CADDRESS2 18 A CCITY 16 A CSTATE 2 A CZIP 10 A CREDITLIM 7S 2 A K COMPANY A K CUSTNBR
You want to display records from the customer file in a subfile and you want to be able to window the customer data right and left. Here’s the display file. Notice the VISIBLE and HIDDEN fields in the subfile record:
A DSPSIZ(24 80 *DS3) A R SFL SFL A OPTION 1 I 5 2 A VISIBLE 76A O 5 4 A HIDDEN 256A H A R CTL SFLCTL(SFL) A SFLSIZ(0011) A SFLPAG(0010) A SFLDSPCTL A SFLDSP A CA03(03) A 3 2'Window:' A WINDOW 3 0B 3 10
Here’s the RPG program that drives the subfile:
Fbigdta02d cf e workstn sfile(sfl:rrn) Fcustomer if e k disk D rrn s 10u 0 D sflsize s 10u 0 D windowsave s 10u 0 inz(0) D len s 10u 0 ** one-time only calcs C eval len = %size(visible) C eval window = 1 ** load the subfile C read custrec C dow not %eof(customer) C eval rrn = rrn + 1 C eval hidden = %editc(company:'4') + ' ' + C %editc(custnbr:'4') + ' ' + C caddress1 + ' ' + C caddress2 + ' ' + C ccity + ' ' + C cstate + ' ' + C czip + ' ' + C %editc(creditlim:'J') C write sfl C read custrec C enddo C eval sflsize = rrn * display the subfile until F3 pressed C dou *in03 C if window <> windowsave C exsr adjust C endif C exfmt ctl C enddo C C eval *inlr = *on C***** C adjust begsr C C for rrn = 1 to sflsize C rrn chain sfl C eval visible = %subst(hidden: window: len) C update sfl C endfor C C eval windowsave = window C C endsr
The HIDDEN field is loaded with the fields from the CUSTOMER file. I used the %editc built-in function to place the numeric fields into HIDDEN. The ADJUST subroutine copies a portion of HIDDEN into VISIBLE–the field the user sees–beginning at the position the user specified by keying in a value for the WINDOW field.
The following screen shots show the data windowed to positions 1 and 25 respectively.
ADVANCED SYSTEMS CONCEPTS
SEQUEL meets all your iSeries and AS/400 data access needs in a single, integrated solution:
Take 6 minutes to
For more information or a FREE trial of SEQUEL,