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

SORT file having multiple Headers


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

New User


Joined: 02 May 2006
Posts: 7
Location: Charlotte, NC, US

PostPosted: Wed Oct 18, 2006 12:04 am
Reply with quote

Hi,

I have a file having records distinguished by Record ID,
Record Id 010 - Header
020 - Sub Header
030/040/050/06 - Detail Record

My file has all the Detail records at top followed by the Subheader & Header can i have it so that the Header comes First followed by sub Header and all the corresoponding Detial records.
Is there any way i can do this using SORT.

Example of my input & Expected o/p file
Input ------ Output
030 AAAA ------ 010 XXXX
030 AAAA ------ 020 11111
040 BBBB ------ 030 AAAA
030 CCCC ------ 030 AAAA
040 DDDD ------ 040 BBBB
020 11111 ------ 030 CCCC
030 AAAA ------ 040 DDDD
040 BBBB ------ 020 22222
030 CCCC ------ 030 AAAA
040 DDDD ------ 040 BBBB
020 22222 ------ 030 CCCC
010 XXXX ------ 040 DDDD
030 SSSS ------ 010 YYYY
030 RRRR ------ 020 33333
020 33333 ------ 030 SSSS
010 YYYY ------ 030 RRRR
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: Wed Oct 18, 2006 1:33 am
Reply with quote

Your example doesn't make sense unless there's a missing 010 record after the first 020 record. I'm going to assume that's the case. If not, then you need to explain why the 010 record from the second input group appears in the first output group instead of in the second output group.

Here's a DFSORT job that will do what I think you asked for. I added the missing 010 record. I assumed your input file has RECFM=FB and LRECL=80, but the job can be changed appropriately for other attributes.

Code:

//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN   DD *
030 AAAA
030 AAAA
040 BBBB
030 CCCC
040 DDDD
020 11111
010 QQQQQ <---- ADDED
030 AAAA
040 BBBB
030 CCCC
040 DDDD
020 22222
010 XXXX
030 SSSS
030 RRRR
020 33333
010 YYYY
/*
//SORTOUT  DD SYSOUT=*
//SYSIN DD *
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(82:SEQNUM,8,ZD)),
        IFTHEN=(WHEN=(1,3,CH,EQ,C'010'),
                OVERLAY=(81:C'A',82:SEQNUM,8,ZD,START=0)),
        IFTHEN=(WHEN=(1,3,CH,NE,C'010'),
                OVERLAY=(81:C'C',90:SEQNUM,8,ZD,
                         82:82,8,ZD,SUB,90,8,ZD,M11,LENGTH=8),
                HIT=NEXT),
        IFTHEN=(WHEN=(1,3,CH,EQ,C'020'),
                OVERLAY=(81:C'B'))
  OPTION EQUALS
  SORT FIELDS=(82,8,ZD,A,81,1,CH,A)
  OUTREC BUILD=(1,80)
/*


SORTOUT would have:

Code:

010 QQQQQ <---- ADDED           
020 11111                       
030 AAAA                       
030 AAAA                       
040 BBBB                       
030 CCCC                       
040 DDDD                       
010 XXXX                       
020 22222                       
030 AAAA                       
040 BBBB                       
030 CCCC                       
040 DDDD                       
010 YYYY                       
020 33333                       
030 SSSS                       
030 RRRR                       
Back to top
View user's profile Send private message
rajanish

New User


Joined: 02 May 2006
Posts: 7
Location: Charlotte, NC, US

PostPosted: Wed Oct 18, 2006 8:21 am
Reply with quote

Hi Frank,
Actually Header can have multiple subheaders so it is not necessary that a 020 record should be followed by a 010 record.
However i got the Logic and i think i can work with it.

Thanks a lot
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: Wed Oct 18, 2006 8:44 pm
Reply with quote

Quote:
Actually Header can have multiple subheaders so it is not necessary that a 020 record should be followed by a 010 record.


Ok, but that doesn't explain why you show the 010 record from the second input group appearing in the first output group instead of in the second output group.

Quote:
However i got the Logic and i think i can work with it.


Good.
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 FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
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
Search our Forums:

Back to Top