Can the parameter’s name in parameter list same with the field name in physical file?

105 pts.
Tags:
Parameter list -AS400
RPGLE
Can the parameter's name in parameter list same with the field name in physical file?
ASKED: October 7, 2008  6:37 AM
UPDATED: August 21, 2010  7:03 AM

Answer Wiki

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

Yes, apparently from this example.
Note I didn’t define Field1, its definition is from the file
Good practice, probably not.
<pre>
FMyFile if e k disk
C *entry plist
C parm Field1
C Field1 dsply
C eval *inlr = *on</pre>
Additional from Sloopy:

You should note that using the field name from the file means you are also using whatever value is in that field, after a record is retrieved. And, if you receive a value through that parameter, it will be changed if you then read a record from that file.

If you don’t want that, then use a new name (you can use a LIKE() define).

The usefulness of using the field name from the file is only that you don’t have to create a new field and move data to it when all you want is to pass the value from the record.

You can also use the field name as a KFLD name in a key list.

But, if you use the field name as a formal parameter name in a procedure definition, it will NOT be automatically filled with the value from the record. Procedure parameter names are, in essence, just placeholders against which you specify the attributes of a parameter. So, if you had a procedure defined like this:
<pre>
D CentreText PR 256 Varying
D FLD001 256
D p_Leader 6 Const Options(*NoPass)</pre>

- where FLD001 comes from a file – you must still state the length and other attributes of the field (or LIKE() define), and you would still have to explicitly state the field when you use the procedure:
<pre>
PrtEnd = CentreText( FLD001 ) ;</pre>

Regards,

Sloopy

==========================================================

The more complete answer is “Yes and no.”

It depends on whether the PARM is input to the program or is specified on a CALL to another program.

A file field can be used in a parameter list to call another program. That is, it can be used going out.

However, it can’t come into a program as a parm value and be a file field in that same program — that would require a single field name to refer to different memory locations at the same time with two different meanings. If fields could point to two different memory locations, programs would be useless. You could never be sure what values were anywhere.

Tom

Discuss This Question: 1  Reply

 
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
    Yes, it can be done. No, its not a good idea. The first read of the file containing the value passed in via the parameter will be overlaid.
    6,065 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