it was working fine.......
here i got another requirement on the same......ie i should not write header and trailer in the output file if it is not satishfying my condition in INCLUDE.....
but for the above card ..even when it is satisfying the condition also ...it 's writing HEADER AND TRAILER in the output file.....
can you please help on this..?
Joined: 29 Jun 2006 Posts: 1436 Location: Bangalore,India
How to recognize header and trailer records from other data in the file? Provide an example. Also, does the header and trailer are going to remain constant for every run?
hi ,
we dont have any header and trailer records in the inputfile.......
we are creating header and trailer in the outputfile....
please see this..Code:
SORT FIELDS=(1,2,CH,A,3,60,CH,A,63,3,CH,A),EQUALS
OUTFIL REMOVECC,FNAMES=PASRC,INCLUDE=(1,2,CH,EQ,C'PA'),
HEADER1=(1:C'PA',63:C'002',
67:DATE=(4MD-),C'-',TIME=(24.),
C'.000000'),
TRAILER1=(1:C'PA',63:C'001',236:COUNT=(M11,LENGTH=10))
in this when first 2 chars are not equal also....this card is writing HEADER AND TRAILER...CAN WE AVOID WRITING THESE WHEN CONDITION IS NOT SATISFIED?.
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
So you're saying if there are no included records, you don't want the header and trailer - you just want an empty file ... right? There's no way to tell DFSORT not to generate the Header and Trailer records for that case, but you can use this rather tricky DFSORT/ICETOOL job to get what you want:
Code:
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=... input file
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//T2 DD DSN=&&T2,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//CTL3CNTL DD DSN=&&C3,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//PASRC DD DSN=... output file
//TOOLIN DD *
* Create T1 data set with header and trailer and
* T2 data set with count of included records.
* If count of included records is 0, generate:
* OMIT COND=ALL
* to delete the header and trailer record -> empty output file.
* If count of included records is > 0, generate:
* INCLUDE COND=ALL
* to copy the header, detail and trailer records to output file.
SORT FROM(IN) USING(CTL1)
COPY FROM(T2) TO(CTL3CNTL) USING(CTL2)
COPY FROM(T1) TO(PASRC) USING(CTL3)
//CTL1CNTL DD *
SORT FIELDS=(1,2,CH,A,3,60,CH,A,63,3,CH,A),EQUALS
OUTFIL REMOVECC,FNAMES=T1,INCLUDE=(1,2,CH,EQ,C'PA'),
HEADER1=(1:C'PA',63:C'002',
67:DATE=(4MD-),C'-',TIME=(24.),
C'.000000'),
TRAILER1=(1:C'PA',63:C'001',236:COUNT=(M11,LENGTH=10))
OUTFIL REMOVECC,FNAMES=T2,NODETAIL,
TRAILER1=(COUNT=(M11,LENGTH=10))
/*
//CTL2CNTL DD *
INREC IFOUTLEN=80,
IFTHEN=(WHEN=(1,10,ZD,EQ,+0),
BUILD=(C' OMIT COND=ALL')),
IFTHEN=(WHEN=NONE,
BUILD=(C' INCLUDE COND=ALL'))
/*