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

Combine header and detail records


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

New User


Joined: 30 Sep 2006
Posts: 60

PostPosted: Fri May 20, 2011 2:15 pm
Reply with quote

Hi,

I have an FB file of length 80. The file has a header, sub header and detail records structure. The fist character determines whether a record is a header, sub header or detail.

H Header line 1
S Sub header line 1
D Detail line 1
D Detail line 2
S Sub header line 2
D Detail line 1
D Detail line 2
D Detail line 3
H Header line 2
S Sub Header line 1
D Detail line 1

The requirement is to create a file having detail records with the preceding sub header and header records merged - a file of length 240.

H Header line 1 S Sub header line 1 D Detail line 1
H Header line 1 S Sub header line 1 D Detail line 2
H Header line 1 S Sub header line 2 D Detail line 1
H Header line 1 S Sub header line 2 D Detail line 2
H Header line 1 S Sub header line 2 D Detail line 3
H Header line 2 S Sub header line 1 D Detail line 1

This is a one time requirement and want to avoid writing a program if possible - Is this possible using sort?

Thanks,
Aneesh.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Fri May 20, 2011 2:54 pm
Reply with quote

a quick and dirty attempt
tested processing 20(twenty) bytes of data

Code:
****** ***************************** Top of Data ******************************
000001 //ENRICO1  JOB NOTIFY=&SYSUID,
000002 //             MSGLEVEL=(1,1),CLASS=A,MSGCLASS=H
000003 //*
000004 //S1      EXEC PGM=SORT
000005 //SYSPRINT  DD SYSOUT=*
000006 //SYSOUT    DD SYSOUT=*
000007 //SORTIN    DD *
000008 H HDR 1
000009 S SUB 1
000010 D DET 1 1
000011 H HDR 2
000012 S SUB 2
000013 D DET 2 1
000014 D DET 2 2
000015 H HDR 3
000016 S SUB 3
000017 D DET 3 1
000018 D DET 3 2
000019 D DET 3 3
000020 H HDR 4
000021 S SUB 4
000022 D DET 4 1
000023 D DET 4 2
000024 D DET 4 3
000025 D DET 4 4
000026 //SORTOUT   DD SYSOUT=*,
000027 //             DCB=(RECFM=FB,LRECL=80)
000028 //SYSIN     DD *
000029   SORT   FIELDS=COPY
000030   INREC  IFTHEN=(WHEN=GROUP,BEGIN=(1,1,CH,EQ,C'H'),PUSH=(081:1,20)),
000031          IFTHEN=(WHEN=GROUP,BEGIN=(1,1,CH,EQ,C'S'),PUSH=(101:1,20))
000032   OUTFIL BUILD=(081,20,101,20,1,20,20X),
000033          INCLUDE=(01,20,CH,NE,81,20,CH,AND,01,20,CH,NE,101,20,CH)
000034 //*
****** **************************** Bottom of Data ****************************

and the result is

Code:
H HDR 1             S SUB 1             D DET 1 1
H HDR 2             S SUB 2             D DET 2 1
H HDR 2             S SUB 2             D DET 2 2
H HDR 3             S SUB 3             D DET 3 1
H HDR 3             S SUB 3             D DET 3 2
H HDR 3             S SUB 3             D DET 3 3
H HDR 4             S SUB 4             D DET 4 1
H HDR 4             S SUB 4             D DET 4 2
H HDR 4             S SUB 4             D DET 4 3
H HDR 4             S SUB 4             D DET 4 4


for the full 80 bytes <thing>
the sort control cards should look like ( not tested )
and check the output dcb attributes

Code:
000028 //SYSIN     DD *
000029   SORT   FIELDS=COPY
000030   INREC  IFTHEN=(WHEN=GROUP,BEGIN=(1,1,CH,EQ,C'H'),PUSH=(081:1,80)),
000031          IFTHEN=(WHEN=GROUP,BEGIN=(1,1,CH,EQ,C'S'),PUSH=(161:1,80))
000032   OUTFIL BUILD=(081,80,161,80,1,80),
000033          INCLUDE=(01,80,CH,NE,081,80,CH,AND,01,80,CH,NE,161,80,CH)
000034 //*
Back to top
View user's profile Send private message
Aneesh

New User


Joined: 30 Sep 2006
Posts: 60

PostPosted: Fri May 20, 2011 5:24 pm
Reply with quote

That was great. Thanks a lot, Enrico icon_smile.gif
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Fri May 20, 2011 5:29 pm
Reply with quote

glad that it worked!
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 only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Join multiple records using splice DFSORT/ICETOOL 5
No new posts EZT program to build a flat file with... All Other Mainframe Topics 9
No new posts JCL sortcard to print only the records DFSORT/ICETOOL 11
Search our Forums:

Back to Top