I’m trying to perform a search-replace in several JCLs but I need multi-line capabilities, I need to replace a line for several.
Example:
//STEP1 EXEC PGM=DUMY,PARAM=XPTO
transform into
//STEP1 EXEC PGM=WORKS,PARAM=THAT
//SOMEDD DSN=DSN.WITH.SOMETHING
//SYSTIN
SOME MORE PARAMETERS
I looked into file-aid batch processing but it seems to only support STRING replacement without multi-line support.
I thing REXX might do it but I have no knowledge in it.
Any ideas?
There are commercial products that understand JCL syntax and can do this sort of thing. JOB/SCAN is one, I’m sure others in this product space can do it too.
Which is of no help if you don’t have such a product, so we’re back to your Rexx comment. Yes, you can do this with Rexx, but you’re going to be parsing JCL. This can be non-trivial depending on your requirements. Rexx doesn’t have regular expression matching, which is what one normally uses when parsing. It can be done, and if you aren’t seeking to do anything much more complicated that what you’ve indicated then it’s probably not too difficult for a Rexx programmer – perhaps this is an opportunity to become one. Rexx had, as one of its design goals, to make programming easier.
An alternative would be to use Perl, copying the PDS members to the Unix file system so you can process them, then copying them back when you’re done. Presuming you’re running a relatively current release of z/OS and your Systems Programmer(s) have installed the z/OS port of Perl, which is a no-cost item.
If you’re willing to copy the affected members to the Unix file system, you may be able to do this with awk. I’ve only dabbled with awk, but it has the advantage of just being there by default, no one would have to install anything (Perl) that isn’t already there by default.