ADMIN_JOB_SUBMIT stored procedure

The SYSPROC.ADMIN_JOB_SUBMIT stored procedure submits a job to a JES2 or JES3 system.

Environment

Begin general-use programming interface information.

ADMIN_JOB_SUBMIT runs in a WLM-established stored procedure address space.

The load module for ADMIN_JOB_SUBMIT, DSNADMJS, must be program controlled if the BPX.DAEMON.HFSCTL FACILITY class profile has not been set up. For information on how to define DSNADMJS to program control, see installation job DSNTIJRA.

Authorization

To execute the CALL statement, the owner of the package or plan that contains the CALL statement must have one or more of the following privileges on each package that the stored procedure uses:

  • The EXECUTE privilege on the package for DSNADMJS
  • Ownership of the package
  • PACKADM authority for the package collection
  • SYSADM authority

Syntax

The following syntax diagram shows the SQL CALL statement for invoking this stored procedure:

>>-CALL--SYSPROC.ADMIN_JOB_SUBMIT--(--+-user-ID-+-,------------->
                                      '-NULL----'     

>--+-password-+-,--job-ID,--return-code,--message--)-----------><
   '-NULL-----'                                        

Option descriptions

user-ID
Start of changeSpecifies the user ID under which the job is submitted.

If user-ID is NULL, password must also be NULL. If the user-ID and password values are NULL, the login process uses the primary authorization ID of the process.

You can specify NULL for this parameter in the following circumstances:

  • The operating system is any supported level, and the authorization ID that is associated with the stored procedure address space has daemon authority.
  • The operating system is z/OS® Version 1 Release 13 or later, and the authorization ID that is associated with the stored procedure address space does not have daemon authority but is authorized to the BPX.SRV.userid SURROGAT class profile, where 'userid' is the authorization ID of the stored procedure. In this case, you must install APAR OA36062. For more information about how the RACF® security administrator can authorize the authorization ID that is associated with the stored procedure address space to a SURROGAT class profile, see Defining servers to process users without passwords or password phrases.

    Daemon authority is given to any superuser that is permitted to the BPX.DAEMON FACILITY class profile. If the BPX.DAEMON FACILITY class profile is not defined, all superusers have daemon authority.

This is an input parameter of type VARCHAR(128).

End of change
password
Start of changeSpecifies the password associated with the input parameter user-ID.

The value of password is passed to the stored procedure as part of payload and is not encrypted. It is not stored in dynamic cache when parameter markers are used.

If password is NULL, user-ID must also be NULL. If the user-ID and password values are NULL, the login process uses the primary authorization ID of the process.

You can specify NULL for this parameter in the following circumstances:

  • The operating system is any supported level, and the authorization ID that is associated with the stored procedure address space has daemon authority.
  • The operating system is z/OS Version 1 Release 13 or later, and the authorization ID that is associated with the stored procedure address space does not have daemon authority but is authorized to the BPX.SRV.userid SURROGAT class profile, where 'userid' is the authorization ID of the stored procedure. In this case, you must install APAR OA36062.

This is an input parameter of type VARCHAR(24).

End of change
job-ID
Identifies the JES2 or JES3 job ID of the submitted job.

This is an output parameter of type CHAR(8).

return-code
Provides the return code from the stored procedure. Possible values are:
0
The call completed successfully.
12
The call did not complete successfully. The message output parameter contains messages describing the error.

This is an output parameter of type INTEGER.

message
Contains messages describing the error encountered by the stored procedure. If no error occurred, then no message is returned.

The first messages in this area are generated by the stored procedure. Messages that are generated by DB2® might follow the first messages.

This is an output parameter of type VARCHAR(1331).

Additional input

In addition to the input parameters, the stored procedure submits the job's JCL from the created global temporary table SYSIBM.JOB_JCL for execution.

The following table shows the format of the created global temporary table SYSIBM.JOB_JCL:

