Pregunta

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?

¿Fue útil?

Solución

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.

Otros consejos

Here are the possibilities that I have in my mind:

  1. You can write a simple COBOL program which would search for the required STRING and replace with whatever you want/need to add.
  2. You can also write a REXX EXEC to perform this, which may not need to parse the line of code that gets read. Simple IF condition would do, i suppose.

But here are some challenges you would have and of course are avoidable.

  1. What if some other parameters exist along with what you search for? like

    //STEP1 EXEC PGM=DUMY,PARAM=XPTO,PARM1='X'

  2. What if the search string is spanned across more than one line? like

    //STEP1 EXEC PGM=DUMY,

    // PARAM=XPTO

Here is a simple TSO/ISPF edit macro that will implement your example. Of course this is very crude but serves as an example of how JCL might be edited.

    ISREDIT MACRO ()                                                                
        CONTROL NOFLUSH NOPROMPT   LIST   CONLIST   SYMLIST   MSG               
        ISREDIT CHANGE ' PGM=DUMY' ' PGM=WORKS'                                 
        ISREDIT CHANGE 'XPTO'     'THAT'                                        
        ISREDIT (ROW1,COL1) = CURSOR                                            
        ISREDIT LINE_AFTER &ROW1 = "//SOMEDD DD DSN=DSN.WITH.SOMTHING,DISP=SHR" 
        SET &ROW1 = &ROW1 + 1                                                   
        ISREDIT LINE_AFTER &ROW1 = "//SYSTSIN DD *"                             
        SET &ROW1 = &ROW1 + 1                                                   
        ISREDIT LINE_AFTER &ROW1 = "SOME MORE PARAMETERS"                       
        EXIT CODE(0) 
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top