SAP SUBMIT VIA JOB ABAP Statements



Get Example source ABAP code based on a different SAP table
  


• VIA JOB NUMBER SUBMIT

SUBMIT, job_options
Short Reference

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

ABAP Addition
1 ... USER user
2 ... LANGUAGE lang

What does it do?
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: The addition VIA JOB also loads the called program in a separate ABAP_ISESS 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 ABAP_ISESS of the called program is terminated after selection screen processing and the calling program is resumed due to AND RETURN. 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. 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-subrcMeaning 0Background task was scheduled successfully. 4Scheduling was terminated by the user on the selection screen. 8Error during the scheduling, that is during the internal call of JOB_SUBMIT. 12Error during internal number assignment



Latest 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.
If a scheduling error occurs, the key of the last error message sent can be read using the method GET_ERROR_MESSAGE of the class CL_ABAP_SUBMIT_HANDLING.
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 ABAP_ISESS 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.
ABAP_HINT_END



Example ABAP Coding

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.
ABEXA 01582
The following code snippet shows how the background task can be analyzed.
ABEXA 01583
ABAP_EXAMPLE_END
• USER SUBMIT

ABAP Addition

What does it do?
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.



Latest 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.
See also User-Specific Program Flow.
ABAP_HINT_END
• LANGUAGE SUBMIT

ABAP Addition

What does it do?
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 ABAP_ISESS 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.



Latest notes:

If the function module JOB_SUBMIT is called internally, its optional parameter LANGUAGE is passed the first position of lang.
ABAP_HINT_END



Example ABAP Coding

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'.
ABAP_EXAMPLE_END

Return to menu