Automatically Change Job Card Name To User ID?



JES, JES2, JCL utilities, IDCAMS, Compile & Run JCLs, PROCs etc...

Automatically Change Job Card Name To User ID?

Postby aqjentz » Fri Oct 07, 2016 4:13 am

Hello,

My team currently has various JCLs that we all share, but run individually as needed. With our shop's setup, the first characters of the job name must match our User ID or else we get the following error:

FIRST CHARACTERS OF JOBNAME NOT EQUAL TO USERID  - SUBMIT TERMINATED
***                                                                


So every time we want to run one of the shared JCLs, we have to edit the JCL and change the job name to match our User ID before submitting. For example, if I open a JCL and the last person to run the JCL was "JOEUSER," then the job card will look something like this:

//JOEUSERA  JOB (M9999),'TEST JCL',CLASS=U,MSGCLASS=Y,
//          NOTIFY=&SYSUID                                  


And if my user ID is "AQJENTZ" I have to change it to this before submitting the job:

//AQJENTZA  JOB (M9999),'TEST JCL',CLASS=U,MSGCLASS=Y,
//          NOTIFY=&SYSUID                                  


And this is the process anyone has to go through if they want to run the JCL. I've tried removing the job card altogether and trying to submit, but the system will ask:

ENTER JOBNAME CHARACTER(S) -


And then I'll enter a jobname character, but the JCL will JCLERROR out and never run successfully. I haven't been able to find any other possible solutions when searching online. I know we can successfully use "&SYSUID" for the NOTIFY portion of the job card and it will notify the current user correctly, but I haven't found anyway of doing anything similar with the job card name.

Is there anything we can do so that users don't have to change the job card name every time they submit the JCL? Or is this something we're stuck with? Any help or guidance on this would be much appreciated, thanks!
aqjentz
 
Posts: 4
Joined: Fri Oct 07, 2016 3:14 am
Has thanked: 4 times
Been thanked: 0 time

Re: Automatically Change Job Card Name To User ID?

Postby Aki88 » Fri Oct 07, 2016 10:28 am

Hello,

IMO, there may or may not be a clean solution to this, though a few pointers:

