Calling RPG program without Parameters

0 pts.
Tags:
Application development
AS/400
CLP
RPG
RPGLE
1) I have an RPG PGM 'A' which call's another RPG PGM 'B'. PGM 'B' accepts 3 parameters. But i need to call PGM 'B' without passing parameters. How to achieve this??? 2) I have an RPG PGM 'A' which call's another RPG PGM 'B'. PGM 'B' doesnot accept parameters. But i need to call PGM 'B' with passing 3 parameters. How to achieve this??? Thanks in Advance Rama Krishna
ASKED: April 24, 2007  4:48 AM
UPDATED: January 12, 2010  7:02 AM

Answer Wiki

Thanks. We'll let you know when a new response is added.

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:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following