IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Mass Replace in a file using JCL


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
MainB

New User


Joined: 03 Nov 2005
Posts: 17

PostPosted: Thu Nov 17, 2005 2:10 am
Reply with quote

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
View user's profile Send private message
Ramya A

Active User


Joined: 26 Jul 2004
Posts: 104

PostPosted: Thu Nov 17, 2005 3:12 am
Reply with quote

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
View user's profile Send private message
MainB

New User


Joined: 03 Nov 2005
Posts: 17

PostPosted: Thu Nov 17, 2005 3:15 am
Reply with quote

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
View user's profile Send private message
Kevin

Active User


Joined: 25 Aug 2005
Posts: 234

PostPosted: Thu Nov 17, 2005 6:01 am
Reply with quote

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
View user's profile Send private message
MainB

New User


Joined: 03 Nov 2005
Posts: 17

PostPosted: Thu Nov 17, 2005 9:19 pm
Reply with quote

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
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sat Nov 19, 2005 5:36 am
Reply with quote

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
View user's profile Send private message
Sagar_mainframe

New User


Joined: 07 Jun 2008
Posts: 34
Location: Harrisburg, Pennsylvania

PostPosted: Thu Jul 10, 2008 1:15 am
Reply with quote

Is it possible without using 'FILEAID'?
Back to top
View user's profile Send private message
superk

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Thu Jul 10, 2008 1:39 am
Reply with quote

Have you looked into a solution using either SYNCSORT or DFSORT yet?
Back to top
View user's profile Send private message
Sagar_mainframe

New User


Joined: 07 Jun 2008
Posts: 34
Location: Harrisburg, Pennsylvania

PostPosted: Thu Jul 10, 2008 1:46 am
Reply with quote

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
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Thu Sep 04, 2008 11:28 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
Search our Forums:

Back to Top