Subfile program to display a load all subfile

pts.
Tags:
RPG
Hi, I have written a simple subfile program to display a load all subfile. When I press page down which is automatically handled by O/S, it displays me another set of records. From the second screen, if I press ENTER, it comes back to the previous screen which should not happen. Only, when I press Page up, it should come back,not with Enter. Is there any way in which I can avoid this in a Load all subfile? Thanks

Answer Wiki

Thanks. We'll let you know when a new response is added.

you have a cursor-position error. It’s not linked to a load-all subfile.

in your prg, after looping on readc or chain subfile, you have change the cursor position to 1. the cursor position is defiled in the F card. For example
sfile(sflb:ran01b)
means ran01b is the key for chaining the subfile sflb.
It also means next prompt cursor line is ran01B

Discuss This Question: 4  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Phacops
    If I understand what you are trying to do, I think that you can handle the problem by using the display file feedback area in your program and SFLRCDNBR in your display file. From the feedback area you can get the subfile record number of the first subfile record being shown. That value gets put into the field associated with SFLRCDNBR. So, if you have a load all subfile with ten records per page, and the user pages down twice, records 21-30 are being shown. The feedback area provides the value of 21 when control returns to the program after the user presses enter. If you put 21 into the hidden field for SFLRCDNBR, when the program redisplays the screen the subfile will be displayed starting with record 21. I haven't done this for a while, but I think I have some non-production code doing this, which I'll post if it is available.
    0 pointsBadges:
    report
  • Graeme
    I like coding in this way in RPG - you load the entire subfile and so don't have to mess around with routines to handle the page-up and page-down. If I was going to knock together an easy RPG routine for a 'load-all', it would be roughly this structure: EXSR CLR01 (CLEAR SUBFILE ROUTINE) EXSR BLD01 (BUILD SUBFILE ROUTINE) *IN03 DOWEQ*OFF WRITEF01 EXFMTCTL01 SELEC BLAH WHEQ BLAH (DO CLEVER THINGS) EXSR CLR01 EXSR BLD01 BLAH WHEQ BLAH (DO OTHER CLEVER THINGS) EXSR CLR01 EXSR BLD01 OTHER READC etc. (DO REALLY CLEVER THINGS) EXSR CLR01 EXSR BLD01 ENDSL ENDDO If I wanted to avoid giving my users a program that went back to the beginning ever time they pressed enter/f4/f4/f8/selection (meaning that they would phone me and use swear words every time they page through 10 screens!), I would make sure this bit was in my control record in my display file: A POS01 4S 0H SFLRCDNBR(*TOP) A TOP01 5S 0H SFLSCROLL A RRN01 4S 0H The POS01 field remembers what the relative record number of the top row on the screen the user is at a nanosecond before he presses the ANY key. When redisplaying the screen after doing the clever things you've coded when the user presses the ANY key, the system takes the number that is in the TOP01 field, finds that relative record number and displays from that record on. The RRN01 is the relative record number and, well, is a number that is relative to a record in your subfile. SO... ('here comes the science' as they say in the adverts), all you have to do before you execute the clear and build subroutines is sneak the POS01 into the TOP01 and your subfile will magically appear to stay in the same place! DISCLAIMER: 1. If you have no records in the subfile, you will have to make a cunning plan. 2. If you subfile content changes (i.e., the number of records change), you will have to make a cunning plan. 3. If you page all the way down to the bottom of the subfile, you will have to make a cunning plan. 4. Anything I may have misspelt or lied about is someone else's fault. Now, you're in luck because I'm a hugely lazy person and can tell you the easiest way to do all of these things. Create a field called MAX01 in your program and each time you build subfile routine writes a record, add one to it (at the same time as you increment the RRN). In your control record, you will have something like this: A 30 SFLDSP A SFLDSPCTL A 31 SFLCLR A 32 SFLEND In your RPG program, stick in a little if that uses this: RRN01 IFEQ *ZEROS MOVE *OFF *IN30 ENDIF Also stick this one in to deal with funnies or changes: POS01 IFLE *ZEROS Z-ADDTOP01 POS01 ENDIF And this one will deal with the 'edge of the world' one - it will position the top of the display to the third last subfile record: RRN01 IFGE MAX01 MAX01 SUB 3 POS01 ELSE Z-ADDTOP01 POS01 ENDIF If you lost the will to live, ten lines into my inane ramble, e-mail me and I'll dump and example display and program into a text file and whizz it over to you. Good Luck! Graeme
    0 pointsBadges:
    report
  • Openanewdoor
    This should take care of your problem: ***in your dspf program--just under the Control format...Add a field for SFLRCDNBR R TFD001B SFLCTL(TFD001A) @PAG 4S 0H SFLRCDNBR ****************************************************** FM0323FM CF E WORKSTN INFDS(INFDS) SFILE(FM0323A:@RRN) ******************************************************** Information Data Structure INFDS DS @SPRRN 378 379B 0 ***any time your display your screen--save the relative record number from the information data structure-- like so WRITE FM0323C EXFMT FM0323B eval @PAG = @SPRRN *************************************************** ***every time you clear the subfile --reset the sflrcdnbr *** like so... MOVE *ON *IN30 WRITE FM0323B MOVE *OFF *IN30 eval @RRN = 0 RESET @PAG ************************************************* ***be sure to initialize the sflrcdnbr from the start *INZSR BEGSR eval @PAG = 1
    0 pointsBadges:
    report
  • TomLiotta
    The subfile returns to the top because that's what your RPG programming tells it to do. When <Enter> is pressed, control is returned to your program. The OS will handle PageUp and PageDown, but you handle <Enter>. Most likely, your program simply redisplays the subfile and doesn't say which page to display. It displays it from the beginning. It might even reload the subfile. What do you expect to happen when a user presses <Enter>? The user is telling your program "I'm done. I entered my choice." If you want a particular page to be shown when your program redisplays the subfile, then it needs to capture the subfile record from that moment and use it to position the subfile. The SFLRCDNBR() suggestions are probably your best choice. But you can also position at the beginning again. How else would a user choose to start from the beginning? Tom
    125,585 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following