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 file with a different value for a field

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

New User


Joined: 08 Oct 2007
Posts: 27
Location: Dallas, TX

PostPosted: Mon May 12, 2008 6:47 am    Post subject: Sorting a file with a different value for a field
Reply with quote

Hi,

I have a requirement to sort a file with a different value for a field. I am not sure of how to do it. Please help me.

Input File:
------------
Code:
0413....GNL......1.
0413....DDA......2.
0774....DDA......1.
0885....DDA......1.
0885....DDA......2;
0365....DDA......1;

I want to sort ths i/p file with the bytes (2-4) but I need to interpret the values of those fields with someother values and sort it. For example, a values in bytes 2-4 should be interpreted to the following:

Code:
413 - 280
774 - 280
885 - 096



So my i/p is sorted with interpreted values in the above table, but in the o/p my orginal values should come.

Output file:
-------------
Code:
0885....DDA......1.
0885....DDA......2;
0413....GNL......1.
0413....DDA......2.
0774....DDA......1.
0365....DDA......1;


Please someone help me doing this.
Code:
Back to top
View user's profile Send private message

gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1703
Location: Australia

PostPosted: Mon May 12, 2008 8:03 am    Post subject:
Reply with quote

Hi,
try this
Code:
//S1       EXEC  PGM=ICEMAN                                           
//SORTIN   DD *                                                       
0413....GNL......1.                                                   
0413....DDA......2.                                                   
0774....DDA......1.                                                   
0885....DDA......1.                                                   
0885....DDA......2;                                                   
0365....DDA......1;                                                   
/*                                                                     
//SORTOUT DD SYSOUT=*                                                 
//SYSOUT  DD SYSOUT=*                                                 
//SYSIN   DD *                                                         
      SORT FIELDS=(81,3,BI,A)                                         
  INREC  IFTHEN=(WHEN=(02,3,CH,EQ,C'413'),                             
      OVERLAY=(81:C'280')),                                           
         IFTHEN=(WHEN=(02,3,CH,EQ,C'774'),                             
      OVERLAY=(81:C'280')),                                           
         IFTHEN=(WHEN=(02,3,CH,EQ,C'885'),                             
      OVERLAY=(81:C'096')),                                           
         IFTHEN=(WHEN=(02,3,CH,EQ,C'365'),                             
      OVERLAY=(81:C'395'))                                             
      OUTREC BUILD=(1,80)                                             


Gerry
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: Mon May 12, 2008 8:57 pm    Post subject:
Reply with quote

bharath,

Gerry's "solution" works for the data given but will not work for other variations of the data because there's no IFTHEN NONE clause. For example, if the input included this record:

0285....NEW......1.

It would be sorted as the first record instead of after the "280" records.

Here's a DFSORT job that will work for all variations of the data:

Code:

//S1       EXEC  PGM=ICEMAN
//SYSOUT  DD SYSOUT=*
//SORTIN   DD *
0285....NEW......1.
0413....GNL......1.
0413....DDA......2.
0774....DDA......1.
0885....DDA......1.
0885....DDA......2;
0365....DDA......1;
/*
//SORTOUT DD SYSOUT=*
//SYSIN   DD *
  INREC IFTHEN=(WHEN=(2,3,SS,EQ,C'413,774'),
      OVERLAY=(81:C'280')),
    IFTHEN=(WHEN=(2,3,CH,EQ,C'885'),
      OVERLAY=(81:C'096')),
    IFTHEN=(WHEN=NONE,
      OVERLAY=(81:2,3))
    SORT FIELDS=(81,3,ZD,A)
    OPTION EQUALS
    OUTREC BUILD=(1,80)
/*
Back to top
View user's profile Send private message
pavans_here
Warnings : 1

New User


Joined: 12 Aug 2005
Posts: 3
Location: hyderabad

PostPosted: Thu May 15, 2008 5:04 pm    Post subject: Reply to: Sorting a file with a different value for a field
Reply with quote

Why did you choose 81 position to write to output file..
Is the requirement to write to 81 position.
Back to top
View user's profile Send private message
bharath_gct2002

New User


Joined: 08 Oct 2007
Posts: 27
Location: Dallas, TX

PostPosted: Thu May 15, 2008 5:57 pm    Post subject:
Reply with quote

Thanks Frank n Gerry. The solution worked just fine!!.

Pavan,

My requirement is to add it in the position 4001 of the file cos my input record length is 4000
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: Thu May 15, 2008 8:51 pm    Post subject:
Reply with quote

Quote:
Why did you choose 81 position to write to output file..


Since the OP didn't originally give the LRECL of the input file, I assumed for the example that it was LRECL=80. The job would need to be changed appropriately for a different LRECL.
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 SORTJOIN - Copy Matched and Unmatched... Steve Ironmonger DFSORT/ICETOOL 5 Tue Jan 17, 2017 4:26 pm
No new posts INVALID FIELD OR CONSTANT IN SORTOF ?? Ron Klop DFSORT/ICETOOL 8 Wed Jan 11, 2017 3:44 pm
No new posts Copy RECFM =VB TO FB file with RECL =... sahil41352 DFSORT/ICETOOL 3 Wed Dec 28, 2016 11:29 pm
No new posts Performing arithmetic on input field zh_lad DFSORT/ICETOOL 31 Tue Dec 06, 2016 8:04 pm
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm


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