Page 1 of 1

copy in reverse order

PostPosted: Sat Jul 10, 2010 12:15 am
by maxcc
Hi,

How can we copy records in a PS to a PDS in reverse order without using sort?

Re: copy in reverse order

PostPosted: Sat Jul 10, 2010 12:43 am
by dick scherrer
Hello,

What is the reason for such a requirement?

Re: copy in reverse order

PostPosted: Sat Jul 10, 2010 5:55 am
by MrSpock
I guess you'd have to load the data into a table, then write the data out from the table in reverse order.

Re: copy in reverse order

PostPosted: Sat Jul 10, 2010 6:24 am
by dick scherrer
Hello,

Or create a table that has record number as the key and retrieve the rows using an ORDER BY ... DESCENDING.

Or define a vsam esds file that uses max-record-number - record-number as the key. The records would be written in reverse order.

And others, but i still wonder why the requirement to accomplish this without using sort. . .

Re: copy in reverse order

PostPosted: Mon Jul 19, 2010 6:42 pm
by maxcc
Thanks for the replies.

It was an interview question. he said do it without using a key from a ps to pds.

not sure if reference modification option can work here.

Re: copy in reverse order

PostPosted: Mon Jul 19, 2010 7:30 pm
by Robert Sample
Reference modification would only work within a single record.

Unless you use SORT (either directly through JCL or via a program), in general this cannot be accomplished.

Re: copy in reverse order

PostPosted: Mon Jul 19, 2010 11:48 pm
by dick scherrer
Hello,

It was an interview question. he said do it without using a key from a ps to pds.
Sounds like there is/was some misunderstanding between the people in the room. . . PS and PDS datasets are not "keyed".

Maybe it is me that misunderstands. . .