With subfiles you can create a display file with lists of items. Let's see how that's done.
A subfile is a display file where you can place a listing of values and process changes on the list. The list of members that you can see in the PDM is an example of a subfile.
In this chapter we'll create a subfile which will show all the cards from a client given its ID. To make the manipulation of several tables easier, we'll create a view with the fields we'll use on the subfile. In STRSQL insert this code:
CREATE VIEW CLICARD AS SELECT CL.ID_CLI, CR.ID_CRD, SH.NAME_SHP, CR.SHOP_CRD FROM DEMO/CLIENTS CL, DEMO/SHOP SH, DEMO/CARDS CR WHERE CL.ID_CLI = CR.CLIENT_CRD AND CR.SHOP_CRD = SH.ID_SHP
Open SDA (STRSDA) and create a new member:
Create a BOTTOM record that should look like this:
And the TOP record like this:
Let's create the subfile now. Create a new record, name it LIST, the record type is SFL:
When you press Enter a new record appears. Write SFLCTL on it:
This field creates a subfile control record, which works like the heading on the list.
You have to activate some options now:
On the General Keywords menu insert the data you see below:
These indicators allow us to manipulate the status of the subfile from the RPG code. Press Enter to go back to the previous screen. Select Subfile display layout.
On subfile maximum size type 9999 and on the number of records for page type 9:
Press enter to go back. Select the option Select Record Keyword:
Choose Overlay keywords:
Select Overlay without erasing:
Press Enter until you're back on this screen:
Open the SFLCTL record. By default the record list is already visible on the design screen. Select to visualize the other 2 records, TOM and BOTTOM (F9).
Back to the design screen, write at the top “Client Nr.”. Select the fields from CLICARD view for input/output (F10) and select the ID_CLI field: