Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Sort differently based on value in a particular column

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
Aneesh

New User


Joined: 30 Sep 2006
Posts: 60

PostPosted: Sat Nov 08, 2008 7:00 pm    Post subject: Sort differently based on value in a particular column
Reply with quote

Hi,

I have a file (FB LRECL 280) that has the following fields.
col1 8-12 (5 bytes numeric
col2 132-142 (11 bytes - S9(6).9(3) - positive, negative or zero)
col3 150-175 (26 bytes - timestamp)

The input record can have multiple records for same value of col1. There should be only 1 record in the output file for the same value of col1. For multiple records with same value of col1, there should be only 1 record in the output file, which should be selected as the record with the highest positive value of col2, or the record with the latest date in the col3 value if there is no record with positive value (>0) for col2. For eg:

Code:

Col1    Col2          Col3
12345   +000003.500   2008-10-26 -> record to o/p file
12345   +000001.200   2008-10-20
12345   -000003.500   2008-11-01
     
12346   +000000.000   2008-10-01
12346   -000003.500   2008-10-26 -> record to o/p file
12346   -000001.200   2008-10-20
       
12347   -000000.500   2008-10-10 -> record to o/p file


Is this something that can be easily done through sort?

Thanks,
Aneesh.
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: Sat Nov 08, 2008 10:09 pm    Post subject:
Reply with quote

Here's a DFSORT/ICETOOL job that will do what you asked for:

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//IN DD DSN=...  input file (FB/280)
//OUT DD DSN=...  output file (FB/280)
//TOOLIN DD *
SELECT FROM(IN) TO(OUT) ON(8,5,ZD) FIRST USING(CTL1)
/*
//CTL1CNTL DD *
  INREC IFTHEN=(WHEN=INIT,
          OVERLAY=(281:132,11,SFF,TO=ZD,LENGTH=9)),
        IFTHEN=(WHEN=(281,9,ZD,LE,0),
          OVERLAY=(281:-1,TO=ZD,LENGTH=9))
  SORT FIELDS=(8,5,ZD,A,281,9,ZD,D,150,26,CH,D)
  OUTFIL FNAMES=OUT,BUILD=(1,280)
/*
Back to top
View user's profile Send private message
Aneesh

New User


Joined: 30 Sep 2006
Posts: 60

PostPosted: Sun Nov 09, 2008 12:19 am    Post subject: Reply to: Sort differently based on value in a particular co
Reply with quote

Thank you, Frank.
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 records based on length exceeds ... maxsubrat DFSORT/ICETOOL 7 Wed Oct 04, 2017 4:48 pm
No new posts Execute JCL step based on the content... sprikitik JCL & VSAM 2 Tue Oct 03, 2017 10:03 am
No new posts How to insert a value on specific pos... Poha Eater DFSORT/ICETOOL 9 Sun Oct 01, 2017 3:04 am
No new posts JOINKEYS Paired and Unpaired Sort MFwhiz DFSORT/ICETOOL 4 Fri Sep 29, 2017 1:48 am
No new posts Difference in SORT & ICETOOL Mohan Kothakota DFSORT/ICETOOL 5 Fri Sep 22, 2017 4:56 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us