Table 1. Additional input for the ADMIN_JOB_SUBMIT stored procedure
Column name Data type Contents
ROWNUM INTEGER Sequence number of the table row, from 1 to n
STMT VARCHAR(80) A JCL statement

Example

The following C language sample shows how to invoke ADMIN_JOB_SUBMIT:

 #include    <stdio.h>
 #include    <stdlib.h>
 #include    <string.h>

/******************** DB2 SQL Communication Area ********************/
 EXEC SQL INCLUDE SQLCA;

 int main( int argc, char *argv[] )    /* Argument count and list    */
 {
   /****************** DB2 Host Variables ****************************/
   EXEC SQL BEGIN DECLARE SECTION;

   /* SYSPROC.ADMIN_JOB_SUBMIT parameters                            */
   char        userid[129];            /* User ID                    */
   short int   ind_userid;             /* Indicator variable         */
   char        password[25];           /* Password                   */
   short int   ind_password;           /* Indicator variable         */
   char        jobid[9];               /* Job ID                     */
   short int   ind_jobid;              /* Indicator variable         */
   long int    retcd;                  /* Return code                */
   short int   ind_retcd;              /* Indicator variable         */
   char        errmsg[1332];           /* Error message              */
   short int   ind_errmsg;             /* Indicator variable         */

  /* Temporary table SYSIBM.JOB_JCL columns                          */
   long int    rownum;                 /* Sequence number of the     */
                                       /* table row                  */
   char        stmt[81];               /* JCL statement              */
   EXEC SQL END DECLARE SECTION;

   /******************************************************************/
   /* Create the JCL job to be submitted for execution               */
   /******************************************************************/
   char jclstmt[12][50] = {
   "//IEBCOPY  JOB ,CLASS=K,MSGCLASS=H,MSGLEVEL=(1,1)",
   "//STEP010 EXEC PGM=IEBCOPY",
   "//SYSPRINT DD SYSOUT=*",
   "//SYSUT3 DD SPACE=(TRK,(1,1)),UNIT=SYSDA",
   "//SYSUT4 DD SPACE=(TRK,(1,1)),UNIT=SYSDA",
   "//*",
   "//DDI1 DD DSN=USER.DEV.LOADLIB1,DISP=SHR",
   "//DDO1 DD DSN=USER.DEV.LOADLIB2,DISP=SHR",
   "//SYSIN DD *",
   " COPY OUTDD=DDO1,INDD=DDI1",
   "/*",
   "//*"
   } ;
   int i = 0;                          /* loop counter               */

   /******************************************************************/
   /* Assign values to input parameters                              */
   /* Set the indicator variables to 0 for non-null input parameters */
   /******************************************************************/
   strcpy(userid, "USRT001");
   ind_userid = 0;
   strcpy(password, "N1CETEST");
   ind_password = 0;

   /******************************************************************/
   /* Clear temporary table SYSIBM.JOB_JCL                           */
   /******************************************************************/
   EXEC SQL DELETE FROM SYSIBM.JOB_JCL;

   /******************************************************************/
   /* Insert the JCL job into the temporary table SYSIBM.JOB_JCL     */
   /******************************************************************/
   for (i = 0; i < 12; i++)
   {
     rownum = i+1;
     strcpy(stmt, jclstmt[i]);
     EXEC SQL INSERT INTO SYSIBM.JOB_JCL
                     ( ROWNUM, STMT)
              VALUES (:rownum, :stmt);
   };

   /******************************************************************/
   /* Call stored procedure SYSPROC.ADMIN_JOB_SUBMIT                 */
   /******************************************************************/
   EXEC SQL CALL SYSPROC.ADMIN_JOB_SUBMIT
                        (:userid    :ind_userid,
                         :password  :ind_password,
                         :jobid     :ind_jobid,
                         :retcd     :ind_retcd,
                         :errmsg    :ind_errmsg);

   return(retcd);
 }

Output

This stored procedure returns the following output parameters, which are described in Option descriptions:

  • job-ID
  • return-code
  • message

End general-use programming interface information.