Ansicht
Dokumentation

ABAPSUBMIT_VIA_JOB - SUBMIT VIA JOB

ABAPSUBMIT_VIA_JOB - SUBMIT VIA JOB

Vendor Master (General Section)   CL_GUI_FRONTEND_SERVICES - Frontend Services  
This documentation is copyright by SAP AG.
SAP E-Book

SUBMIT, job_options

Short Reference



... $[USER user$] VIA JOB job NUMBER n $[LANGUAGE lang$] ...

Additions

1. ... USER user

2. ... LANGUAGE lang

Effect

This addition schedules the execution of the called program as a background task with the number n in the background request job. The number n for a background request job must be obtained using the function module JOB_OPEN from the function pool BTCH. The complete program is not processed directly but in a background session in accordance with the parameters for 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 loads the called program in a separate internal session when the statement SUBMIT is executed, and 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 because VIA SELECTION-SCREEN is specified, the user of the calling program can edit it and schedule the called program 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 terminated after selection screen processing and the calling program is resumed due to AND RETURN.
  2. The program is then scheduled in the background task. After this, scheduling is carried out in the background task, where the selections specified by the user or by 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. The current user and client of the current session correspond to the user and client of the background 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 is now run completely. All events are raised, including those from selection screen processing, although the selection screen is 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 called program, a spool request should be created with explicitly passed spool parameters by specifying TO SAP-SPOOL at the same time. Otherwise, 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 are not necessarily consistent.

System Fields

sy-subrc Meaning
0 Background task was scheduled successfully.
4 Scheduling was terminated by the user on the selection screen.
8 Error during the scheduling, that is during the internal call of JOB_SUBMIT.
12 Error during internal number assignment

Notes

  • Background jobs can usually be created and monitored via the menu path System - Services - Jobs. Internally, the language elements shown here are used. In addition to JOB_OPEN, the function modules JOB_CLOSE and JOB_SUBMIT can also be used in the ABAP program. JOB_CLOSE completes the creation of a background request. Like the SUBMIT statement, JOB_SUBMIT schedules an ABAP program as a background task in a background request. JOB_SUBMIT provides more control options for background processing but the input values for the selection screen must be passed to an existing selection screen variant. The statement SUBMIT creates this variant and accesses JOB_SUBMIT internally.
  • Also when the addition VIA JOB is used a call sequence is created for a short time. In the called program, the associated ABAP memory can be accessed in the processing blocks that are executed before actual background processing in the first step above, that is, before the internal session is exited after selection screen processing. The actual background processing takes place in a separate background session, where neither the ABAP memory nor the user memory of the calling program can be accessed.

Example

Scheduling of a program demo_submitable 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.

The following code snippet shows, how the background task can be analyzed.

Addition 1

... USER user

Effect

The optional addition USER can be used to specify a user name user of the type sy-uname under whose name the logon to the background session takes place and whose authorizations are used to execute the background task. If USER is not specified, the user name of the current user session is used.

Notes

  • The name specified after USER is checked using the authorization object S_BTCH_NAM. When the program is executed, only those names can be specified for which the current user has the appropriate authorization. The names allowed by the authorization object represent a type of include list of users whose logons allow the current user to execute a background task.
  • The current user should not be specified explicitly using USER sy-uname. This specification is redundant, and the system field is also at risk of being overwritten before the background task is scheduled, for example in the ABAP Debugger.

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 that contains 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 at the first position, the logon language of the current user is used.

Note

If the function module JOB_SUBMIT is called internally, its optional parameter LANGUAGE is passed the first position 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'.






BAL_S_LOG - Application Log: Log header data   ABAP Short Reference  
This documentation is copyright by SAP AG.

Length: 12719 Date: 20240328 Time: 212922     sap01-206 ( 196 ms )