SUBMIT - job_options
Short Reference
ABAP Syntax ... [USER user] VIA JOB job NUMBER n... .
ABAP_ADDITION:
... USER user
What does it do? 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 is supplied by function module
JOB_OPEN in function group BTCH . The full program is not
processed directly but in background processing, according to the
parameters specified for the background request. The addition
VIA
JOB can only be used together with the addition AND RETURN .
The VIA JOB addition also loads the program accessed in a
separate internal mode when the SUBMIT statement is executed and
the system performs all the steps specified before
START-OF-SELECTION . This means
the events LOAD-OF-PROGRAM and
INITIALIZATION are triggered 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 eidit 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, execution of the program executed is
completed after selection screen processing and the system returns to
the calling program due to the AND RETURN addition.
When the program is scheduled in the background task, the selections
specified by the user or in the additions for filling the selection
screen are stored in an internal variant .
When the program is executed in the background request, it is processed
fully but the selection screen is processed in the background. The
system triggers all events, including that for selection screen
processing. The variant stored internally is passed to the selection
screen between the INITIALIZATION and
AT SELECTION SCREEN OUTPUT
events.
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 . Otherwise the VIA JOB addition implicitly
creates a spool request 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
0Background task scheduled successfully.
4Scheduling 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 be created and monitored by choosing
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 closes 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 must
receive the input values for the selection screen in an existing
variant. The SUBMIT statement creates this variant and accesses
JOB_SUBMIT internally.
Example ABAP Coding Scheduling a submittable program as a background
task with the number number in a background request name .
After scheduling, the background task is completed by 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.
ABAP_ADDITION ... USER user
What does it do? The optional addition USER can be used to specify
a user name user of the type sy-uname , whose
authorizations are used to run the background task. If USER is
not specified, the user name of the current user session is used.
Latest notes: Using the addition FOR USER produces a security
risk. It can be misused to execute a program with more extensive
authorizations than the user actually has. User names passed to the
program from the outside should never be specified. If this does become
necessary, however, the name must be checked carefully.
The current user should not be specified explicitly using USER
sy-uname . Not only is the user specified redundantly, the system
field is also at risk of being overwritten before the background task is
scheduled, for example in ABAP Debugger.
See also User-Specific Program Flow .
Documentation extract taken from SAP system, � Copyright SAP AG. All rights reserved