.st0{fill:#FFFFFF;}

RPG SQL: load all subfile has fixed size of 9999 records 

 October 10, 2008

By  NickLitten

What is a load all subfile?

A load all subfile is one in which we generally specify the subfile size as 9999 in the record format itself. However, you may define the subfile size to be less than 9999 in the record format and still load all your subfile at a time. In that situation the records will not be placed at contiguous memory location.

So, conceptually a load all subfile is the one in which all records are loaded at one go before they are displayed. Also, they should occupy contiguous memory locations.

Load all subfiles are the easiest concept in subfile. That too when the subfile is display only! Let us now see the example of a load all subfile DDS.

** Declare the name of the record format of the subfile. Notice
** that this time the function SFL has been used to distinguish
** this record format as a subfile
A R LOADALLSF SFL
** Declare fields as we would do in case of normal record format.
A 20A 5 10TEXT('Customer name')
A DSPATR(HI)
**
A 4Y 0 5 02TEXT('customer Number')
A DSPATR(HI)
**
** Control Format of the subfile. Notice the usage of function
** SFLCTL. The name of the subfile has been given here to associa
** this control format with a specific subfile.
A R LOADALLCF SFLCTL(LOADALLSF)
** Function keys are defined in the record format.
A CA01
** Declare the page size and subfile size
A SFLPAG(2)
A SFLSIZ(9999)
** Declare the function SFLCLR. We need this function to clear a
** subfile.
A 50 SFLCLR
** The SFLDSP and SFLDSPCTL functions are necessary to display
** subfile.
A SFLDSP
A SFLDSPCTL
** Define the control format fields. Generally the heading and
** subfile specific instructions are given here.
A 1 26' Customer Display '
A DSPATR(RI)
A 2 02'F1=Exit'
A 4 02'Id'
A DSPATR(UL)
A 4 10'Customer name'
A DSPATR(UL)

The source code with explanation of the ILE RPG program to process the load all subfile in the above example is given below.

**
**Declare the display file which contains the subfile
**
FFilename++IPEASF.....L.....A.Device+.Keywords+++++++++++++++++++++++
FLOAD_ALL CF E WorkStn
**
** Declare the relative record number (RRN) for the subfile. Notice
** the keyword used to declare subfile.
**
F SFILE(LOADALLSF:W@Rrn1)
**
** Define the RRN of subfile (Typically 4 or 5 length with zero
** decimal places depending on how you handle it. If it's likely to
** reach 10000 then declare the length as 5 otherwise 4.)
**
DW@Rrn1 S 4 0 Inz
**
CL0N01Factor1+++++++Opcode&ExtExtended-factor2++++++++++++
C DoW *INKA = *Off
**
** Execute subroutine to load the subfile
**
C ExSr #LodSfl
**
** ExFmt the CONTROL FORMAT of the subfile.
**
C ExFmt LOADALLCF
C EndDo
**
** Free up resources and return
**
C Eval *InLr = *On
C Return
**
** The subroutine #LODSFL
**
C #LODSFL BegSr
**
** Clear the subfile. Clearing a subfile involves the following four
** statements.
** 1. Swicth on the SFLCLR indicator
** 2. Write to the control format
** 3. Swicth off the SFLCLR indicator
** 4. Reset the RRN to zero (Or one).
** The fourth statement actually is not related to subfile. However,
** we generally reset this value while clearing the subfile itself.
**
C Eval *In(50) = *On
C Write LOADALLCF
C Eval *In(50) = *Off
C Eval W@Rrn1 = *Zeros
**
** Set a looping condition. This condition may be based on anything.
** But in any case just ensure that RRN does not exceed 9999.
**
C DoW W@Rrn1 < 9999
**
** Increment the RRN to mark a new record of subfile. Remember that
** the variable corresponding to RRN should not be less than one (1) a
** nd it should never exceed 9999.
**
C Eval W@Rrn1 += 1
**
** Populate the fields defined in the subfiles. To load a blank subfil
** e we can just intialize the subfile fields.
**
C Eval = W@Rrn1
**
** Perform actual write to the subfile. Notice that each write actuall
** y adds a record to the subfile.
**
C Write LOADALLSF
C EndDo
**
C EndSr

NickLitten


IBM i Software Developer, Digital Dad, AS400 Anarchist, RPG Modernizer, Shameless Trekkie, Belligerent Nerd, Englishman Abroad and Passionate Eater of Cheese and Biscuits. Nick Litten Dot Com is a mixture of blog posts that can be sometimes serious, frequently playful and probably down-right pointless all in the space of a day. Enjoy your stay, feel free to comment and remember: If at first you don't succeed then skydiving probably isn't a hobby you should look into.

Nick Litten

related posts:

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}
__CONFIG_colors_palette__{"active_palette":0,"config":{"colors":{"cff50":{"name":"Main Accent","parent":-1},"a344d":{"name":"Accent Transparent","parent":"cff50"}},"gradients":[]},"palettes":[{"name":"Default","value":{"colors":{"cff50":{"val":"var(--tcb-skin-color-0)"},"a344d":{"val":"rgba(46, 138, 229, 0.85)","hsl_parent_dependency":{"h":210,"l":0.54,"s":0.78}}},"gradients":[]},"original":{"colors":{"cff50":{"val":"rgb(0, 178, 255)","hsl":{"h":198,"s":1,"l":0.5}},"a344d":{"val":"rgba(0, 178, 255, 0.85)","hsl_parent_dependency":{"h":198,"s":1,"l":0.5}}},"gradients":[]}}]}__CONFIG_colors_palette__

Get In Touch

I’m always looking for awesome input, feedback and critique!

>