View previous topic :: View next topic
Author
Message
technut New User Joined: 27 Dec 2007Posts: 73 Location: India
Hi,
I have a file with below three records...
'2008-07-22.00.37.44.297630'
'2008-07-22.00.37.44.297631'
'2008-08-05.00.40.02.167578'
I need to write a new file like below
'2008-07-22.00.37.44.297630',
'2008-07-22.00.37.44.297631',
'2008-08-05.00.40.02.167578'
Here, I want the COMMA to be inserted at the end of first two records only. The last record should be left as is.
Back to top
gcicchet Senior Member Joined: 28 Jul 2006Posts: 1702 Location: Australia
Hi,
here is one way of achieving it
Code:
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD *
'2008-07-22.00.37.44.297630'
'2008-07-22.00.37.44.297631'
'2008-08-05.00.40.02.167578'
//CTL2CNTL DD DSN=&&C1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
// DD *
OUTREC OVERLAY=(1,28,29:C',')
//OUT DD SYSOUT=*
//TOOLIN DD *
COPY FROM(IN) USING(CTL1)
COPY FROM(IN) TO(OUT) USING(CTL2)
COPY FROM(IN) TO(OUT) USING(CTL3)
/*
//CTL1CNTL DD *
OUTFIL FNAMES=CTL2CNTL,REMOVECC,NODETAIL,
BUILD=(80X),
TRAILER1=(' OPTION STOPAFT=',COUNT-1=(M11,LENGTH=8))
/*
//CTL3CNTL DD *
OPTION COPY
OUTFIL FNAMES=OUT,REMOVECC,NODETAIL,
TRAILER1=(1,80)
/*
Gerry
Back to top
technut New User Joined: 27 Dec 2007Posts: 73 Location: India
Thanks a lot for responding.. I tried your option and it yielded below output..
'2008-07-22.00.37.44.297630',
'2008-07-22.00.37.44.297631',
The last line was omitted as a whole.. I want the last record to be present in the output with no COMMAs at the end..!
I have never used ICETOOL before... It could be my unawareness!..
Back to top
Escapa Senior Member Joined: 16 Feb 2007Posts: 1399 Location: IL, USA
Here is icetool job for what you want to do
Code:
//STEP050 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD *
'2008-07-22.00.37.44.297630'
'2008-07-22.00.37.44.297631'
'2008-08-05.00.40.02.167578'
/*
//TMP1 DD DSN=&&TEMP1,DISP=(NEW,PASS),SPACE=(CYL,(1,10),RLSE)
//TMP2CNTL DD DSN=&&TEMP2,
// DISP=(NEW,PASS),SPACE=(CYL,(1,10),RLSE)
//OUT DD SYSOUT=*
//TOOLIN DD *
COPY FROM(IN) TO(TMP1) USING(CTL1)
COPY FROM(TMP1) TO(TMP2CNTL) USING(CTL2)
COPY FROM(TMP1) TO(OUT) USING(TMP2)
/*
//CTL1CNTL DD *
SORT FIELDS=COPY
INREC FIELDS=(1,28,29:C',',81:SEQNUM,8,ZD)
/*
//CTL2CNTL DD *
SORT FIELDS=COPY
OUTFIL FNAMES=TMP2CNTL,NODETAIL,REMOVECC,
HEADER2=(3:'OPTION COPY'),
TRAILER2=(2X,
3:'OUTREC IFTHEN=(WHEN=(81,8,ZD,EQ,',COUNT=(EDIT=(TTTTTTTT)),
'),',/,
3:'BUILD=(1,28,29:X)),',/,
3:'IFTHEN=(WHEN=NONE,BUILD=(1,29))')
/*
Output:
Code:
'2008-07-22.00.37.44.297630',
'2008-07-22.00.37.44.297631',
'2008-08-05.00.40.02.167578'
Back to top
technut New User Joined: 27 Dec 2007Posts: 73 Location: India
Thanks a lot..!!!!!!! It worked............
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
If you have z/OS DFSORT V1R5 PTF UK90013 (July, 2008) installed, you can do this quite easily like this:
Code:
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD *
'2008-07-22.00.37.44.297630'
'2008-07-22.00.37.44.297631'
'2008-08-05.00.40.02.167578'
/*
//OUT DD SYSOUT=*
//TOOLIN DD *
DATASORT FROM(IN) TO(OUT) LAST USING(CTL1)
/*
//CTL1CNTL DD *
INREC OVERLAY=(29:C',')
SORT FIELDS=(1,1,CH,A)
/*
Note that the INREC statement is applied to the data records, but NOT to the LAST record.
Back to top
gcicchet Senior Member Joined: 28 Jul 2006Posts: 1702 Location: Australia
Hi,
my cut and paste omitted the below code, the job should have failed with a cc of 12.
Code:
//CTL3CNTL DD *
OPTION COPY
OUTFIL FNAMES=OUT,REMOVECC,NODETAIL,
TRAILER1=(1,80)
/*
Gerry
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
I edited that into your job.
I suspect there are better ways to do this even without DATASORT, but since DFSORT/ICETOOL now has DATASORT, I won't bother to figure it out.
Back to top
Arun Raj Moderator Joined: 17 Oct 2006Posts: 2481 Location: @my desk
Frank,
How about this one. But I can't test this now
Code:
//STEP1 EXEC PGM=ICETOOL
//IN DD *
'2008-07-22.00.37.44.297630'
'2008-07-22.00.37.44.297631'
'2008-08-05.00.40.02.167578'
/*
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//T1 DD DSN=&&T1,DISP=(,PASS)
//OUT DD SYSOUT=*
//TOOLIN DD *
COPY FROM(IN) TO(T1) USING(CTL1)
SELECT FROM(T1) TO(OUT) ON(1,28,CH) LAST
/*
//CTL1CNTL DD *
INREC OVERLAY=(29:C',')
OUTFIL FNAMES=T1,REMOVECC,TRAILER1=(1,28)
/*
Back to top
gcicchet Senior Member Joined: 28 Jul 2006Posts: 1702 Location: Australia
Hi Arun,
as long as the input file does not contain duplicates else your code will drop duplicates, also using LAST may not preserve the output file in the same sequence.
Gerry
Back to top
Arun Raj Moderator Joined: 17 Oct 2006Posts: 2481 Location: @my desk
Hi all,
Here's an updated one which takes care of Gerry's considerations.
Code:
//STEP1 EXEC PGM=ICETOOL
//IN DD *
'2008-07-22.00.37.44.297630'
'2008-07-22.00.37.44.297631'
'2008-08-05.00.40.02.167578'
//*
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//T1 DD DSN=&&T1,DISP=(,PASS)
//OUT DD SYSOUT=*
//TOOLIN DD *
SORT FROM(IN) TO(T1) USING(CTL1)
SORT FROM(T1) TO(OUT) USING(CTL2)
//CTL1CNTL DD *
INREC OVERLAY=(29:C',',81:SEQNUM,4,ZD)
SORT FIELDS=(81,4,ZD,D)
//CTL2CNTL DD *
INREC IFTHEN=(WHEN=INIT,OVERLAY=(89:SEQNUM,4,ZD)),
IFTHEN=(WHEN=(89,4,ZD,EQ,1),OVERLAY=(29:C' '))
SORT FIELDS=(81,4,ZD,A)
OUTFIL FNAMES=OUT,BUILD=(1,80)
/*
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
Your first solution was actually better then this new one.
FWIW, here's another variation on that theme:
Code:
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file (FB/80)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//SYM DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//SYSIN DD *
OPTION COPY
OUTFIL FNAMES=T1,OVERLAY=(81:SEQNUM,8,ZD)
OUTFIL FNAMES=SYM,REMOVECC,NODETAIL,
BUILD=(80X),
TRAILER1=('LASTR,+',COUNT=(M11,LENGTH=8))
/*
//S2 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)
//SORTIN DD DSN=... input file (FB/80)
//SORTOUT DD DSN=... output file (FB/80)
//SYSIN DD *
OPTION COPY
INREC IFOUTLEN=80,
IFTHEN=(WHEN=(81,8,ZD,NE,LASTR),OVERLAY=(29:C','))
/*
Back to top
Arun Raj Moderator Joined: 17 Oct 2006Posts: 2481 Location: @my desk
Quote:
Your first solution was actually better then this new one.
I do agree that. But while posting that I assumed that there are no duplicates in the input and also that the records are in sorted order (which the OP has not mentioned) as pointed out by Gerry. Thanks for your point.
Back to top
Please enable JavaScript!