Hello
I am wondering if there is a way to pass parameters from a menu into a CLLE program, whereby the parameter list could be variable. Most Menu options will pass one parameter to the CLLE program; namely the program name that will be called if security is passed. (PARM 1)
But, there are some menu options that already have parms passed into the CLLE program. So, I will need to pass additional parameters to the program, in addition to the program name. (PARM 1).
Rather than clone the CLLE program into a program that has one parm for the program name, and then additiional variable names would need to be declared and set with certain default values, prior to calling the RPG ILE program, I am wondering if there is a way to do this without having to create an additional CLLE program.
Thanks for your assistance
-Nick
Software/Hardware used:
ASKED:
January 29, 2008 11:00 PM
UPDATED:
January 31, 2008 3:32 PM
Three alternative answers:
1) Go back to the System/36 days and use the local data area to pass parameters. They won’t mean anything to any program that doesn’t check for them.
2) Use a data area to pass parameters.
3) Use a data queue to pass the parameters.
For the answers I proposed, I am assuming that you are not using the native AS/400 menu format since it has almost no security. I write all of my menus in CL.
I have used Bruce Vining’s method before, in situations where a variable number of parameters must be passed.
It is worth pointing out that, although in Bruce’s example code the data parameter variables are length 1, the HLL programs that receive the parameters through the CALL operation can actually declare their parameters as whatever lengh and data type they like.
This is because the parameters are passed by address, and not by value. So you can call Bruce’s program like this:
CALL BRUCEPGM PARM(‘MYPGM’ ‘MYDATA’ 0000123′)
Bruce’s program will call MYPGM and pass the parameters ‘MYDATA’ and 0000123 BY ADDRESS. If you looked into Bruce’s program in debug, you would see the value ‘M’ in &P1 and hex 00 in &P2.
In the program MYPGM the parameter list would declare the first parameter as character length 6, and the second parameter as 7 digit packed decimal. Debugging MYPGM would show those parameters contain the correct values.
Of course, you have to be careful with this. If you declared the first parameter in MYPGM as character length 7, the value in it would (probably) be ‘MYDATA?’, where ? = hex 00 – it is actually seeing the first character of the next parameter value. So, padding of character values and correct lengths of numerics is required with this method.
So, using Bruce’s program, you can pass different types and lengths of parameter values whenever you call it, depending on which HLL program will be called by it.
John Blenkinsop
NSRI London