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: 10211
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: 10211
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 Removing Duplicates based on certain ... chandracdac DFSORT/ICETOOL 8 Fri Dec 09, 2016 4:40 am
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm
No new posts abend sort based on count records in ... anatol DFSORT/ICETOOL 5 Mon Oct 17, 2016 10:10 pm


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