Reading GDGs in Reverse Order

Question:I have a doubt in accessing GDG's and I thought I shall ask you. Actually we have a SYNCSORT step in which a GDG base is provided as sortin. Thus all generations of that base would be read by that step. The general rule is that the generations are read in the descending order (latest generation first and so on).

I need to read the generations in an ascending order which I don't know how to. Can you please suggest the means of doing it.

Following is the scenario in the code.

//SORTIN DD DSN=IDPOS03.MR0303.BK,DISP=SHR
 
translates as,
IDPOS03.MR0303.BK.G0006V00
IDPOS03.MR0303.BK.G0005V00
IDPOS03.MR0303.BK.G0004V00
IDPOS03.MR0303.BK.G0003V00
IDPOS03.MR0303.BK.G0002V00
IDPOS03.MR0303.BK.G0001V00

However, I require it to be read in the following order,
IDPOS03.MR0303.BK.G0001V00
IDPOS03.MR0303.BK.G0002V00
IDPOS03.MR0303.BK.G0003V00
IDPOS03.MR0303.BK.G0004V00
IDPOS03.MR0303.BK.G0005V00
IDPOS03.MR0303.BK.G0006V00

Is there a way to do this?
Arun

Answer:To the program a GDG looks just like one big file. The only way to feed the files in in reverse order is if you know how many files there are in the GDG and specify each of them individually (you can use relative generation numbers for this) eg. if there are always six files then refer to them as follows

//SORTIN    DD DSN=IDPOS03.MR0303.BK(0), DISP=SHR
//          DD DSN=IDPOS03.MR0303.BK(-1),DISP=SHR
//          DD DSN=IDPOS03.MR0303.BK(-2),DISP=SHR
//          DD DSN=IDPOS03.MR0303.BK(-3),DISP=SHR
//          DD DSN=IDPOS03.MR0303.BK(-4),DISP=SHR
//          DD DSN=IDPOS03.MR0303.BK(-5),DISP=SHR

Note that this will only work if there are exactly that many generations. Fewer generations will give an error, more generations will result in older generations being ignored.

 

This article written by Stephen Chapman, Felgall Pty Ltd.

go to top

FaceBook Follow
Twitter Follow
Donate