ABAP - Keyword Documentation →  ABAP - Reference →  Calling and leaving program units →  Calling Programs →  Calling Executable Programs →  SUBMIT → 

SUBMIT - job_options

Quick Reference

Syntax

... [USER user] VIA JOB job NUMBER n [LANGUAGElang] ...

Extras:

1. ... USER user

2. ... LANGUAGE lang

Effect

This addition schedules the execution of the program accessed as a background task with the number n in the background request job. The number n for a background request job must be filled using the function module JOB_OPEN from the function group BTCH. The full program is processed in a background session in accordance with the parameters of the background request and is not processed directly. The addition VIA JOB can only be used together with the addition AND RETURN.

The called program is scheduled and executed in three steps:

  1. The addition VIA JOB also first loads the program in question to a separate internal session when the statement SUBMIT is executed. Here, all steps located before START-OF-SELECTION are executed. This means the events LOAD-OF-PROGRAM and INITIALIZATION are raised and selection screen processing is performed. If the selection screen is not processed in the background when VIA SELECTION-SCREEN is specified, the user of the calling program can edit it and schedule the program accessed in the background request using the function Place in Job. If the user cancels selection screen processing, the program is not scheduled in the background job. In both cases, the internal session of the called program is exited after selection screen processing and the calling program is resumed due to AND RETURN.

  2. The program is then scheduled in the background task. Here, the selections specified by the user or in the additions for filling the selection screen are stored in an internal selection screen variant.

  3. The actual execution of the program then takes place in a separate background session as part of the background request. User and client match the current user and client of the current session. The user can be overwritten using the addition USER. The language of the background session is either the current text environment language or can be set using the addition LANGUAGE. The program now runs in full. All events are raised, including those from selection screen processing (although these are processed in the background). The selection screen variant stored internally is passed to the selection screen between the events INITIALIZATION and AT SELECTION SCREEN OUTPUT.

If a basic list is created in the program accessed, a spool request should be created with explicit spool parameters by specifying TO SAP-SPOOL. If this is not done, the addition VIA JOB creates a spool request implicitly that derives its spool parameters from standard values, some of which are taken from the user defaults, and which are not necessarily consistent.

System Fields

sy-subrc Meaning
0 Background task scheduled successfully.
4 Scheduling terminated by the user on the selection screen.
8 Error in scheduling (in the internal call of JOB_SUBMIT).
12 Error in internal number assignment.

Notes

Example

Schedules a submittable program as a background task with the number number in a background request name. After scheduling, the background task is completed by the function module JOB_CLOSE and released immediately, providing the user has the relevant authorization.

DATA: number           TYPE tbtcjob-jobcount,
      name             TYPE tbtcjob-jobname VALUE 'JOB_TEST',
      print_parameters TYPE pri_params.

...

CALL FUNCTION 'JOB_OPEN'
  EXPORTING
    jobname              = name
  IMPORTING
    jobcount             = number
  EXCEPTIONS
    cant_create_job  = 1
    invalid_job_data = 2
    jobname_missing      = 3
    OTHERS           = 4.
IF sy-subrc = 0.
  SUBMIT submitable TO SAP-SPOOL
                    SPOOL PARAMETERS print_parameters
                    WITHOUT SPOOL DYNPRO
                    VIA JOB name NUMBER number
                    AND RETURN.
  IF sy-subrc = 0.
    CALL FUNCTION 'JOB_CLOSE'
      EXPORTING
        jobcount             = number
        jobname              = name
        strtimmed            = 'X'
      EXCEPTIONS
        cant_start_immediate = 1
        invalid_startdate    = 2
        jobname_missing      = 3
        job_close_failed     = 4
        job_nosteps          = 5
        job_notex            = 6
        lock_failed          = 7
        OTHERS               = 8.
    IF sy-subrc <> 0.
      ...
    ENDIF.
  ENDIF.
ENDIF.


Addition 1

... USER user

Effect

The optional addition USER can be used to specify a user name user of the type sy-uname. The name of this user is used to log on to the background session and its authorizations are used to execute the background task. If USER is not specified, the user name of the current user session is used.

Notes

Addition 2

... LANGUAGE lang

Effect

This addition sets the logon language of the background session in which the called program is executed. If the addition LANGUAGE is not specified, the text environment language of the current internal session is used.

lang expects a character-like data object. This must contain a language key with a length of one character in the first place and this value must be contained in the column SPRAS of the database table T002. If the data object lang contains a blank in its first place, the logon language of the current user is used.

Note

If the function module JOB_SUBMIT is called internally, its optional parameter LANGUAGE is filled with the first place of lang.

Example

This statement

SUBMIT submitable TO SAP-SPOOL
                  SPOOL PARAMETERS print_parameters
                  WITHOUT SPOOL DYNPRO
                  VIA JOB name NUMBER number
                  LANGUAGE langu
                  AND RETURN.

has the same effect as the following function module call:

CALL FUNCTION 'JOB_SUBMIT'
  EXPORTING
    authcknam = sy-uname
    jobcount             = number
    jobname              = name
    language  = langu
    priparams = print_parameters
    report    = 'SUBMITABLE'.