View previous topic :: View next topic |
Author |
Message |
sivafdms Intermediate
Joined: 29 May 2007 Posts: 165 Topics: 77
|
Posted: Wed Jan 21, 2009 8:44 am Post subject: How to copy records from backword using sort |
|
|
Hi All,
Please tell me how to copy records from backword using sort utility
Thanks
Siva |
|
Back to top |
|
 |
Frank Yaeger Sort Forum Moderator

Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
|
Posted: Wed Jan 21, 2009 11:05 am Post subject: |
|
|
Siva,
If you mean you want to copy the records in reverse order, you can use a DFSORT job like the following to do that. I assumed your input file has RECFM=FB and LRECL=80, but the job can be changed appropriately for other attributes.
Code: |
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD *
RECORD 01
RECORD 02
RECORD 03
RECORD 04
RECORD 05
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
INREC OVERLAY=(81:SEQNUM,8,ZD)
SORT FIELDS=(81,8,ZD,D)
OUTREC BUILD=(1,80)
/*
|
SORTOUT would have:
Code: |
RECORD 05
RECORD 04
RECORD 03
RECORD 02
RECORD 01
|
If that's not what you want, then please explain more clearly what you do want with an example of your input records and expected output records. _________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort |
|
Back to top |
|
 |
sivafdms Intermediate
Joined: 29 May 2007 Posts: 165 Topics: 77
|
Posted: Wed Jan 21, 2009 12:25 pm Post subject: |
|
|
Hi Frank,
The job worked perfectly fine. But i am not able to understand how it copies the data in reverse order.
Thanks,
Siva |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Wed Jan 21, 2009 1:13 pm Post subject: |
|
|
sivafdms wrote: | Hi Frank,
The job worked perfectly fine. But i am not able to understand how it copies the data in reverse order.
Thanks,
Siva |
It is quite simple siva. Using INREC statement we add a record number at the end of each record ie at pos 81 which looks like this
Code: |
---+----1----+----2----+----pos81-88
RECORD 01 00000001
RECORD 02 00000002
RECORD 03 00000003
RECORD 04 00000004
RECORD 05 00000005
|
Now we are sorting on the newly added record number field in DESCENDING order and using outrec we remove the newly added field which gives you the results backwards.
Hope this helps... _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
sivafdms Intermediate
Joined: 29 May 2007 Posts: 165 Topics: 77
|
Posted: Thu Jan 22, 2009 8:25 am Post subject: |
|
|
Thanks Frank and Kolusu |
|
Back to top |
|
 |
|
|