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

Sort records with in a group of records


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Krishnadeva Reddy

New User


Joined: 14 Nov 2007
Posts: 37
Location: Chennai

PostPosted: Wed Mar 16, 2011 8:10 pm
Reply with quote

Hi,

Could anyone please help me out on sorting records with in a group as per the example shown below:

The below file contains diff types of records with more than one batch: A-Batch, Z-Trailer, and group of H,D,I is one record.I type record is not mandatory in each group.

Input RECL = 80
Input RECFM = FB

Input file:
Code:

A03162011BATCH00103152011                           
HN000294968250012XYZ   
DN0002949682500100010307201103072011       
HN000294968240012ABC   
DN0002949682400100010205201102052011       
DN0002949682400100020205201102052011       
IN0002949682400100030205201102052011       
HN000294968230012TMC   
DN0002949682300100010217201102172011       
DN0002949682300100020217201102172011       
HN000294968210012ABC   
DN0002949682100100010304201103042011       
HN000294968200012XYZ   
DN0002949682000100010308201103082011       
IN0002949682000100010308201103082011       
Z000000500000070000002000000000000077595
A03162011BATCH00203152011                           
HN000294968250012WIC   
DN0002949682500100010307201103072011       
HN000294968240012MDR   
DN0002949682400100010205201102052011       
DN0002949682400100030205201102052011       
HN000294968230012MDR   
DN0002949682300100010217201102172011       
IN0002949682300100020217201102172011         
Z000000300000040000001000000000000004590


I'm trying to sort records based on the code present in H type record.The position of the code is 18 with 3 bytes length.Could you please help me out to get the output as shown below: The group containing code ABC in type H record is shown on TOP in batch1 and group containing code MDR in type H record is shown on TOP in batch2.

Output file:
Code:

A03162011BATCH00103152011                           
HN000294968240012ABC   
DN0002949682400100010205201102052011       
DN0002949682400100020205201102052011       
IN0002949682400100030205201102052011       
HN000294968210012ABC   
DN0002949682100100010304201103042011       
HN000294968230012TMC   
DN0002949682300100010217201102172011       
DN0002949682300100020217201102172011 
HN000294968250012XYZ   
DN0002949682500100010307201103072011             
HN000294968200012XYZ   
DN0002949682000100010308201103082011       
IN0002949682000100010308201103082011       
Z000000500000070000002000000000000077595
A03162011BATCH00203152011                           
HN000294968240012MDR   
DN0002949682400100010205201102052011       
DN0002949682400100030205201102052011       
HN000294968230012MDR   
DN0002949682300100010217201102172011       
IN0002949682300100020217201102172011     
HN000294968250012WIC   
DN0002949682500100010307201103072011       
Z000000300000040000001000000000000004590
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 Mar 17, 2011 10:32 pm
Reply with quote

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

Code:

//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=...  input file (FB/80)
//SORTOUT DD DSN=...  output file (FB/80)
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,1,CH,EQ,C'A'),
    PUSH=(81:ID=8)),
   IFTHEN=(WHEN=GROUP,BEGIN=(1,1,CH,EQ,C'H'),
    PUSH=(89:1,1,90:18,3)),
   IFTHEN=(WHEN=(1,1,SS,EQ,C'AZ'),OVERLAY=(89:1,1))
  OPTION EQUALS
  SORT FIELDS=(81,8,CH,A,89,1,CH,A,90,3,CH,A)
  OUTREC BUILD=(1,80)
/*
Back to top
View user's profile Send private message
Krishnadeva Reddy

New User


Joined: 14 Nov 2007
Posts: 37
Location: Chennai

PostPosted: Thu Mar 17, 2011 11:59 pm
Reply with quote

Thanks Frank for providing the solution.

While I'm looking at output dataset, there is ZERO '0' written in the last byte of the output file.Any idea please why the last byte is written with '0'.

Other than this everything looks good as expected.
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 Mar 18, 2011 1:36 am
Reply with quote

I don't see 0 in the last byte when I run the job using your input example as shown. Something must be different on your end. If your input had '0' in the last byte, so would the output.
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 Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Compare only first records of the fil... SYNCSORT 7
Search our Forums:

Back to Top