Search code examples
ibm-midrangerpgle

How can I control multiple subfiles on the same screen?


I am having issues with multiple subfiles on the same screen. I display two subfiles horizontally and I am only able to use page up and page down on the one that is loaded in second. I read somewhere that you can change the "active" subfile but haven't found anything further.

RPG Code:

     // display screen
     if #rrn02 <> 0 and #rrn03 <> 0;

       write msgctlw;
       write win01;
       write ctl03;
       write ctl02;
       read  ctl02;
       read  ctl03;

     else;

       *in02   = *on;
       @err00  = *on;
       @errmsg = '*Error: No Records Retrieved';
       @errmsgs1(@errmsg);


     ENDIF;               

1st Subfile:

 A          R SFL02                     SFL
 A            WINCD1         5      2  1
 A                                      COLOR(YLW)
 A            WINST1         2      2  7
 A                                      COLOR(YLW)
 A            WINCITY1      15      2 11
 A                                      COLOR(YLW)

 A                                  3  1'*-----------------------*'
 A          R CTL02                     SFLCTL(SFL02)
 A N61                                  SFLDSPCTL
 A N60                                  SFLDSP
 A                                      SFLPAG(5)
 A                                      SFLSIZ(500)
 A                                      WINDOW(4 8 13 25)
 A                                      OVERLAY
 A N60                                  SFLEND(*MORE)
 A  62                                  SFLCLR
 A                                      SFLCSRRRN(&#CSR02)
 A                                      SFLFOLD(CA11)
 A                                      CF06
 A                                      CF15
 A                                      WDWBORDER((*DSPATR ND))
 A
 A            #RRN02         4S 0H      SFLRCDNBR(CURSOR)
 A            #CSR02         5S 0H
 A            @CURRCD       10A  H
 A            @CURFLD       10A  H
 A            @CURPOS        4S 0H
 A                                  1  1'Zip  '
 A                                      COLOR(GRN)
 A                                      DSPATR(RI)
 A                                      DSPATR(UL)
 A                                  1  7'St'
 A                                      COLOR(GRN)
 A                                      DSPATR(RI)
 A                                      DSPATR(UL)
 A                                  1 11'City           '
 A                                      COLOR(GRN)
 A                                      DSPATR(RI)
 A                                      DSPATR(UL)              

2nd Subfile:

 A          R SFL03                     SFL
 A            WINCD2         5      2  1
 A                                      COLOR(YLW)
 A            WINST2         2      2  7
 A                                      COLOR(YLW)
 A            WINCITY2      15      2 11
 A                                      COLOR(YLW)

 A                                  3  1'*-----------------------*'
 A          R CTL03                     SFLCTL(SFL03)
 A N61                                  SFLDSPCTL
 A N60                                  SFLDSP
 A                                      SFLPAG(5)
 A                                      SFLSIZ(500)
 A                                      WINDOW(4 41 13 25)
 A                                      OVERLAY
 A N60                                  SFLEND(*MORE)
 A  62                                  SFLCLR
 A                                      SFLCSRRRN(&#CSR03)
 A                                      SFLFOLD(CA11)
 A                                      CF06
 A                                      CF15
 A                                      WDWBORDER((*DSPATR ND))
 A
 A            #RRN03         4S 0H      SFLRCDNBR(CURSOR)
 A            #CSR03         5S 0H
 A            @CURRCD       10A  H
 A            @CURFLD       10A  H
 A            @CURPOS        4S 0H
 A                                  1  1'Zip  '
 A                                      COLOR(GRN)
 A                                      DSPATR(RI)
 A                                      DSPATR(UL)
 A                                  1  7'St'
 A                                      COLOR(GRN)
 A                                      DSPATR(RI)
 A                                      DSPATR(UL)
 A                                  1 11'City           '
 A                                      COLOR(GRN)
 A                                      DSPATR(RI)
 A                                      DSPATR(UL)

Solution

  • After more research, I have discovered the root of the problem. I was trying to have two subfiles side by side when the OS can only handle two subfiles stacked vertically.

    Taken from this blog post:

    Side by side subfile has to be handled by programming as OS/400 will not handle it automatically.

    To achieve my desired result (two lists side by side) I am going to put my data into one subfile and split it into two lines using SFLLN(2) in my DDS.