|
View previous topic :: View next topic
|
| Author |
Message |
venkata.ravi
New User
Joined: 09 May 2005 Posts: 30 Location: Hyderabad
|
|
|
|
Hi All,
I have a following sort card to arrannge the data in an ascending order. The below SORT card will fulfil the purpose. Read further to know the actual requirment out of this SORT card.
SORT FIELDS=(1,8,CH,A, <<== DATE filed
9,20,CH,A, <<== Read the Requirement below
29,20,CH,A, <<== Column 3
49,10,CH,A, <<== Column 4
59,10,CH,A) <<== Column 5
Requirement:
First 8 characters is DATE, Let it as it is in the Ascending order.
Second filed is Location, Out of different possible values for the Location, I want to define my own order such as IJK, ABC, PQR and DEF etc. These 4 locations should be in the top order (After DATE) and if still any other locations occur in the file, then they should follow the first 4 user defined locations in the ascending order. Rest of the fileds (Column 3, Column 4, Column 5) will be in the same ascending order as shown in the above sort card. |
|
| Back to top |
|
 |
rakesha.hg
Active User

Joined: 21 Mar 2008 Posts: 161 Location: bangalore
|
|
|
|
hi Venkata,
Okay, this would work much faster, if you give some sample input records and the sample output records with the record lengths, key field postions and the rules for sorting. |
|
| Back to top |
|
 |
venkata.ravi
New User
Joined: 09 May 2005 Posts: 30 Location: Hyderabad
|
|
|
|
Rakesha.hg,
As suggested, Here are the additiaonal details.
Note: **** represents column 3, column 4 and Column 5. As they don't need any changes, I didn't include them in the example. Also lenth of the file would be 176 bytes
Input file looks like
| Code: |
20122811ABC **********
20122811ABC **********
20122911ABC **********
20122811PQR **********
20122811ABC **********
20122911ABC **********
20122811DEF **********
20122911PQR **********
20122911IJK ********** |
Output for the above SORT card
| Code: |
20122811ABC **********
20122811ABC **********
20122811ABC **********
20122811DEF **********
20122811PQR **********
20122911ABC **********
20122911ABC **********
20122911IJK **********
20122911PQR ********** |
Desired Output
| Code: |
20122811ABC **********
20122811ABC **********
20122811ABC **********
20122811PQR **********
20122811DEF **********
20122911IJK **********
20122911ABC **********
20122911ABC **********
20122911PQR ********** |
|
|
| Back to top |
|
 |
enrico-sorichetti
Superior Member

Joined: 14 Mar 2007 Posts: 10903 Location: italy
|
|
|
|
the code snippet
| Code: |
****** ***************************** Top of Data ******************************
000001 //ENRICO1 JOB NOTIFY=&SYSUID,
000002 // MSGLEVEL=(1,1),CLASS=A,MSGCLASS=H
000003 //*
000004 //S1 EXEC PGM=SORT
000005 //SYSPRINT DD SYSOUT=*
000006 //SYSOUT DD SYSOUT=* IJK, ABC, PQR AND DEF
000007 //SORTIN DD *
000008 20122811AAA **********
000009 20122811AAB **********
000010 20122811IKJ **********
000011 20122811PQR **********
000012 20122811DEF **********
000013 20122811ABC **********
000014 20122711AAA **********
000015 20122711AAB **********
000016 20122711IKJ **********
000017 20122711PQR **********
000018 20122711DEF **********
000019 //SORTOUT DD SYSOUT=*
000020 //SYSIN DD *
000021 INREC IFTHEN=(WHEN=(9,3,CH,EQ,C'IKJ'),OVERLAY=(51:C'00001')),
000022 IFTHEN=(WHEN=(9,3,CH,EQ,C'ABC'),OVERLAY=(51:C'00002')),
000023 IFTHEN=(WHEN=(9,3,CH,EQ,C'PQR'),OVERLAY=(51:C'00003')),
000024 IFTHEN=(WHEN=(9,3,CH,EQ,C'DEF'),OVERLAY=(51:C'00004')),
000025 IFTHEN=(WHEN=NONE,OVERLAY=(51:C'99999'))
000026 SORT FIELDS=(1,4,CH,A,7,2,CH,A,5,2,CH,A,51,5,CH,A,9,3,CH,A)
000027 //*
****** **************************** Bottom of Data **************************** |
the result
| Code: |
********************************* TOP OF DATA **********************************
20122711IKJ ********** 00001
20122711PQR ********** 00003
20122711DEF ********** 00004
20122711AAA ********** 99999
20122711AAB ********** 99999
20122811IKJ ********** 00001
20122811ABC ********** 00002
20122811PQR ********** 00003
20122811DEF ********** 00004
20122811AAA ********** 99999
20122811AAB ********** 99999
******************************** BOTTOM OF DATA ******************************** |
change the offsets accordingly ...
the overlay should be 1 byte after the data ...
in Your case 177
and the sort card should be modified accordingly
remember to add a build to writ just the first 176 bytes |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|