On 5/16/2017 2:51 PM, Birgitta Hauser wrote:
1. Good Naming Conventions
2. Group the procedures according their functionality into Modules/Members
3. Include the member name in the procedure/function name e.g.
ItemNo_GetDescription, DateTime_CvtNumToDate etc.
These three are pretty easy to do in practise. Assume my example
ibeamWeight() sub-procedure is a new one undergoing development. Where
do all the pieces go, and what are they called? Again, I'm an RPG
programmer; COBOL will be similar.
QRPGLESRC member SHIPPING:
Holds all the sub-procedures related to shipping products,
including the new one, 'shipping_ibeamWeight()'
Also holds the test suite, 'shipping_t'
QPROTOSRC member SHIPPING:
Holds all the prototypes related to shipping products,
including the new one, 'shipping_ibeamWeight()'
QSRVSRC member SHIPPING:
Holds the binder language for the public/exported
sub-procedures, including the new one, 'shipping_ibeamWeight()'
To edit, fire up RDi on the above three source files / members.
To create the service program, CRTRPGMOD SHIPPING, then CRTSRVPGM (or
UPDSRVPGM) SHIPPING
To use, write a new program like PRINTBOL:
ctl-opt bnddir('PROCEDURES');
/copy qprotosrc,shipping
for i = 1 to numberOfItems;
weight += shipping_ibeamWeight(...);
endfor;
CRTBNDRPG PRINTBOL
The binding directory is used at compile time of the mainline programs.
On my system, I have one binding directory for all my service programs,
cleverly named PROCEDURES. What happens during the compilation is the
compiler notes that there are no procedure specs for ibeamWeight(), so
it goes looking through each of the exports in each of the service
programs in the binding directory. Here, it'll find that export in the
SHIPPING service program, and it'll bind that service program to this
mainline program.
You can see all the pieces/parts with
DSPSRVPGM
WRKBNDDIRE
DSPPGM
I seriously suggest that you give it a whirl. Everyone has a service
program called UTILITY or some such. Make a sub-procedure that returns
the absolute value of a number. Put all the pieces together, then write
a mainline program to try it out. Once that's working, make another
sub-procedure that returns the highest of two values. Write a second
program to try that out. This is one of those things that looks
grotesque when spelt out in detail, but it's really a lot easier to do
than to read about.
Again, apologies to the list for the RPG code; I don't know how to give
an example of ILE construction methods without a little bit of code, and
I'm afraid RPG is all I have :-/
As an Amazon Associate we earn from qualifying purchases.