a. If you have a scheduler like TWS which you CAN USE to submit these jobs, use the JCLVARiable-table functionality of the same to substitute IDs in the job-name.
b. If you have z/OS 2.1 or higher, you can test using &SYSUID system symbol (again, you'll have to check if SYSSYM has been set to ALLOW prior this); this feature is turned off for me, so am unable to test it; though you can give it a shot if it is available.
c. Write a small REXX EXEC, which would override the JCL submit command for you. In the EXEC, first get the user id name, read your submitted JCL top down, substitute the user id name on the job card, use ISREDIT SUBMIT MACRO to submit the edited JCL.

These users thanked the author Aki88 for the post:
aqjentz (Thu Oct 13, 2016 12:12 am)
Aki88
 
Posts: 381
Joined: Tue Jan 28, 2014 1:52 pm
Has thanked: 33 times
Been thanked: 36 times

Re: Automatically Change Job Card Name To User ID?

Postby willy jensen » Fri Oct 07, 2016 2:32 pm

I would recommend Aki88's last option, 'c. Write a small REXX EXEC, ' as en edit macro.

These users thanked the author willy jensen for the post:
aqjentz (Thu Oct 13, 2016 12:12 am)
willy jensen
 
Posts: 455
Joined: Thu Mar 10, 2016 5:03 pm
Has thanked: 0 time
Been thanked: 69 times

Re: Automatically Change Job Card Name To User ID?

Postby Terry Heinze » Fri Oct 07, 2016 7:02 pm

I use the following edit macro to generate a Job statement for my JCLs. It could be modified to insert only the 1st line of your Job statement:
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************* Top of Data **********************************
/*                                                                    */
/*  JS       -  INSERT A JOB STATEMENT AT THE BEGINNING OF THE        */
/*              DATASET BEING EDITED.                                 */
/*                                                                    */
/*  AUTHOR   -  MAINFRAME JOURNAL                                     */
/*  CREATED  -  12/07/1989                                            */
/*  CHANGED  -  04/18/2016                                            */
/*                                                                    */
ISREDIT MACRO
SET ME = &NRSTR(&&&&SYSUID)
ISREDIT LINE_AFTER  0 = "//&SYSUID.XX JOB (AAB00,9250),+
                       'TERRY HEINZE -- xxxx',"
/* <-- CHANGE THIS PARM
ISREDIT LINE_AFTER  1 = "//             CLASS=B,"           /* JOB
ISREDIT LINE_AFTER  2 = "//             MSGCLASS=H,"        /* STATEMENT
ISREDIT LINE_AFTER  3 = "//*            RESTART=PROCNAME.SXX,"  /* AND
ISREDIT LINE_AFTER  4 = "//             NOTIFY=&ME"        /* PARAMETERS
ISREDIT LINE_AFTER  5 = "//*  I AM '&SYSUID..xxxx.JCL.PPXX(XXXXXXXX)'"
ISREDIT LINE_AFTER  6 = "//*"
ISREDIT LINE_AFTER  7 = "//*/*JOBPARM  SYSAFF=MNTA  <--- FOR ABEND-AID "
ISREDIT LINE_AFTER  8 = "//*/*JOBPARM  SYSAFF=MNTB  <--- FOR ABEND-AID "
ISREDIT LINE_AFTER  9 = "//*"
SET &ZEDSMSG = JOB STATEMENT INSERTED               /* FILL    SHORT MSG
SET &ZEDLMSG = A JOB STATEMENT HAS BEEN INSERTED AT THE BEGINNING +
               OF THIS DATASET                      /* FILL    LONG  MSG
ISPEXEC SETMSG MSG(ISRZ000)                         /* DISPLAY SHORT MSG
.... Terry

These users thanked the author Terry Heinze for the post:
aqjentz (Thu Oct 13, 2016 12:12 am)
Terry Heinze
 
Posts: 239
Joined: Wed Dec 04, 2013 11:08 pm
Location: Richfield, MN, USA
Has thanked: 12 times
Been thanked: 11 times

Re: Automatically Change Job Card Name To User ID?

Postby aqjentz » Fri Oct 07, 2016 11:21 pm

Thank you all for your suggestions and help! Aki88's last option C does look the most promising. I've run into some syntax issues when I copied Terry's code, but I'm honestly not too familiar with REXX Macros, so I'm trying to look up what I can on my end to fix them before I bug you guys with questions that will most likely be basic REXX Macro information.

Either way, I'll post back when I've got something working or if I really can't get past these issues.

Thanks again for all your help, this is definitely a promising lead!
aqjentz
 
Posts: 4
Joined: Fri Oct 07, 2016 3:14 am
Has thanked: 4 times
Been thanked: 0 time

Re: Automatically Change Job Card Name To User ID?

Postby aqjentz » Thu Oct 13, 2016 12:11 am

Okay, after some experimenting, I've got a macro that does what I'm looking for:

ADDRESS ISREDIT
        "MACRO"
        USERD = USERID()
        "ISREDIT(LINER) = LINE 1"
        "LINE 1 = ""//"||USERD||SUBSTR(LINER,LENGTH(USERD)+3,71)||""""
        "SUBMIT"


Since all of our JCLs begin on line 1 with the job card, I setup the macro to just change line 1 and replace the first characters after the "//" with my userid and it will leave everything else about line 1 in tact. Then it will submit the JCL. I've tested this with a couple different JCLs and as far as I can tell it's working as intended.

I do have some another question on something that I wasn't able to find any answers on: So far I've only been able to execute this macro while in EDIT mode. Everything I've seen states that ISREDIT can only be invoked while in EDIT mode, which is understandable. But my question is, is there anyway to get this macro to run from the 3.4 member list without opening the JCL? For example if I have a member list as shown below and I want to run macro "SUBM" (Submit Macro), I'd like to be able to enter "SUBM" on the line like so:

VIEW              AQJENTZ.JCL.CNTL          
Command ===>                                    
           Name     Prompt       Size   Created  
_________ TESTJCL1                 108  2016/01/27
_________ TESTJCL2 *Viewed        121  2011/11/29
_________ TESTJCL3                113  2011/11/29
_________ TESTJCL4                389  2011/11/29
_SUBM____ TESTJCL5     *Edited         25  2011/11/29
          **End**                                
 


When I do this, the macro gives RC(20) which I'm pretty sure is due to not being in EDIT mode on a dataset. However, if I used "SUB" like this, instead of "SUBM," the JCL job will be submitted and that's what I'm hoping to imitate, if possible. I'm imagining that the macro would have to identify the selected dataset, open that dataset in EDIT mode, and THEN run the macro that I have put together, but I'm not finding much information on how to do those first two steps. Is this possible?

I know that this is straying for the original JCL topic and is getting more into the territory of "CLIST & REXX," but I wasn't sure if I should create another topic over there for this question or continue in this post because it directly relates to my original topic. Feel free to let me know if I should post to "CLIST & REXX" instead and I will gladly do so. Thanks again everyone for your help! I certainly wouldn't have gotten this far without your guidance!

The rest of this is just some FYIs for anyone else who might be searching for the same information that I was:

  • I found different ways you can setup and run REXX macros from the EDIT screen on a dataset. The first one I found was a "no setup" way and it worked by just entering the following on the command line:

    TSO EXEC 'the-name-of-the-PDS(member-name)' EXEC


    This could potentially work for some people, I'm not certain, but for me, every line in my macro would RC(20) no matter what syntax I tried in the macro. I ended up going a different route that had some setup, but still has some drawbacks. Basically, setup a dataset that includes:

    /* REXX */
    "ALTLIB DEACTIVATE APPL(EXEC)"
    "ALTLIB ACTIVATE APPL(EXEC) DA('name-of-your-REXX-PDS')"


    Then on the command line run:

    TSO EXEC 'the-name-of-the-PDS(member-name)' EXEC


    Where the member name is the name of the setup dataset I outlined above. After that, you can just enter the name of the REXX macro on the command line to run it. For example, if I have macro "SUBM" in my 'name-of-your-REXX-PDS' then I just have to enter "SUBM" on the command line each time I want to run it. The drawbacks are that you have to do this setup every time you log in and for any split screens. This is a more ideal way to setup your REXX PDS by including it in your TSO Logon Procedure, but I haven't done that yet since I wanted to see if what I wanted to do was even possible before going through the steps to get that setup.

    I found this information here: http://theamericanprogrammer.com/programming/rexxsetp.shtml
  • If you are still having syntax issues with the code example that Terry provided, perhaps try the syntax I used. For example, Terry's would look like:

    ISREDIT MACRO
    ISREDIT LINE_AFTER  0 = "//AQJENTZX JOB (M9999),"


    The format that worked for me was:

    ADDRESS ISREDIT
            "MACRO"
            "LINE_AFTER  0 = ""//AQJENTZX JOB (M9999),"""


    I'm far from an expert on this, so I'm not sure why there has to be a difference between our syntaxes. Could just be how my shop is setup or it's possible that I wasn't setting up REXX properly to use Terry's syntax. All I know is that it ended up working for me :)
  • TRACE ?R
    is very helpful! Use it!

Those were the major hurdles I had when trying to trying to get the macros working. I know these are novice issues, but hopefully this will help save someone some time in the future!
aqjentz
 
Posts: 4
Joined: Fri Oct 07, 2016 3:14 am
Has thanked: 4 times
Been thanked: 0 time

Re: Automatically Change Job Card Name To User ID?

Postby willy jensen » Thu Oct 13, 2016 5:31 pm

Ok, one option is to write your program to handle both edit and non-edit environments. That way you can keep the heavy lifting in the edit section and still execute it from 3.4 or the command line, where it will call itself.
I quickly wrote the following REXX named ZSPCSUB and it works for me. Note that you need to CANCEL after the submit if the program was called from outside edit, otherwise you are stuck in the edited dataset/member.

 /* ZSPCSUB                              rexx */  
 Address Ispexec "control errors return"          
 Address Isredit "MACRO NOPROCESS(P)"              
                                                   
 /* in edit */                                    
 if rc=0 then do                                  
   Address Isredit                                
   "(s) = line 1"  /* save */                      
   j='//'userid()'A JOB (1),.....'                
   "line 1 = (j)"                                  
   "submit"                                        
   "line 1 = (s)"  /* restore */                  
   if translate(p)='CANCELAFTER' then "cancel"    
   exit 0                                          
 end                                              
                                                   
 /* not edit */                                    
 p='CANCELAFTER'                                  
 Address Ispexec,                                  
   "edit dataset("arg(1)") macro(ZSPCSUB) PARM(P)"
 exit 0                                            
 

These users thanked the author willy jensen for the post:
aqjentz (Thu Oct 13, 2016 11:45 pm)
willy jensen
 
Posts: 455
Joined: Thu Mar 10, 2016 5:03 pm
Has thanked: 0 time
Been thanked: 69 times

Re: Automatically Change Job Card Name To User ID?

Postby aqjentz » Thu Oct 13, 2016 11:55 pm

Thank you, WIlly, this works perfectly! I really like your idea of restoring Line 1 when the macro is finished. That way in case something goes wrong or someone runs this on a non-JCL or something, the changes won't be permanent. That'll save from some headaches in the future!

I tested in EDIT mode and outside and this works great. And FYI for anyone else trying to work with this, one of my other goals was to get this to work for JCLs that call other JCLs like:

//S10 EXEC PGM=IKJEFT1B              
//SYSPRINT DD SYSOUT=*              
//SYSTSPRT DD SYSOUT=*              
//SYSTSIN DD *                      
SUBMIT 'AQJENTZ.JCL.CNTL(TESTJCL4)'
/*                                  
//*                                  
 


and I was hoping to use the macro "SUBM" instead of "SUBMIT" and I was able to! You can't just simply change "SUBMIT" to "SUBM" though. What I found is if a REXX macro uses both TSO & ISPF commands, you need to setup your JCL with ISPF allocations for all ISPF services. Lookup BATCHPDF for a macro that will automatically lookup all of these libraries for you and creates the JCL for you.

Thanks again to everyone for their help, I really appreciate it!
aqjentz
 
Posts: 4
Joined: Fri Oct 07, 2016 3:14 am
Has thanked: 4 times
Been thanked: 0 time


Return to JCL

 


  • Related topics
    Replies
    Views
    Last post