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 file having multiple Headers

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: SORT file having multiple Headers
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 Moderator


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

PostPosted: Wed Oct 18, 2006 1:33 am    Post subject:
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    Post subject: Thanks
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 Moderator


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

PostPosted: Wed Oct 18, 2006 8:44 pm    Post subject:
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    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 Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm
No new posts Adding big TEXT lines to each record ... bshkris SYNCSORT 4 Sat May 06, 2017 1:40 am
No new posts Unable to create multiple files using... mbattu COBOL Programming 3 Fri May 05, 2017 5:35 pm
No new posts Getting error while opening a variabl... apandey1 COBOL Programming 5 Fri May 05, 2017 12:22 pm


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