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
 

 

Combine header and detail records

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Combine header and detail records
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10256
Location: italy

PostPosted: Fri May 20, 2011 2:54 pm    Post subject: Reply to: Combine header and detail records
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    Post subject: Reply to: Combine header and detail records
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10256
Location: italy

PostPosted: Fri May 20, 2011 5:29 pm    Post subject: Reply to: Combine header and detail records
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    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 Check if any Detail records and extra... V S Amarendra Reddy SYNCSORT 19 Mon May 08, 2017 8:54 pm
No new posts Validating file with multiple header/... mohitsaini DFSORT/ICETOOL 6 Thu Apr 13, 2017 1:53 am
No new posts Join giving more records than expected Danielle.Filteau SYNCSORT 2 Thu Mar 09, 2017 3:28 am
No new posts TSO or command line utility to genera... kishpra JCL & VSAM 3 Thu Mar 09, 2017 1:11 am
No new posts Extract set of records matching on ac... bhaskar_kanteti DFSORT/ICETOOL 3 Mon Mar 06, 2017 7:19 am


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