Hi Rama
For the first scenario, you can code PGM B to determine how many parameters have been passed and take action accordingly. If you are using RPG IV/ILE then you can use the %PARMS built-in function for this. An example of this technique can be found at:
http://www.astradyne-uk.com/code/index.php?id=1864c4c55f
If you are using RPG400 then in PGM B you can identify the number of parameters passed by checking the program status data structure (*PSDS) in positions 37-39. An RPG400 example using the PSDS can be found at:
http://www.astradyne-uk.com/code/index.php?id=7c3c52cf68
Moving on to the second scenario, I don’t think this can be done. As no parameters have been defined for the program then there will be no memory allocated when the program is called. You will need to modify PGM B in this case to accept three parameters and use the technique outlined above to determine whether they are used or not.
Hope it helps
Jonathan
===========================================================
First, it depends on whether or not you are coding the two programs or if PGM ‘B’ already exists.
If ‘B’ already exists and cannot handle the lack of passed parameters, there is no way to call it successfully without passing appropriate parameters — the program is going to throw an exception. Nor is there ever any reason to call ‘B’ without parameters — the question makes no sense in that case.
So, we must assume that you are creating both programs. For that case, Jonathan’s discussion is generally correct. You simply write PGM ‘B’ so that it avoids referencing parms beyond the number that were passed.
For the second question. there’s no problem passing extra parms. They will simply end up being ignored.
Tom
Discuss This Question: 2  Replies