Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Mass Replace in a file using JCL

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
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    Post subject: Mass Replace in a file using JCL
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    Post subject: Re: Mass Replace in a file using JCL
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    Post subject:
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    Post subject: Re: Mass Replace in a file using JCL
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    Post subject:
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    Post subject:
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    Post subject: w/o FILEAID
Reply with quote

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

Moderator Team Head


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

PostPosted: Thu Jul 10, 2008 1:39 am    Post subject: Reply to: Mass Replace in a file using JCL
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    Post subject: Thinking of INSPECT verb in COBOL
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 Moderator


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

PostPosted: Thu Sep 04, 2008 11:28 pm    Post subject:
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:

www.ibm.com/systems/support/storage/software/sort/mvs/ugpf/
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts SORTJOIN - Copy Matched and Unmatched... Steve Ironmonger DFSORT/ICETOOL 5 Tue Jan 17, 2017 4:26 pm
No new posts Copy RECFM =VB TO FB file with RECL =... sahil41352 DFSORT/ICETOOL 3 Wed Dec 28, 2016 11:29 pm
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us