|
|
![]() |
|
|
|
|
||
|
Subfile Positioning Hey, Ted: I have several RPG IV programs that display a subfile in a work-with-like display. Users enter option numbers in the option field that begins each subfile record. When a user selects a subfile record, the system usually displays another display format in order to handle the request. When the subfile is redisplayed, the first page of the subfile is shown. How can I position the subfile to the page that contains the selected subfile record?
-- Patrick You need to add the Subfile Record Number (SFLRCDNBR) keyword to your display files. Use this keyword with a four-digit, hidden, zoned-decimal field. The value in this field tells the system which page of a subfile to display. Update this field every time an option is processed. Initialize this field to the number one (1) every time you reload the subfile in order to avoid a run-time error. I recommend you use the CURSOR option to position to the record whose relative record number matches the value in the hidden field. Here is a short RPG IV program and display file you can play with in order to understand this technique. When you run this program, use option 5 to display more information about a record. (Don’t worry--you don't need a database file; the program displays some dummy data.) When the subfile is redisplayed, you will see the page containing the last selected subfile record. Here is display file CD1102D: * To compile: * CRTDSPF FILE(xxx/CD1102D) + * SRCFILE(xxx/QDDSSRC) SRCMBR(CD1102D) A CF03(03) A DSPSIZ(24 80 *DS3) A R SFL SFL A OPT 1 B 6 3 A DTA 5 0O 6 8 A R CTL SFLCTL(SFL) A SFLDSP A SFLDSPCTL A SFLSIZ(16) A SFLPAG(15) A POSRRN 4S 0H SFLRCDNBR(CURSOR) A 5 3'Opt Data ' A DSPATR(UL) A R SCRN A NUM 5 0B 4 5 A ALPHA 28 O 4 15 Here is RPG program CD1102R: * To compile * CRTBNDRPG PGM(xxx/CD1102R) + * SRCFILE(xxx/QRPGLESRC) SRCMBR(CD1102R) Fcd1102d cf e workstn sfile(sfl:rrn) D rrn s 4 0 D c c 'ABCDEFGHIJKLMNOPQRSTUVWXYZ7890- D 1234567890abcde' * fill the subfile with dummy data C for rrn = 1 to 45 C eval dta = rrn C write sfl C endfor * display the subfile C eval posrrn = 1 C exfmt ctl C dow not *in03 C exsr dosfl C exfmt ctl C enddo C* C eval *inlr = *on * process subfile options C dosfl begsr C readc sfl C dow not %eof(cd1102d) C if opt = '5' C exsr show C z-add rrn posrrn C eval opt = *blank C update sfl C endif C readc sfl C enddo C endsr * display the data C show begsr C* C eval num = dta C eval alpha = %char(num) + '=' C + %subst(c:num:1) C exfmt scrn C* C endsr -- Ted
|
Editors
Contact the Editors |
|
Last Updated: 12/11/02 Copyright © 1996-2008 Guild Companies, Inc. All Rights Reserved. |