View previous topic :: View next topic
Author
Message
ksk Active User Joined: 08 Jun 2006Posts: 355 Location: New York
Hi,
I have an input file with Account ID from 1st to 16th colomn. I want to add single quotes for each input record in 1st and 17th colomn.
Input file looks like below.
0000000000000001
0000000000000002
0000000000000003
Output should look like below:
' 0000000000000001'
' 0000000000000002'
' 0000000000000003'
We have DFSORT. Can we achieve this using DFSORT?
Record length of my Input and output files 23 and Record Format is FB.
Regards,
KSK
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
Here's a DFSORT job that will do what you asked for:
Code:
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file (FB/23)
//SORTOUT DD DSN=... output file (FB/23)
//SYSIN DD *
OPTION COPY
INREC BUILD=(C'''',1,16,C'''',23:X)
/*
If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:
Use [URL] BBCode for External Links
Back to top
ksk Active User Joined: 08 Jun 2006Posts: 355 Location: New York
Hi Frank,
Thanks very much for your solution. It is working fine.
I have one more requirement here. I also want to add ,(comma) after last quote of each record.
i.e. output should look like below.
'0000000000000001',
'0000000000000002',
'0000000000000003'
Please note that last record should not have comma but all other prior records should have.
I tried with the following sort card but it is giving comma for last record also.
INREC BUILD=(C'''',1,16,C'''',C',',23:X)
And my actual output records are showing like below.
'0010089589511343',
'0010089589511343',
'0010089589562369',
'0010089589562469',
Last highlited comma should not come in my output.
Please let me know the solution.
Regards,
KSK
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
Here's a DFSORT job for your new requirement:
Code:
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file (FB/23)
//SYM DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//SYSIN DD *
OPTION COPY
OUTFIL FNAMES=SYM,REMOVECC,NODETAIL,
BUILD=(80X),
TRAILER1=('LASTRCD,+',COUNT=(M11,LENGTH=8))
/*
//S2 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)
//SORTIN DD DSN=... input file (FB/23)
//SORTOUT DD DSN=... output file (FB/23)
//SYSIN DD *
OPTION COPY
INREC IFOUTLEN=23,
IFTHEN=(WHEN=INIT,
BUILD=(C'''',1,16,C''',',24:SEQNUM,8,ZD)),
IFTHEN=(WHEN=(24,8,ZD,EQ,LASTRCD),
OVERLAY=(19:X))
/*
Back to top
ksk Active User Joined: 08 Jun 2006Posts: 355 Location: New York
Thanks Frank. It worked fine.
Regards,
KSK
Back to top
Please enable JavaScript!