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

Sorting a file with a different value for a field


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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: 1702
Location: Australia

PostPosted: Mon May 12, 2008 8:03 am
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 Developer


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

PostPosted: Mon May 12, 2008 8:57 pm
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
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
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 Developer


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

PostPosted: Thu May 15, 2008 8:51 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
Search our Forums:

Back to Top