Program variable in RPG?

2,300 pts.
Tags:
AS/400
DSPF
RPG
Hi! Is it necessary to use a program variable or what is the use of program variable? For example I have a field name EMPNO in Physical File MASTER01. Program is getting the value for this field from Display file DSP01. Can I use the same name EMPNO in RPG and DSPF too? Surey.
ASKED: November 25, 2013  9:26 AM
UPDATED: November 27, 2013  3:14 PM

Answer Wiki

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

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
  • TomLiotta
    Yes. In general, you must use the same name. If you used a different name, there would be no way for your program to access the value from the DSPF. The name is what connects the value to both the program and the file. (There are advanced techniques that do not use the name, ut you're not likely ever to use them.) -- Tom
    125,585 pointsBadges:
    report
  • CharlieBrowne
    You can use different names, but then in your program you need to move the value to the other field. Sometimes there is an issue using the same name in both places. I usually use the PREFIX option on the F spec. Prefix(S_) for the DSPF and some other prefix for the DB files.
    39,815 pointsBadges:
    report
  • Sureyz
    Thanks Mr.Charlie,
    Me too got some error message while assigning the same field name in all places.
    This is the reason why this question has been raised.

    Surey. 
    2,300 pointsBadges:
    report
  • TomLiotta

    You can create a second variable with a different name and copy the value into the new variable as CharlieBrowne suggests.. But you can only use the original name to copy from. (Technically, you can RENAME the DSPF field; but then you'd simply be using the same field with a different name.)

    If you are getting an error, we need to know what the error is before we can say much about it. If you are trying to create a new variable and to give it the same name as a field in one of the files that your program is using, there will be a conflict. You can't use the same name for two different things. There's no way the compiler could tell which one you were referring to.

    Tom

    125,585 pointsBadges:
    report
  • philpl1jb

     error message was might be because

    the fields weren't structred the same

       or

    the fields didn't need to be defined in the program since the structure is available in the file and screen.

     

    48,575 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