copy in reverse order



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

copy in reverse order

Postby maxcc » Sat Jul 10, 2010 12:15 am

Hi,

How can we copy records in a PS to a PDS in reverse order without using sort?
maxcc
 
Posts: 28
Joined: Fri Apr 30, 2010 12:50 pm
Has thanked: 0 time
Been thanked: 0 time

Re: copy in reverse order

Postby dick scherrer » Sat Jul 10, 2010 12:43 am

Hello,

What is the reason for such a requirement?
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: copy in reverse order

Postby MrSpock » Sat Jul 10, 2010 5:55 am

I guess you'd have to load the data into a table, then write the data out from the table in reverse order.
User avatar
MrSpock
Global moderator
 
Posts: 807
Joined: Wed Jun 06, 2007 9:37 pm
Location: Raleigh NC USA
Has thanked: 0 time
Been thanked: 4 times

Re: copy in reverse order

Postby dick scherrer » Sat Jul 10, 2010 6:24 am

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. . .
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: copy in reverse order

Postby maxcc » Mon Jul 19, 2010 6:42 pm

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.
maxcc
 
Posts: 28
Joined: Fri Apr 30, 2010 12:50 pm
Has thanked: 0 time
Been thanked: 0 time

Re: copy in reverse order

Postby Robert Sample » Mon Jul 19, 2010 7:30 pm

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.
Robert Sample
Global moderator
 
Posts: 3719
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: copy in reverse order

Postby dick scherrer » Mon Jul 19, 2010 11:48 pm

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. . .
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post