Joined: 15 Dec 2002 Posts: 637 Topics: 43 Location: Bengaluru, INDIA
Posted: Fri Sep 12, 2003 7:26 am Post subject:
This solution must work.
The first step identifies the line numbers where the trailer records are. The second step uses the first line number and dynamically generates OUTFIL statements to split the input dataset. THe conditions are, those records that are less than the line number of the first trailer and, those that are greater.
Code:
//STEP EXEC PGM=ICETOOL
//TOOLIN DD *
COPY FROM(IN01) TO(T1) USING(CPY1)
COPY FROM(T1) USING(CPY2)
COPY FROM(IN01) USING(CPY3)
/*
//IN01 DD *
----+----1----+----2----+----3----+--
01 HEADER OF FIRST FILE
11 DETAIL OF FIRST FILE
11 DETAIL OF FIRST FILE
11 DETAIL OF FIRST FILE
11 DETAIL OF FIRST FILE
99 TRAILER OF FIRST FILE
01 HEADER OF SECOND FILE
11 DETAIL OF SECOND FILE
11 DETAIL OF SECOND FILE
11 DETAIL OF SECOND FILE
11 DETAIL OF SECOND FILE
99 TRAILER OF SECOND FILE
/*
//T1 DD DSN=&&TEMP0001,
// DISP=(,PASS)
//T2 DD DSN=&&TEMP0002,
// DISP=(,PASS)
//OT01 DD SYSOUT=*
//OT02 DD SYSOUT=*
//CPY1CNTL DD *
INREC FIELDS=(1,80,SEQNUM,8,ZD)
OUTFIL FNAMES=T1,
INCLUDE=(1,2,CH,EQ,C'99')
/*
//CPY2CNTL DD *
OUTFIL FNAMES=T2,
ENDREC=1,
OUTREC=(C' INREC FIELDS=(1,80,SEQNUM,8,ZD)',80:X,/,
C' OUTFIL FNAMES=OT01,',80:X,/,
C' INCLUDE=(81,8,ZD,LT,',81,8,C'),',80:X,/,
C' OUTREC=(1,80)',80:X,/,
C' OUTFIL FNAMES=OT02,',80:X,/,
C' INCLUDE=(81,8,ZD,GT,',81,8,C'),',80:X,/,
C' OUTREC=(1,80)',80:X)
---+----1----+----2----+-
01 HEADER OF FIRST FILE
11 DETAIL OF FIRST FILE
11 DETAIL OF FIRST FILE
11 DETAIL OF FIRST FILE
11 DETAIL OF FIRST FILE
OT02:
Code:
---+----1----+----2----+-
01 HEADER OF SECOND FILE
11 DETAIL OF SECOND FILE
11 DETAIL OF SECOND FILE
11 DETAIL OF SECOND FILE
11 DETAIL OF SECOND FILE
99 TRAILER OF SECOND FILE
_________________ ALL opinions are welcome.
Debugging tip:
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
-- Sherlock Holmes.
Joined: 15 Dec 2002 Posts: 637 Topics: 43 Location: Bengaluru, INDIA
Posted: Fri Sep 12, 2003 8:44 am Post subject:
Kolusu,
Don't you think, a OPTION EQUALS is needed so that the unique 99 that is used to decide the STARTREC and ENDREC is the first 99 record?
Also, looking at the sample output provided by Vijay, he does not need the trailer of the first file. So, maybe, your ENDREC should be less than 1.
Finally, his input is a concatenation of two datasets. Wonder what would happen if either of them is empty? This concern of mine is valid for any solution that one may post. _________________ ALL opinions are welcome.
Debugging tip:
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
-- Sherlock Holmes.
Joined: 15 Dec 2002 Posts: 637 Topics: 43 Location: Bengaluru, INDIA
Posted: Fri Sep 12, 2003 10:24 am Post subject:
Vijay,
In that case, my job needs to be changed as follows:
Code:
//CPY2CNTL DD *
OUTFIL FNAMES=T2,
ENDREC=1,
OUTREC=(C' INREC FIELDS=(1,80,SEQNUM,8,ZD)',80:X,/,
C' OUTFIL FNAMES=OT01,',80:X,/,
C' INCLUDE=(81,8,ZD,LE,',81,8,C'),',80:X,/,
C' OUTREC=(1,80)',80:X,/,
C' OUTFIL FNAMES=OT02,',80:X,/,
C' SAVE,',80:X,/,
C' OUTREC=(1,80)',80:X)
/*
_________________ ALL opinions are welcome.
Debugging tip:
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
-- Sherlock Holmes.
Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
Posted: Fri Sep 12, 2003 10:31 am Post subject:
coolman: I would be surprised if DFSORT allows DUPLICATE outfil names.
cogito: You are right about the OPTION EQUALS.I missed it. I am editing the post to reflect the change.I did not have the problem as my shop have OPTION EQUALS as default parameter.
Frank: can you clarify if DFSORT allows duplicate outfil names.
Let do some more hair-splitting. Will DFSORT always ignore the second OUTFIL? (It must, I guess. But, just curious... ) _________________ ALL opinions are welcome.
Debugging tip:
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
-- Sherlock Holmes.
Joined: 15 Dec 2002 Posts: 637 Topics: 43 Location: Bengaluru, INDIA
Posted: Fri Sep 12, 2003 10:58 am Post subject:
Kolusu,
From the manual,
Quote:
Duplicate Ddnames
If you specify a particular ddname (such as SORTIN) more than once within the
same step, DFSORT uses the first ddname and ignores subsequent duplicates.
Processing continues normally.
In addition, SORTIN0, SORTIN1...SORTIN9 can be specified instead of SORTIN00,
SORTIN01...SORTIN09, respectively. If you specify both SORTINn and SORTIN0n
in the same job step, DFSORT treats them as duplicates, and ignores each usage
after the first. For example, SORTIN2 and SORTIN02 are treated as duplicates and
only SORTIN2 is used.
Quote:
Duplicate OUTFIL ddnames are ignored at the OUTFIL statement level
More from the manual
Quote:
Multiple OUTFIL statements can be specified in the same and different sources.
If a ddname occurs more than once in the same source, the ddname is
associated with the first OUTFIL group in which it appears. For example, if the
following is specified in SYSIN:
OUTFIL FNAMES=(OUT1,OUT2),INCLUDE=(1,1,CH,EQ,C ’A ’)
OUTFIL FNAMES=(OUT3,OUT1),SAVE
OUT1 and OUT2 are processed as part of the first OUTFIL group, that is, with
INCLUDE. OUT3 is processed as part of the second OUTFIL group, that is, with
SAVE; but OUT1 is not because it is a duplicate ddname.
If a ddname occurs in more than one source, the ddname is associated with the
highest source OUTFIL group in which it appears. For example, if the following is
specified in DFSPARM:
OUTFIL FNAMES=(OUT1,OUT2),INCLUDE=(1,1,CH,EQ,C ’A ’)and the following is specified in SYSIN:
OUTFIL FNAMES=(OUT3,OUT1),SAVE
OUT1 and OUT2 are processed as part of the DFSPARM OUTFIL group, that is,
with INCLUDE. OUT3 is processed as part of the SYSIN OUTFIL group, that is,
with SAVE; but OUT1 is not because it is an overridden ddname.
However, your question still holds. A user would not know as to why the dataset is empty until he looks up his/her control statements. Again, I guess, the chances of coding duplicate DD names (Coolman's case is unique) will be few. So, DFSORT, I think, pardons such peccadilloes. _________________ ALL opinions are welcome.
Debugging tip:
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
-- Sherlock Holmes.
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