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
 

 

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 How to change 'K' or 'M' use Sort vice_versa DFSORT/ICETOOL 5 Thu May 18, 2017 7:11 am
No new posts Check if any Detail records and extra... V S Amarendra Reddy SYNCSORT 19 Mon May 08, 2017 8:54 pm
No new posts find RACF group for access to spooled... jzhardy JCL & VSAM 1 Mon May 08, 2017 11:46 am
No new posts Adding big TEXT lines to each record ... bshkris SYNCSORT 4 Sat May 06, 2017 1:40 am
This topic is locked: you cannot edit posts or make replies. SORT trick needed bshkris SYNCSORT 6 Tue May 02, 2017 4:35 am


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