View previous topic :: View next topic
|
Author |
Message |
prat
New User
Joined: 08 Apr 2022 Posts: 3 Location: India
|
|
|
|
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 |
|
|
Pete Wilson
Active Member
Joined: 31 Dec 2009 Posts: 585 Location: London
|
|
|
|
What have you tried so far. You have various utilities available such as SORT or REXX that can probably do this. |
|
Back to top |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2115 Location: USA
|
|
|
|
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!
There is a lot of choices for you to try! |
|
Back to top |
|
|
Joerg.Findeisen
Senior Member
Joined: 15 Aug 2015 Posts: 1305 Location: Bamberg, Germany
|
|
|
|
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 |
|
|
prat
New User
Joined: 08 Apr 2022 Posts: 3 Location: India
|
|
|
|
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 |
|
|
prino
Senior Member
Joined: 07 Feb 2009 Posts: 1310 Location: Vilnius, Lithuania
|
|
|
|
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 |
|
|
Willy Jensen
Active Member
Joined: 01 Sep 2015 Posts: 724 Location: Denmark
|
|
|
|
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 |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2115 Location: USA
|
|
|
|
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 |
|
|
prat
New User
Joined: 08 Apr 2022 Posts: 3 Location: India
|
|
|
|
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 |
|
|
Joerg.Findeisen
Senior Member
Joined: 15 Aug 2015 Posts: 1305 Location: Bamberg, Germany
|
|
|
|
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 |
|
|
|