Start of Content Area

Sample Program: Adding a Job Step for an External Command or Program  Locate the document in its SAP Library structure

With Release 4.0, there are now two ways to schedule external programs or commands in a job step. These are:

     External commands -- pre-defined symbolic names for commands or programs at the operating system level. External commands are intended for ordinary users. Because they are pre-defined in the SAP system and are authorizations-tested, the administrator has control over what users can do at the operating system level through background jobs.

     External programs -- OS commands that are directly entered into the job step specifications and for which no specific authorization test is carried out in the SAP system. Use of external programs is restricted to administrators (a special authorization is required.

You can schedule either an external command or an external program in a single job step, but not both. To schedule an external command, you use the COMMANDNAME and OPERATING SYSTEM parameters. To schedule an external program, you use the EXTPGM_NAME parameter.

Both external commands and external programs share the EXTPGM-parameters other than EXTPGM_NAME.

For more information, search for “External Programs” in the CCMS Guide.

*
* Add a job step: external program
*
  CALL FUNCTION 'JOB_SUBMIT'
   EXPORTING
     AUTHCKNAM      = SY-UNAME             “ User for runtime
                                           “ authorizations
     JOBCOUNT       = JOBNUMBER            “ From JOB_OPEN
     JOBNAME        = JOBNAME              “ From JOB_OPEN
     COMMANDNAME    = EXTERNAL_COMMAND     “ Name of a pre-defined
                                           “ external command. 
                                           “ COMMANDNAME and
                                           “ EXTPGM_NAME are
                                           “ mutually-exclusive
                                           “ alternatives.  Both
                                           “ use the EXTPGM
                                           “ parameters. 
     OPERATINGSYSTEM= 'AIX'                “ Operating system for
                                           “ choosing COMMANDNAME
                                           “ variant.  
     EXTPGM_NAME    = '/usr/exe/myexe'     “ Pathname of an
                                           “ external program; 
                                           “ an authorization
                                           “ for
S_RZL_ADM (CC
                                          
Control Center: 
                                          
System Administration)
                                           “ is required. 
     EXTPGM_PARAM   = '<Parameter String>' “ Program parameters
     EXTPGM_SYSTEM      = 'host01'         “ Host for execution
     EXTPGM_WAIT_FOR_TERMINATION = 'X'     “ Control flags for
     EXTPGM_STDOUT_IN_JOBLOG = 'X'         “ external programs:
     EXTPGM_SET_TRACE_ON     = 'X'         “ see RSXPGDEF
     EXTPGM_STDERR_IN_JOBLOG = 'X'         “ documentation for
                                           “ EXTPGM options
   EXCEPTIONS
     INVALID_JOBDATA         = 02
     JOBNAME_MISSING         = 03
     JOB_NOTEX               = 04
     JOB_SUBMIT_FAILED       = 05
     LOCK_FAILED             = 06
     PROGRAM_MISSING         = 07
     PROG_ABAP_AND_EXTPG_SET = 08
     BAD_XPGFLAGS            = 09
     OTHERS                  = 99.

  IF SY-SUBRC > 0.
    <Error processing>
  ENDIF.

 

 

End of Content Area