Search code examples
regexmainframezosjcl

What is a regular expression that satisfies all valid options for a JOB card in JCL?


I'm working on a program that will need to remove a JOB card from a JCL member. I'm having a lot of trouble building something that satisfies all possible options and configurations.

Below is a good guide on the JOB statement: http://www.tutorialspoint.com/jcl/jcl_job_statement.htm

Some issues though:

  1. There may be multiple job cards in a member
  2. There may be comments in the job card
  3. There may be characters in columns 73-80
  4. There may be a SYSAFF, SET or similar statement directly following the JOB statement that should be retained but may begin with slashes and spaces just like a job card

Any help would be appreciated. Currently I have the following regular expression:

//.*JOB.*\n(//\s{4,}[^\s]+(\s|\d)*\n)+

Ultimately I only need to change the JOB name to fit the restriction of the FTP JES reader which requires your job name to be the submitting USERID plus exactly one character under JESINTERFACELEVEL 1 which is used by our site. Changing only the job name would also be acceptable.


Solution

  • You will need to account for the two positional parameters -- 142 bytes of accounting information and 30ish bytes for programmers name. Also, you will have to account for the optional keyword parameters:

    ADDRSPC=   BYTES=     CARDS=      CLASS=      COND=    
    GROUP=     LINES=     MEMLIMIT=   MSGCLASS=   MSGLEVEL=
    NOTIFY=    PAGES=     PASSWORD=   PERFORM=    PRTY=    
    RD=        REGION=    RESTART=    SECLABEL=   SCHENV=  
    TIME=      TYPRUN=    USER=   
    

    Dealing with the JES commands like SYSAFF and other JCL commands like SET make it very complicated.

    You might want to approach it in steps -- regex to handle the "//" followed by up to 69 bytes and continued with a comma except in cases of comments where it starts with "//*".

    It might help to know what you are trying to accomplish. You can ask JES to process the JCL for you and there are ways you can inspect the parsed JCL via macros, exits and control blocks.