AS400 Parameters

5 pts.
Tags:
AS/400 Parameters
AS/400 programming
Do the number of parms passed from the called program have to match the number of parms defined in calling program.

Answer Wiki

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

Yes. They must be in the same order and same type. Though if it is truly not needed you can send blanks for alpha and zeros for numeric.

May I inquire as to why you are asking?

KSoniat

/////////////////////////////////////

No.

Any parameter accessed in the called program must be passed.
So if PgmA calles PgmB and passes 5 parameters/

PgmB can access anywhere from 0 to 5 parameters but if it tries to access a 6th parameter it will encounter a pointer error.

You are passing pointers to data, they don’t have to be used.

Type/length wise .. it’s good to keep the types length the same. Espcially if a receiving parameter is numeric.

The %PARMS function can be used in the called program to determine how many parameters were passed. Don’t try to access any more than were passed.

Phil

/////////////////////////////////////

Yes and No :) . If you are calling an OPM program then you must pass the number of parameters defined in the called program. If you are calling an ILE program then you can pass from 0 to N.

Bruce
/////////////////////////
Bruce

I think the ILE calling program must pass at least the number of parameters that are exercised in the called program. It’s rather that the called program can use from 0 to N (number passed). The %Parms function in the called program can be used to avoid exercising parameters that aren’t passed.

In the called program:
If %parms() > 6;
MyFld7 = Parm7;
Else;
MyFld7 = *blanks;
Endif

Phil

– – – – – – – – – – – – – – – – – – – – –

All is true !

but, it depends…..

Regardless of language or syntax, you must have consideration of what, precisely, needs to be accomplished, and what informatio needs to be provided to the called function. Plainly, there are situations where, if data is not given to it, there is no option but to fail / abend.
If there are three parameters, and you provide the first and third, without signifying the missing one, then again the program will behave erratically. If you provide the first two, and the third may be optional, then, as others have mentioned, you need only concern yourself with the content of the uninitialised field.

The techniques for coding for ‘optional’ parameters are well documented, and repeated here.

Remember the maxim . .
First, design your interfaces, then fill in the boxes.

Yorkshireman

////////////////////////////////////////////////

Phil,

Exercised yes, but the question was related to defined. An ILE called program can define any number of parameters, but the caller does not have to pass any. DSPPGM of an ILE program will show that the parameters can be in the range of 0 to 255. DSPPGM of an OPM program on the other hand shows the explicit number of parameters that must be passed.

Bruce

—————————–
Bruce

The original question, what a novel idea! Actually the question looks twisted! Parameters aren’t passed from the called program! Parameters are passed from the calling program and returned from the called program. But here is the kicker — why did we assume that the question was about RPG? How many languages run on the AS/400 that can pass parameters?

Interesting discussion however.
Phil

Discuss This Question: 5  Replies

 
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
  • WoodEngineer
    Both OPM and ILE RPG programs (and probably COBOL) allow you to pass less than the number of parms defined. I've done this many times in OPM-land, where I use a subfield in the program status data structure (SDS) to check the number of parms passed. Just be sure your program does not execute any code that references an un-passed parm. One technique that I like is to move the parms to work fields at the very beginning of the program. If a parm is not passed, just fill that parm's work field with blanks or zeros and you are good to go. For example, If %Parms >= 3 WorkField3 = parm3 <-- this line of code is only executes when three or more parms are passed, so you are safe. else Clear Workfield3 EndIf Same technique in OPM - just reference the subfield that contains the number of parms passed to the program. Works great.
    6,875 pointsBadges:
    report
  • WilsonAlano
    Hi, Just to confirm what WoodEngineer is saying here's a SDS example :
    D PGMDS          SDS                 
    D  PGMNAM           *PROC            
    D  NBRPAR           *PARMS           
    D  PGMSTS           *STATUS          
    D  SRCLIN                21     28   
    D  CPFCOD                40     46   
    D  CPFMSG                91    170   
    D  FILNAM               201    208   
    D  FILSTS               209    213  0
    D  JOBNAM               244    253   
    D  USERID               254    263   
    D  WUSRID               257    263   
    D  JOBNBR               264    269  0
    D  JOBNBR_ALFA          264    269   
    D  JOBDTE               276    281  0
    D  JOBTME               282    287  0
    Regards, Wilson
    2,600 pointsBadges:
    report
  • BigKat
    just an fyi, if you are coding RPG (not RPGLE) then in the SDS it is *PGM not *PROC D PGMDS SDS D PGMNAM *PGM
    8,350 pointsBadges:
    report
  • WilsonAlano
    Thanks BigKat, Here's the SDS for RPG IPGMDS SDS I *PROGRAM PGMNAM I *PARMS NBRPAR I *STATUS PGMSTS I 21 28 SRCLIN I 40 46 CPFCOD I 91 170 CPFMSG I 201 208 FILNAM I 209 2130FILSTS I 244 253 JOBNAM I 254 263 USERID I 257 263 WUSRID I 264 2690JOBNBR I 276 2810JOBDTE I 282 2870JOBTME Wilson
    2,600 pointsBadges:
    report
  • WilsonAlano
    Trying to use code
    I* Estructura de datos del Programa                   
    IPGMDS      SDS                                       
    I                                     *PROGRAM PGMNAM 
    I                                     *PARMS   NBRPAR 
    I                                     *STATUS  PGMSTS 
    I                                       21  28 SRCLIN 
    I                                       40  46 CPFCOD 
    I                                       91 170 CPFMSG 
    I                                      201 208 FILNAM 
    I                                      209 2130FILSTS 
    I                                      244 253 JOBNAM 
    I                                      254 263 USERID 
    I                                      257 263 WUSRID 
    I                                      264 2690JOBNBR 
    I                                      276 2810JOBDTE 
    I                                      282 2870JOBTME 
    2,600 pointsBadges:
    report

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