MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Retain only the first header

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
bade_miya
Beginner


Joined: 10 Dec 2003
Posts: 110
Topics: 38

PostPosted: Wed Jan 06, 2010 3:17 pm    Post subject: Retain only the first header Reply with quote

Hi All,

I hope you can help me with a challenge i am facing for creating a DFSORT sort card. I searched but did not find anything which is exactly matching my requirement.

I have multiple files merged into a single file. Each of these input files used for merging will have a header record and a number of detail records. So the final merged file will have multiple header records and detail records. There are no trailers. There is no way to identify a header record uniquely as it has got the run date and time and the program name which created the file (which can vary). My requirement is to select a particular kind of detail record plus only one header record at the top. For any merged output file there will be a header record at the top. I want to use this header.

Code:
Sample input merged file
=================

1201009 0600 ===> Header 1
DTL type 1
DTL type 1
DTL type 1
DTL type 1
DTL type 1
DTL type 1
DTL type 1
DTL type 2
DTL type 2
DTL type 2
DTL type 2
12020090700 ===> Header 2
DTL type 3
DTL type 3
DTL type 3
DTL type 3
DTL type 3
DTL type 4
DTL type 4
DTL type 4
DTL type 4
DTL type 4

Sample DFSORT output file required if i am selecting only detail record type 2
==============================================================================

1201009 0600 ===> Header 1
DTL type 2
DTL type 2
DTL type 2
DTL type 2



The challange i am facing is to only select the first header all the time because the date and time is not known beforehand.

Hope i have explained the issue in detail.

Thanks
bade_miya
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Wed Jan 06, 2010 4:08 pm    Post subject: Reply with quote

Quote:
There is no way to identify a header record uniquely as it has got the run date and time and the program name which created the file (which can vary).


If this was really true, there would be no way to do what you say you want, because there would be no way to distinguish a header record from a detail record so how could you select one or the other?.

But it appears from your example that the detail records start with 'DTL' and the header records don't. Assuming that's true, you could use a DFSORT job like the following to do what you want. I assumed your input file has RECFM=FB and LRECL=80, but the job can be changed for other attributes.

Code:

//S1    EXEC  PGM=SORT
//SYSOUT    DD  SYSOUT=*
//SORTIN DD *
1201009 0600 ===> Header 1
DTL type 1
DTL type 1
DTL type 1
DTL type 1
DTL type 1
DTL type 1
DTL type 1
DTL type 2
DTL type 2
DTL type 2
DTL type 2
12020090700 ===> Header 2
DTL type 3
DTL type 3
DTL type 3
DTL type 3
DTL type 3
DTL type 4
DTL type 4
DTL type 4
DTL type 4
DTL type 4
/*
//SORTOUT DD SYSOUT=*
//SYSIN    DD    *
  OPTION COPY
  INREC OVERLAY=(81:SEQNUM,8,ZD)     
  OUTFIL INCLUDE=(81,8,ZD,EQ,1,OR,
    (1,3,CH,EQ,C'DTL',AND,10,1,CH,EQ,C'2')),
    BUILD=(1,80)
/*

_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
bade_miya
Beginner


Joined: 10 Dec 2003
Posts: 110
Topics: 38

PostPosted: Wed Jan 06, 2010 8:31 pm    Post subject: Reply with quote

Worked like magic. I just modified the card to suit my requirement.

Before posting the question here I was also trying out a similar approach to include sequence number and select the one with value 1. But i did not use "outfil include". i just used "include cond" but due to some reason it did not work out (Does both these function differently?). Also, i am new to this trick of adding the sequence number AFTER the actual record length. Learned something new today. Thanks a ton Frank.
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Thu Jan 07, 2010 12:05 pm    Post subject: Reply with quote

Quote:
But i did not use "outfil include". i just used "include cond" but due to some reason it did not work out (Does both these function differently?).


The INCLUDE statement is processed before the INREC statement. The OUTFIL statement is processed after the INREC statement. So anything you do in an INREC statement is NOT seen by an INCLUDE statement, but is seen by an OUTFIL statement. See the following for a Figure that gives more details:

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/ICE1CA40/FIGSTMTSEQ?SHELF=&DT=20090527161936&CASE=&ScrollTOP=FIGSTMTSEQ#FIGSTMTSEQ
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
bade_miya
Beginner


Joined: 10 Dec 2003
Posts: 110
Topics: 38

PostPosted: Mon Jan 11, 2010 7:30 pm    Post subject: Thank You Reply with quote

Thanks for the explanation Frank. The figure really helped understand the flow.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group