rpg

5 pts.
Tags:
COBOL
RPG
RPG Program
I have five indexed files in rpg prog. Can I decleared common key field parameters for all five files? Is it possible in cobol ? If not how will solve this querry in cobol ? Explain with an ex.

Answer Wiki

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

An index can contain multiple fields.
If you have 5 different index files then you can use the save KLIST if the following is true:
1. Determine how many of the key fields you want to use.
2. Is every file setup with those fields as the initial fields in the access path? They can have more fields AFTER those fields.
3. Do you want to use the same number of fields in the CHAIN command?
==
If any of the above is not true, you cannot do what you are asking.
So you need to set up other KLISTS. Here are some examples:
C Key#1 Klist
C Kfld SPASYS
C Kfld SPAPRN
C Kfld SPAAGT
C Kfld Acct1

C Key#2 Klist
C Kfld SPASYS
C Kfld SPAPRN
C Kfld SPAAGT

C Key#3 Klist
C Kfld SPASYS

Discuss This Question: 3  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
    It's not clear what you mean by "common key field parameters". Do you mean that you want to use the same program variables to access all five files? If so, then, yes, you can. Why not? If you mean that five files have different key structures and you want to access all five using a single key structure, then, no, you can't. It doesn't matter what language you use. You can't do it in any language. And an example won't be very useful if the question isn't clarified first. Also, an example will simply show five files being accessed with the same variables. It'll be the same as an example with five sets of variables except there will only be one set instead of five. Tom
    125,585 pointsBadges:
    report
  • WoodEngineer
    Mahesh11 - its generally a good practice to use different field names in your key list than the names of the field in the file being accessed. That way, there is no risk of a chain altering the contents of your key. It can save you from future headaches.
    6,765 pointsBadges:
    report
  • Cwc
    Regarding key lists, I hardly ever use them anymore, as they're not necessary and seem nearly obsolete in free format RPG. I'd rather have all the field names used for the key coded with the file operation itself, so that I don't have scan through the rest of the program to find what field names the key list consists of.
    4,290 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