rpg
5 pts.
0
Q:
rpg
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.

ASKED: Nov 9 2009  6:55 AM GMT
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
0
6350 pts.
0
A:
 RATE THIS ANSWER
0
Click to Vote:
  •   0
  •  0
  • AddThis Social Bookmark Button
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
Last Answered: Nov 9 2009  4:44 PM GMT by CharlieBrowne   6350 pts.
0
0
Discuss This Answer:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

TomLiotta   7610 pts.  |   Nov 9 2009  7:48AM GMT

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

 

WoodEngineer   2240 pts.  |   Nov 10 2009  5:15PM GMT

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.

 

Cwc   3845 pts.  |   Nov 11 2009  2:38PM GMT

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.

 
0