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

Replacing character string in file through JCL


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

New User


Joined: 08 Apr 2022
Posts: 3
Location: India

PostPosted: Fri Apr 08, 2022 12:45 pm
Reply with quote

I need your help to find a solution to below through a JCL.

I have a file, in that I need to find 6 characters irrespective of the position and if found I need to replace those 6 plus next 9 characters. For example input file is something like below:

Code:
XXXXXXABCDEFGHIJKLMNO                          XXXXXX123456789
ABPOPCHGXXXXXXZYXWVUTSR123456   XXXXXX987654321ZZZZ   88888888

Here, I have find characters starting with 'XXXXXX' and if found replace those 15 characters with 000000000000000. As you can see the position of string 'XXXXXX' is not fixed. Thus my output file should be like:

Code:
000000000000000JKLMNO                          000000000000000
ABPOPCHG000000000000000123456   000000000000000ZZZZ   88888888


Can you please suggest if this can be done using some utilities rather than a COBOL program. Please help.
Back to top
View user's profile Send private message
Pete Wilson

Active Member


Joined: 31 Dec 2009
Posts: 541
Location: London

PostPosted: Fri Apr 08, 2022 4:32 pm
Reply with quote

What have you tried so far. You have various utilities available such as SORT or REXX that can probably do this.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 1614

PostPosted: Fri Apr 08, 2022 5:11 pm
Reply with quote

prat wrote:
I need your help to find a solution to below through a JCL.

I have a file, in that I need to find 6 characters irrespective of the position and if found I need to replace those 6 plus next 9 characters.


Can you please suggest if this can be done using some utilities rather than a COBOL program. Please help.


Neither JCL nor VSAM can do this.

You can try: REXX, SORT, FILEAID, other utilities, or write your own code in any language you are familiar with.

JCL or VSAM - no way.
Those two are the only tools not able to to this task. Everything else can be used! icon_lol.gif
There is a lot of choices for you to try! icon_exclaim.gif
Back to top
View user's profile Send private message
Joerg.Findeisen

Active Member


Joined: 15 Aug 2015
Posts: 905
Location: Bamberg, Germany

PostPosted: Fri Apr 08, 2022 7:01 pm
Reply with quote

If the DSN can be edited in 3.4, an ISPF Change will do what's requested.
Code:
C P'XXXXXX=========' '000000000000000' ALL
Back to top
View user's profile Send private message
prat

New User


Joined: 08 Apr 2022
Posts: 3
Location: India

PostPosted: Sun Apr 10, 2022 1:15 pm
Reply with quote

Thank you all for your inputs. Greatly appreciate it.

I am working on the REXX code which I am planning to invoke in batch through a JCL. However I am not sure if REXX can handle large files. Also can REXX work on tape files. (Sorry for stupid question - I have not worked on REXX much). I am anyway going to test with a large and a tape file but wanted some guidance from you experts.

If some one has any idea about achieving same using SORT, please do share the pointers. I am out of ideas because:

1. We have to check for only first 6 characters of the string and then replace 15 characters (6 matching + 9 subsequent characters).
2. The string can be at any position in the file record and a record may have multiple strings.

I thank you all again for taking out time to provide your expert opinion.

Regards.
Back to top
View user's profile Send private message
prino

Senior Member


Joined: 07 Feb 2009
Posts: 1285
Location: Vilnius, Lithuania

PostPosted: Sun Apr 10, 2022 2:41 pm
Reply with quote

Via USS:

Code:
"sed -i "s/XXXXXX[.]\{9\}/000000000000000/g"


Where you have to sort out the correct use of quotes yourself.
Back to top
View user's profile Send private message
Willy Jensen

Active Member


Joined: 01 Sep 2015
Posts: 628
Location: Denmark

PostPosted: Sun Apr 10, 2022 5:40 pm
Reply with quote

REXX can handle datasets of any size, just don't do EXECIO * DISKR for larger dataset.
You can read one record at a time using EXECIO 1 DISKR, or a number of records at a time, like:
Code:
 do forever                               
   "Execio 1000 diskr -infile- (stem in.)"
   if in.0=0 then leave                   
   do ini=1 to in.0                       
     -                                     
   end                                     
 end                                       
 "Execio 0 diskr -infile- (finis)"         

Some find that the latter approach isn't (much) faster than reading one record at a time.
But SORT will be much faster.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 1614

PostPosted: Sun Apr 10, 2022 5:53 pm
Reply with quote

prat wrote:
Thank you all for your inputs. Greatly appreciate it.

I am working on the REXX code which I am planning to invoke in batch through a JCL. However I am not sure if REXX can handle large files. Also can REXX work on tape files. (Sorry for stupid question - I have not worked on REXX much). I am anyway going to test with a large and a tape file but wanted some guidance from you experts.

If some one has any idea about achieving same using SORT, please do share the pointers.

1. I have to repeat once again: this cannot be done by JCL. (Though JCL can be used to run any other tool of your choice)

2. REXX can handle datasets of any size, unless you try reading the whole data at once into memory (such as “EXECIO * DISKR”). Tape datasets can be handled, too.

3. Using REXX to handle huge amount of data can be very ineffective.

4. There is no problem in using SORT utility for this task. It is usually the fastest way to handle huge datasets. Please, try to do something yourself; when you are facing problems then forum members would help you. But please, don’t ask people to do the whole your own job for you.

5. There is no such thing as “file” in zOS. In some tools (COBOL, SORT, …) “file” can be used in place of “DDNAME”

6. From your explanation it is not clear what to do with your data? How is it possible to handle “the first six characters” which “can be located at any position of the record”???
Back to top
View user's profile Send private message
prat

New User


Joined: 08 Apr 2022
Posts: 3
Location: India

PostPosted: Sun Apr 10, 2022 7:33 pm
Reply with quote

Joerg.Findeisen wrote:
If the DSN can be edited in 3.4, an ISPF Change will do what's requested.
Code:
C P'XXXXXX=========' '000000000000000' ALL



This is exactly what I am trying to achieve. Can we do something like this using SORT ?
Back to top
View user's profile Send private message
Joerg.Findeisen

Active Member


Joined: 15 Aug 2015
Posts: 905
Location: Bamberg, Germany

PostPosted: Mon Apr 11, 2022 10:02 am
Reply with quote

prat wrote:
This is exactly what I am trying to achieve. Can we do something like this using SORT ?

Yes, you can - pretty simple. Look up FINDREP with parameter SHIFT=NO. Let us know the results you have achieved.
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 Selecting the max value from a file. DFSORT/ICETOOL 3
No new posts Panvalet - 9 Character name - Issue c... CA Products 6
No new posts Change history of vsam file. JCL & VSAM 3
No new posts Split large FB file based on Key coun... DFSORT/ICETOOL 4
No new posts EMPTY file check scenario JCL & VSAM 6
Search our Forums:

Back to Top