|
View previous topic :: View next topic
|
| Author |
Message |
MainB
New User
Joined: 03 Nov 2005 Posts: 17
|
|
|
|
I need to replace a string of characters with another in a dataset. Want to do it using JCL.
The file has field separators that look like this --> "," <-- I want this string carrying dblqt comma dblqt to be replaced with just a single | (pipe) character. The rec length is 400 plus. The string appears after every field in the record as a separator.
I planned to use Fileaid but that can only handle 255 chars at a time. To overcome that OI can split the record into multiple statements. But then I may actually split it somewhere in between "," thereby not replacing it. |
|
| Back to top |
|
 |
Ramya A
Active User

Joined: 26 Jul 2004 Posts: 104
|
|
|
|
Did you try doing it with the SORT utility? Using the CHANGE and NOMATCH parameter of the OUTREC statement, you should be able to change one string to another provided you know the exact positions of the strings.
The CHANGE subparameter changes an input field to a replacement constant in the reformatted output record if the input field equals a search constant. The input field remains unchanged on the input side.
NOMATCH indicates how SyncSort should respond if the input field
does not match a search constant. If NOMATCH is not specified and no search constant matches the input field, sort processing will terminate with an error message.
Eg:
OUTREC FIELDS=(16,2,
CHANGE=(13,C'NJ',C'NEW JERSEY',
C'NY',C'NEW YORK',
C'PA',C'PENNSYLVANIA')
NOMATCH=(C'NOT SUPPORTED'))
For syntax and other options refer QW in your mainframes. |
|
| Back to top |
|
 |
MainB
New User
Joined: 03 Nov 2005 Posts: 17
|
|
|
|
| Actually this "," is a field terminator - so its position is not fixed - depending on length of the field it can be anywhere. It is a VB dataset. With fields like Name address etc - so based on size - the "," can be anywhere |
|
| Back to top |
|
 |
Kevin
Active User

Joined: 25 Aug 2005 Posts: 234
|
|
|
|
The data format seems like a good candidate for a SAS program or for your own in-house written program, or maybe an ISPF EDIT session run in batch mode.
What do you consider to be a valid programming language and/or utility when you say "using JCL"? |
|
| Back to top |
|
 |
MainB
New User
Joined: 03 Nov 2005 Posts: 17
|
|
|
|
Thanks for all your help - I did find a way to take care of this using fileaid in JCL. I wanted to avoid writing a SAS, COBOL, EASYTRIEVE etc...
Posting it here just in case someone needs it.
//STEP01 EXEC PGM=FILEAID
//SYSPRINT DD SYSOUT=*
//SYSLIST DD SYSOUT=*
//DD01 DD DISP=SHR,DSN=A.B.C.D
//DD01O DD DSN=X.Y,Z,
// DISP=(NEW,CATLG,DELETE),
// UNIT=DISK,SPACE=(CYL,(800,800),RLSE)
//* (TO,LENGTH,FROM)
//SYSIN DD *
$$DD01 COPYALL EDIT=(1,5,X'7F',C''), <-- Replaces the first " with null
EDITALL=(6,0,X'7F6B7F',C'|'), <--Replaces "," with |
EDITALL=(400,0,X'7F',C''), <--Replaces last " with null
OUT=0
/*
x'7F' is hex for "
x'6B' is hex for ,
1,5 - means starting from 1 - next 5 bytes
6,0 - means starting from 1 upto end of record
400,0 - means starting from 400 upto end of record
I had a " in the begining and end of record and "," after every field. And had to remove the first and last double quotes and replace "," with |. |
|
| Back to top |
|
 |
mmwife
Super Moderator

Joined: 30 May 2003 Posts: 1592
|
|
|
|
Hi MainB,
Thanx for sharing the resolution of your prob w/us.
I just hope everyone out there follows your example and either provides feedback on a solution offered or shares their own solution w/the rest of us in the forum.
Thanx again, and |
|
| Back to top |
|
 |
Sagar_mainframe
New User

Joined: 07 Jun 2008 Posts: 34 Location: Harrisburg, Pennsylvania
|
|
|
|
| Is it possible without using 'FILEAID'? |
|
| Back to top |
|
 |
superk
Global Moderator

Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
|
|
| Have you looked into a solution using either SYNCSORT or DFSORT yet? |
|
| Back to top |
|
 |
Sagar_mainframe
New User

Joined: 07 Jun 2008 Posts: 34 Location: Harrisburg, Pennsylvania
|
|
|
|
Yes, but as my requirement is also similar to above one mentioned.
I want to replace special characters like ) ( . , / \ + * @ with the space for certain fields of the given record.
As the position of the special character is not fixed, we are not able to mention the position in OUTREC statement using JCL.
Finally I'm thinking to write a COBOL batch pgm using the INSPECT verb. |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
DFSORT now has a find and replace function (FINDREP). It's available with z/OS DFSORT V1R5 PTF UK90013 (July, 2008).
For the example in Mainb's post, we can use DFSORT control statements like this:
| Code: |
OPTION COPY
INREC FINDREP=(IN=C'","',OUT=C'|')
|
For the example in Sagar's post, we can use DFSORT control statements like this:
| Code: |
OPTION COPY
INREC FINDREP=(IN=(C')',C'(',C'.',C',',C'/',C'\',C'+',C'*',C'@'),
OUT=C' ')
|
For complete details on the new FINDREP function and the other new functions available with PTF UK90013, see:
Use [URL] BBCode for External Links |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|