View previous topic :: View next topic
|
Author |
Message |
gylbharat
Active Member
Joined: 31 Jul 2009 Posts: 565 Location: Bangalore
|
|
|
|
Add comma at end of all records except the last
A customer asked the following question:
From DFSORT Tricks - OCT 2011
Can DFSORT insert a comma at the end of all of the records except the last one? For example, say I have a
file with the following three records:
Code: |
'2008-07-22.00.37.44.297630'
'2008-07-22.00.37.44.297631'
'2008-08-05.00.40.02.167578' |
and I want to write an output file like this:
Code: |
'2008-07-22.00.37.44.297630',
'2008-07-22.00.37.44.297631',
'2008-08-05.00.40.02.167578' |
How can I do that?
You can use the DATASORT operator of DFSORT's ICETOOL to do this quite easily. Here's the job:
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)
/* |
Can the same be achieved using Syncsort? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
If you have the current release of Syncsort (1.4 or MFX), try it. . .
If there are questions/problems, post a reply including the informational messages generated by the run. |
|
Back to top |
|
|
gylbharat
Active Member
Joined: 31 Jul 2009 Posts: 565 Location: Bangalore
|
|
|
|
Hi Dick,
It is working fine on Syncsort. But I wanted to know how this can be achieved using SORT (Syncsort). Our shop doesn't use ICETOOL. |
|
Back to top |
|
|
Garry Carroll
Senior Member
Joined: 08 May 2006 Posts: 1202 Location: Dublin, Ireland
|
|
|
|
Quote: |
It is working fine on Syncsort. But I wanted to know how this can be achieved using SORT (Syncsort). |
huh??
Garry |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
"Can this ICETOOL code from the DFSORT tricks manual work on vanilla SyncSort (no "tool")?" |
|
Back to top |
|
|
xknight
Active User
Joined: 22 Jan 2008 Posts: 117 Location: Liberty city
|
|
|
|
Quote: |
It is working fine on Syncsort. But I wanted to know how this can be achieved using SORT (Syncsort). Our shop doesn't use ICETOOL |
FYI..
Yes, the job was submitted using the SYNCTOOL. As dick has mentioned version 1.4 & above supports the near DFSORT command, but not all.
In the spool, you can find the relative information on Utility used.
@Bill
Quote: |
"Can this ICETOOL code from the DFSORT tricks manual work on vanilla SyncSort (no "tool")?" |
needs to be coded, SYNCTOOL will be invoked , performs the operation. |
|
Back to top |
|
|
gylbharat
Active Member
Joined: 31 Jul 2009 Posts: 565 Location: Bangalore
|
|
|
|
I wanted to know, If this can be converted to PGM=SORT than PGM=ICETOOL.
As in our shop we use only SORT and No ICETOOL |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
And I was trying to state gylbharat's question as a clarification.
I'll try again. Remember, it is mostly out of interest only.
There is a task in the DFSORT Tricks manual which is performed with ICETOOL.
At a "shop" which has a ban on ICETOOL (may be an Alias)/SYNCTOOL can the same result be achieved just using the plain SORT (SyncSort).
PS. gylbharat, sorry for spelling your name wrong the other day. |
|
Back to top |
|
|
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
Hi,
if you want to use just SORT, this might help
Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
'2008-07-22.00.37.44.297630'
'2008-07-22.00.37.44.297631'
'2008-08-05.00.40.02.167578'
/*
//SORTOUT DD DSN=&&OUT,DISP=(,PASS),SPACE=(CYL,(10,10),RLSE)
//SYSIN DD *
SORT FIELDS=(81,8,BI,D)
INREC OVERLAY=(29:C',',81:SEQNUM,8,ZD)
/*
//STEP0200 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=&&OUT,DISP=(OLD,PASS)
//SORTOUT DD DSN=&&SEQ,DISP=(,PASS),SPACE=(TRK,(1))
//SYSIN DD *
SORT FIELDS=COPY,STOPAFT=1
OUTREC BUILD=(C' INREC IFTHEN=(WHEN=(81,08,ZD,EQ,+',
81,8,C'),',80:X)
/*
//STEP0300 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=&&OUT,DISP=SHR
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=(81,8,BI,A)
/*
// DD DSN=&&SEQ,DISP=SHR
// DD *
OVERLAY=(29:C' '))
OUTREC BUILD=(1,80)
/*
|
Gerry |
|
Back to top |
|
|
gylbharat
Active Member
Joined: 31 Jul 2009 Posts: 565 Location: Bangalore
|
|
|
|
Thanks Gerry... |
|
Back to top |
|
|
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
Hi,
another way of achieving it and it's simpler with no sorting required
Code: |
//STEP0001 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
'2008-07-22.00.37.44.297630'
'2008-07-22.00.37.44.297631'
'2008-08-05.00.40.02.167578'
/*
//SORTOUT DD DSN=&&S1,DISP=(,PASS),UNIT=SYSDA,SPACE=(TRK,(1,1))
//SYSIN DD *
SORT FIELDS=COPY
OUTFIL REMOVECC,NODETAIL,
TRAILER1=(C'SEQ#NUM,',X'7D',COUNT=(M11,LENGTH=8),X'7D',80:X)
/*
//STEP0002 EXEC PGM=SORT
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)
//SYMNOUT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SORTIN DD *
'2008-07-22.00.37.44.297630'
'2008-07-22.00.37.44.297631'
'2008-08-05.00.40.02.167578'
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INREC OVERLAY=(81:SEQNUM,8,ZD)
OUTREC IFOUTLEN=80,
IFTHEN=(WHEN=(81,08,CH,NE,SEQ#NUM),
OVERLAY=(29:C','))
/*
|
Gerry |
|
Back to top |
|
|
|
|