Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Sorting a field based on another field

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Sorting a field based on another field
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 Moderator


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

PostPosted: Fri Jun 15, 2007 4:07 am    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts SORT VSAM file with each field one by... maxsubrat DFSORT/ICETOOL 6 Tue Mar 14, 2017 1:07 pm
No new posts JCL to Set Return code based on DB2 S... vinu78 DB2 17 Mon Mar 13, 2017 9:47 pm
No new posts IMS DB-How to update a record (a sing... Nic Clouston IMS DB/DC 9 Thu Mar 09, 2017 4:38 pm
No new posts outrec field outside range Danielle.Filteau SYNCSORT 10 Sat Mar 04, 2017 2:37 am
No new posts Inserting records based on conditions vickey_dw DFSORT/ICETOOL 9 Wed Feb 22, 2017 1:33 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us