Adam,
In essence, if you can do subroutines, you can use procedures instead when working with subfiles. Prototypes, by the way, are, briefly, merely the list of parameters passed to-from the procedure.
For example, since I always use Load All subfiles, I can code the mainline (or controlling procedure):
DOW not eoj;
Start_Subfile(); // Clear the subfile
Build_List(); // Retrieve the information needed
Put_Subfile(); // Display the subfile
ENDDO;
[eoj, by the way, is a named indicator for F3.]
Now, based upon my understanding of your scenario, you might want to substitute the Build_List() with something like:
SELECT;
WHEN (condition 1);
Build_List_1();
WHEN (condition 2);
Build_List_2()
// etc.
ENDSL;
Each Build_List_x would control which logical to use and would, in turn invoke a separate procedure to load the data elements into the subfile record.
But you could, also, just have one Build_List procedure and within it control the setting and reading of the appropriate LF. This works for me when the LF's have the same field names (i.e., it's just the order that's different). If the field names are different, the multiple Build_List example would probably be the way to go.
In my dotage I'm finally getting to the point of using embedded SQL to select the records into a cursor and just fetch the records into each subfile record.
Jerry C. Adams
IBM System i Programmer/Analyst
B&W Wholesale
office: 615-995-7024
email: jerry@xxxxxxxxxxxxxxx
-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Adam West
Sent: Thursday, July 24, 2008 1:49 PM
To: rpg400-l@xxxxxxxxxxxx
Subject: Subfile as a procedure
HI I have to write a subfile display program that will be populated, depending on one of 4 params that are available to be entered on the initial first screen. Then the particular logical file has to be used. Since the subfile code should always be the same I would like to use the newer coding approach, I am unsure if one used Procedures, Prototypes, etc. and would appreciate any guidance as to the best approach.
--
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit:
http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at
http://archive.midrange.com/rpg400-l.
As an Amazon Associate we earn from qualifying purchases.