Subfile Program Procedure in RPG



PROGRAM:

CLEAR SUBFILE

SFLCLR = ON
Write SUBFILE CONTROL
SFLCLR = OFF
SFLDSPCTL = ON
SFLEND = ON
DisplayFileRRN = 0
SETLL to FILE


LOAD SUBFILE

Read from file and write to subfile
Increment ProgramRRN by 1 for each record


DISPLAY SUBFILE

If ProgramRRN > 0
          DisplayFileRRN = 1
          SFLDSP = ON
Else
          SFLDSP = OFF
EndIf

DOW *IN03 = *OFF
          If RcdCursor <> 0
                   DisplayFileRRN = ProgramRRN
          EndIf
          Write MSGCTL (for message subfile)
          If SFLDSP = OFF
                   Write   EMPTYSUBFILE
          EndIf
          Write FOOTER
          EXFMT SUBFILE CONTROL

NOTE:

Declare ProgramRRN - 4,0 in RPGLE & ASSIGN IT TO SUBFILE AS BELOW:

FSSM720D   CF   E          WORKSTN                     
F                                                        SFILE(DisplaySubfile:ProgramRRN)
F                                                        SFILE(MessageSubfile:MessageRRN)

Declare SFLCSRRRN (&) SFLRCDNBR Keywords in DSPF:

Give this after declaring SFLDSP, SFLDSPCTL, SFLCLR, SFLEND(*MORE) & SFLINZ keywords in DSPF.

A                                                        SFLCSRRRN(&RcdCursor)
A            S1RRN          4S 0H      SFLRCDNBR(CURSOR)
A            RcdCursor     5S 0H                       


(Make sure you have specified OVERLAY on Subfile Control & EMPTYSUBFILE records in Display File)

No comments