View previous topic :: View next topic
Author
Message
jr3011 New User Joined: 17 Apr 2008Posts: 26 Location: Oviedo, FL
Is it possible to replace values within a field without looking at each character in the field. The commas or quotes can appear in any positon.
In my example i want to replace all commas and quotation marks with a question mark
Input file contains invoice-number (15 ch), description (23 Ch), and vendor-name (24 ch)
Input
invoice,"123456description,,"",1234567vendor"",name12345678901
Output
invoice??123456description?????1234567vendor???name12345678901
Back to top
dbzTHEdinosauer Global Moderator Joined: 20 Oct 2006Posts: 6966 Location: porcelain throne
Back to top
jr3011 New User Joined: 17 Apr 2008Posts: 26 Location: Oviedo, FL
Thanks Dinosauer,
The PTF (90013) is in the loop to be installed within the next couple of weeks. So, i guess i have to wait for that.
Thanks alot for your help.
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
Here are two ways to do what you want.
With FINDREP (PTF UK90013 required):
Code:
OPTION COPY
INREC FINDREP=(IN=(C',',C'"'),OUT=C'?')
Without FINDREP (PTF UK90013 not required):
Code:
OPTION COPY
ALTSEQ CODE=(6B6F,7F6F)
INREC OVERLAY=(1:1,62,TRAN=ALTSEQ)
Back to top
jr3011 New User Joined: 17 Apr 2008Posts: 26 Location: Oviedo, FL
Frank,
Thanks for the response. You guys are great. I tried using the ALTSEQ method and it worked with one exception. My record contains some packed decimal fields, so it converted the '7F's to '6F's. Is it possible to define the fields (positions) i want to convert, or do i need to wait for the PTF and use the FINDREP method ?
Thanks for your help.
John Hagan
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
Yes, you can specify the positions you want to convert with both FINDREP and TRAN=ALTSEQ. For example, if you wanted to convert only 11-20 and 31-40, you could use:
Code:
OPTION COPY
INREC IFTHEN=(WHEN=INIT,
FINDREP=(STARTPOS=11,ENDPOS=20,IN=(C',',C'"'),OUT=C'?')),
IFTHEN=(WHEN=INIT,
FINDREP=(STARTPOS=31,ENDPOS=40,IN=(C',',C'"'),OUT=C'?'))
or
Code:
OPTION COPY
ALTSEQ CODE=(6B6F,7F6F)
INREC OVERLAY=(11:11,10,TRAN=ALTSEQ,31:31,10,TRAN=ALTSEQ)
Back to top
Please enable JavaScript!