Passing parms from a command to a CL pgm to submit a job

35 pts.
Tags:
Passing parms
SBMJOB
I've created a menu for my staff in STRSDA on of the options is a command to prompt for variables to run a SBMJOB I need to put defined variable in such as object name, library, volser endopt..after supplying these variables from the prompt, I want to hit enter and have these passed along to the SBMJOB that I have in my cl program. My compile wotks for the CL program as well as the CMD but, I cannot pass the command variables to the source code. Can anyone help me and tell me what I may be missing?

Answer Wiki

Thanks. We'll let you know when a new response is added.

Can you provide the command defintion and the source for your CPP that is doing the SBMJOB? This will help in determining what might be going wrong.

Bruce Vining

Discuss This Question: 5  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Mikey57
    This is the code: PGM PARM(&OBJ &SAVLIB &VOL &ENDOPT &JOB) /* PGM WILL CALL IN VALUES TO SAVE OBJECTS ON MHS1 SOURCE THEN PASS THESE + VARIABLES TO SUBMUT A SAVE JOB */ /* CALL IN PROGRAM TO SUPPLY VARIABLES TO THE JOB */ /* CALL PGM(*CURLIB/RSTOBJTGT) */ /* DECLARE VARIABLES */ DCL (&OBJ) TYPE(*CHAR) LEN(10) DCL (&LIB) TYPE(*CHAR) LEN(12) DCL (&VOL) TYPE(*CHAR) LEN(6) DCL (&ENDOPT) TYPE(*CHAR) LEN(10) DCL (&JOB) TYPE(*CHAR) LEN(10) /* MONITOR FOR SYSTEM MESSAGES */ SBMJOB CMD(SAVOBJ OBJ(&OBJ) LIB(&LIB) + DEV(TAPMLB06) OBJTYPE(*FILE) VOL(&VOL) + ENDOPT(&ENDOPT) SAVACT(*LIB) + ACCPTH(*YES)) JOB(&JOB) SNDPGMMSG MSG('SAVE OBJECT COMPLETE FOR SOURCE SYSTEM') ENDPGM Here is the command, which I have added to a STRSDA menu to plug in the variables which I want to plug into my code from above. all my complies work fine so, I don't know where to go from here. I'm new to CL pgmmng Here is the command: CMD PARM KWD(OBJECT) TYPE(*CHAR) LEN(10) MIN(1) + MAX(4) CHOICE('OBJECT NAME') + PMTCTL(*NONE) PROMPT(OBJECT) PARM KWD(LIBRARY) TYPE(*CHAR) LEN(10) MIN(1) + MAX(4) CHOICE('LIBRARY NAME') + PROMPT('LIBRARY') PARM KWD(VOL) TYPE(*CHAR) LEN(6) MIN(1) + CHOICE(VOLSER) PROMPT('TAPE NUMBER') PARM KWD(ENDOPT) TYPE(*CHAR) LEN(10) MIN(1) + CHOICE('END OPTION') + PROMPT('ENDOPT(*LEAVE *UNLOAD *REWIND)') PARM KWD(JOB) TYPE(*CHAR) LEN(10) MIN(1) + CHOICE('JOB NAME') PROMPT('NAME OF JOB TO SUBMIT')
    35 pointsBadges:
    report
  • bvining
    There are a few problems. The major one being that you have your command defining OBJECT and LIBRARY as a list of 1 to 4 names while your CPP is declaring that only a single, non-list, parameter is being passed. Do you need to allow a list of object and library names? If so, what release are you on? Knowing this will let me know if you can use the *INT datatype in CL or if the %bin built-in is needed. If you don't need a list then remove the MAX(4) from OBJECT and LIBRARY, change the DCL of &SAVLIB in your CPP to a length of 10 (currently it's 12), and you should get quite a bit further along. Bruce Vining http://www.brucevining.com/
    6,410 pointsBadges:
    report
  • Mikey57
    Sometimes, there are multiple libraries or objects that need to be included but, not all the time. If I do it 1 object and library at a time, then I need to run multiple jobs if there are more than one this is why I chose 4 as I have seen a max of 3 but,m to be safe, I used 4. The current release is V5R4. Hope this helps. If you could give me an example or 2 to try or let me know what I'm doing wrong, I would appreciate this. Like I said, I'm new to CL and it's a learning process.
    35 pointsBadges:
    report
  • bvining
    Being new to CL you certainly picked a great way to start! Most commands are easier to do than yours. When you have a command that supports a list of values (a MAX > 1) there is control information that is passed to the CPP. In the case of a simple list, this is a count of the number of list entries followed by the actual list entries provided. This is described in the i5/OS Information Center. So in the following example I use this Count to control how many objects and libraries the CPP processes. As the CPP is getting a formatted list of object and library names, and SAVOBJ wants a simple list, we now get to reformat all the names. In the sample this is done in the DOFOR loops. I used a loop as this approach can handle many more entries than your current MAX of 4 without additional coding (other than changing the declared lengths for &Cmd, &ObjList, and &LibList). The example in the Information Center unfortunately means adding tests as you add entries... SBMJOB with the CMD parameter also introduces a little opportunity :-) The CMD parameter knows we're using a command and the system knows what types of variables we are using with the command. Specifically the SAVOBJ command knows it wants 10 character variables for OBJ and LIB, and will not handle our longer &ObjList and &LibList variables properly. For this reason I use the RQSDTA parameter rather than the CMD parameter. This then leads the program down the path of having to build a command string using the &Cmd variable. I'm probably forgetting a few things, but here is a sample program:
        Pgm        Parm(&Obj &SavLib &Vol &EndOpt &Job)           
                                                                  
        Dcl        Var(&Obj)     Type(*Char)              Len(42) 
         Dcl       Var(&NbrObj)  Type(*Int) Stg(*Defined) Len(2) +
                     DefVar(&Obj)                                 
                                                                  
        Dcl        Var(&SavLib)  Type(*Char)              Len(42) 
         Dcl       Var(&NbrLib)  Type(*Int) Stg(*Defined) Len(2) +
                     DefVar(&SavLib)                              
                                                                  
        Dcl        Var(&Vol)     Type(*Char)              Len(6)  
        Dcl        Var(&EndOpt)  Type(*Char)              Len(10) 
        Dcl        Var(&Job)     Type(*Char)              Len(10) 
                                                                  
        Dcl        Var(&Cmd)     Type(*Char)              Len(512)
        Dcl        Var(&ObjList) Type(*Char)              Len(44) 
        Dcl        Var(&LibList) Type(*Char)              Len(44) 
        Dcl        Var(&Pos)     Type(*Int)                       
        Dcl        Var(&Count)   Type(*Int)                       
                                                                  
        ChgVar     Var(&Pos) Value(3)                             
        DoFor      Var(&Count) From(1) To(&NbrObj)                
                   ChgVar Var(&ObjList) +                         
                      Value(&ObjList *BCat %sst(&Obj &Pos 10))    
                   ChgVar Var(&Pos) Value(&Pos + 10)              
                   EndDo                                          
                                                                  
        ChgVar     Var(&Pos) Value(3)                             
        DoFor      Var(&Count) From(1) To(&NbrLib)                
                   ChgVar Var(&LibList) +                         
                      Value(&LibList *BCat %sst(&SavLib &Pos 10)) 
                   ChgVar Var(&Pos) Value(&Pos + 10)              
                   EndDo                                          
                                                                  
        ChgVar     Var(&Cmd) Value('SAVOBJ OBJ(' *Cat &ObjList +  
                     *TCat ') LIB(' *Cat &LibList *TCat ') +      
                     DEV(TAPMLB06) OBJTYPE(*FILE) VOL(' *Cat +    
                     &Vol *TCat ') ENDOPT(' *Cat &EndOpt *TCat +  
                     ')')                                         
        SbmJob     Job(&Job) RqsDta(&Cmd)                         
        EndPgm                                                    
    
    I hope this helps, Bruce Vining http://www.brucevining.com/
    6,410 pointsBadges:
    report
  • Mikey57
    Bruce, This worked perfectly I was able to pass these along with everyhting and do a save then I was able to make a restore for this as well after saving it to tape. Thanks for all your help!!!!!
    35 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following