IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Sorting a field based on another field


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Ganesh Kalam
Warnings : 1

New User


Joined: 11 Aug 2005
Posts: 45
Location: India

PostPosted: Fri Jun 15, 2007 3:29 am
Reply with quote

Hi friends,

I am facing a problem while sorting an input file. Can anyone please help.

My input file is like this

----+----1----
01|0000000006|
02|0000000006|
02|0000000006|
02|0000000006|
02|0000000006|
02|0000000006|
02|0000000006|
02|0000000006|
02|0000000006|
02|0000000006|
03|0000000006|
04|0000000006|
03|0000000006|
07|0000000006|
01|0000000005|
02|0000000005|
02|0000000005|
02|0000000005|
02|0000000005|
02|0000000005|
02|0000000005|
02|0000000005|
02|0000000005|
02|0000000005|
03|0000000005|
04|0000000005|
03|0000000005|
07|0000000005|

The number in the first two columns should be sorted with in the number present in the column (4-13)

It is very important that the number in the column (4 to 13) Should be in the same order as in the input file.

The output should be llike this

----+----1----
01|0000000006|
02|0000000006|
02|0000000006|
02|0000000006|
02|0000000006|
02|0000000006|
02|0000000006|
02|0000000006|
02|0000000006|
02|0000000006|
03|0000000006|
03|0000000006|
04|0000000006|
07|0000000006|
01|0000000005|
02|0000000005|
02|0000000005|
02|0000000005|
02|0000000005|
02|0000000005|
02|0000000005|
02|0000000005|
02|0000000005|
02|0000000005|
03|0000000005|
03|0000000005|
04|0000000005|
07|0000000005|


Thanks for your help in advance..
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Fri Jun 15, 2007 4:07 am
Reply with quote

Here's a DFSORT job that will do what you asked for. I assumed your input file has RECFM=FB and LRECL=80, but you can change the job appropriately for other attributes.

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file (FB/80)
//SORTOUT DD DSN=...  output file (FB/80)
//SYSIN    DD    *
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD,
                 97:SEQNUM,8,ZD,RESTART=(4,10))),
        IFTHEN=(WHEN=(97,8,ZD,EQ,+1),
                OVERLAY=(81:SEQNUM,8,ZD)),
        IFTHEN=(WHEN=NONE,
                OVERLAY=(89:SEQNUM,8,ZD,
                         81:81,8,ZD,SUB,89,8,ZD,M11,LENGTH=8))
  OPTION EQUALS
  SORT FIELDS=(81,8,ZD,A,1,2,ZD,A)
  OUTREC BUILD=(1,80)
/*
Back to top
View user's profile Send private message
Ganesh Kalam
Warnings : 1

New User


Joined: 11 Aug 2005
Posts: 45
Location: India

PostPosted: Fri Jun 15, 2007 10:12 am
Reply with quote

Excellent Frank..This is working as required. Thanks very much.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
This topic is locked: you cannot edit posts or make replies. Automation need help in sorting the data DFSORT/ICETOOL 38
No new posts Join 2 files according to one key field. JCL & VSAM 3
No new posts How to move the first field of each r... DFSORT/ICETOOL 5
No new posts To search DB2 table based on Conditio... DB2 1
Search our Forums:

Back to Top