I wouldn't pass back the literals "Selected" or "Canceled" as the return value. Pass back an indicator. Then your code will be more streamlined.
Org_Selected = PromptWindowOrg(...);
If Org_Selected ;
//Do stuff
EndIf;
Brian May
Director
Pre-Sales and Customer Solutions
Profound Logic Software
http://www.profoundlogic.com
937-439-7925 Phone
877-224-7768 Toll Free
The IBM i Modernization Experts
www.profoundlogic.com
-----Original Message-----
From: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Dan
Sent: Friday, August 04, 2017 1:25 PM
To: RPG400-L@xxxxxxxxxxxx
Subject: Service program / procedure design and naming conventions
Having finally been given permission to design and implement a service program that will be placed into production and serve as a proof-of-concept for my colleagues who have no to little experience with developing service programs, I am striving to make this first one something that can be used as a reference for others.
In our shop, we make extensive use of F4=Prompt on certain input-capable fields to display a window subfile that allows the user to select from a list of valid records populated by a master file. Two "biggies" in our shop are Organization and Sub-Organization, aka Org and SubOrg. Currently, all of this logic is replicated in every program that uses it, one subroutine for each master file that we prompt for in any given program.
In every case, only one selection from the window subfile can be made.
Based on this, I am designing my prototype as follows:
1) The return value will be either 'Selected' or 'Canceled', based on whether the user made a selection from the window subfile.
2) If there are any key values needed to filter the subfile list, those are the first parameters. In my example, SubOrg requires the Org key value to filter the list. Org has no "higher level" key (my terminology sucks,
sorry) for which Org can be filtered.
3) The last parameter is the database record selected by the user.
d PromptWindowOrg...
d pi 10a
d SelectedRecord LikeRec( RstIndx02 )
d PromptWindowSubOrg...
d pi 10a
d OrgID 4a
d SelectedRecord LikeRec( SubOrgL2 )
Usage example:
If PromptWindowOrg( SelectedRecordOrg ) = 'Selected'; ... do stuff like set display's Org ID and name field values to that returned by procedure Endif;
If PromptWindowSubOrg( xx_OrgID : SelectedRecordSubOrg ) = 'Selected'; ... do stuff like set display's SubOrg ID and name field values to that returned by procedure Endif;
Suggestions / corrections / opinions are welcome. I'd also welcome any online resources. I'm still somewhat early in the design that I can change this as required / desired.
- Dan
--
This is the RPG programming on the IBM i (AS/400 and 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.
Please contact support@xxxxxxxxxxxx for any subscription related questions.
Help support midrange.com by shopping at amazon.com with our affiliate link:
http://amzn.to/2dEadiD
As an Amazon Associate we earn from qualifying purchases.