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 records with in a group of records

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

New User


Joined: 14 Nov 2007
Posts: 36
Location: Chennai

PostPosted: Wed Mar 16, 2011 8:10 pm    Post subject: Sort records with in a group of records
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 Moderator


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

PostPosted: Thu Mar 17, 2011 10:32 pm    Post subject:
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: 36
Location: Chennai

PostPosted: Thu Mar 17, 2011 11:59 pm    Post subject:
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 Moderator


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

PostPosted: Fri Mar 18, 2011 1:36 am    Post subject:
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    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 Addition of two records on 2 fields amar143 SYNCSORT 8 Tue Oct 03, 2017 11:14 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
No new posts column with count of rows within dist... ronald wouterson DB2 4 Sun Sep 17, 2017 9:48 pm

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