You are on page 1of 15

SAP ABAP ECC 6.0 Bootcamp SAP ABAP ECC 6.0 bootcamp_Unit 3.

ppt
Unit 3

Background Processing -
Overview
Characteristics

Execution
Execution ofof ABAP
ABAP programs
programs without
without
dialog
dialog (no
(no specific
specific job-control
job-control language
language
for
for operating
operating system
system required)
required)

Complete
Complete integration
integration in
in the
the SAP
SAP System
System

Parallel
Parallel background
background and
and online
online operation
operation

Ease
Ease of
of use
use

Distributed
Distributed processing
processing
3

Key Message(s):
Background processing allows users to work non-interactively (i.e. off-line).
Instead of executing an ABAP program and waiting for an answer, a user can
create a background job to execute the ABAP program at a particular time.
Background jobs are typically used for the following tasks:
• To process large amounts of data (i.e. a daily movement of data to a
data warehouse).
• To execute periodic jobs without human intervention (i.e. system
clean-up jobs).
• To run programs during non-work hours to decrease the system load
and improve performance (i.e. nightly summary reports).

Additional Information:

Z65431 Copyright © Accenture 2008 All Rights Reserved 3


SAP ABAP ECC 6.0 Bootcamp SAP ABAP ECC 6.0 bootcamp_Unit 3.ppt
Unit 3

Process Flow - Overview


SCHEDULE
SCHEDULE
PROCESS
PROCESS OVERVIEW
OVERVIEW

ABAP
PROGRAM.

Background
Background
VARIANT JOB Work
Work Job Log
process
process

Date & Time

Key Message(s):
A job is a sequential sequence of steps that can be scheduled, i.e. the
automatic initiation of programs in SAP as opposed to executing the programs
manually.
There are three key components required to define a job:
• the program to be run
• the program’s variant (a variant is saved set of value assignments for
a selection screen)
• Time / Date that the job is to be run
A job can have multiple steps. A step is a program for background processing
with a parameter set (variants).
Once the job has been defined, the job can be released either immediately or
to the specified date/time in the future.
Once a job has been released, it is executed by a background work process
within the R/3 Basis System.
The results of the job can then be viewed in the job overview facility (SM37).

Additional Information:

Z65431 Copyright © Accenture 2008 All Rights Reserved 4


SAP ABAP ECC 6.0 Bootcamp SAP ABAP ECC 6.0 bootcamp_Unit 3.ppt
Unit 3

Scheduling Background Jobs


Function
Function "Job
"Job definition"
definition"

Job name ............


.
.
. Steps
Steps

Print
Print data
data

Start
Start date
date

Period
Period
Save
Save 5

Key Message(s):
To define a background job, access the Job definition function via System -> Services
-> Jobs -> Job definition or go to this function via transaction code SM36.
To create a background job, the following information must be provided:
• Job name - freely definable up to 32 characters in length.
• ABAP Program - the name of the ABAP program to be started along with its
associated variant.
• Start date.
Existing jobs can be extended by adding additional steps.
In a distributed environment, it is possible to specify a target host for processing. The
target host is the SAP instance where the job will be executed.
A job class can be specified in order to classify jobs by priority and job type. See SAP
help for more information.
It is also possible to schedule background jobs to run after the execution of another
job (see help on After Job for more information) or after the completion of a system
event (see SAP help on after event for more information).
To edit a background job, access the Job overview via System -> Services -> Jobs ->
Job Overview or via transaction code SM37.

Additional Information:

Z65431 Copyright © Accenture 2008 All Rights Reserved 5


SAP ABAP ECC 6.0 Bootcamp SAP ABAP ECC 6.0 bootcamp_Unit 3.ppt
Unit 3

Processing Jobs - Job Status


Scheduled
Scheduled

Released
Released

Ready
Ready

Active
Active

Finished
Finished
Cancelled
Cancelled
6

Key Message(s):
To check the status of a job, go to Job Overview (SM37).
A job can have any one of the following status:
• Scheduled: The job has been created but still has not been assigned
a Start Date and Time. A scheduled job will never execute unless it is
assigned a start date or released.
• Released: The job is released to run at the time or condition specified
in the start options, but the run time has not occurred yet.
• Ready: The start date and time has arrived and the job is waiting to
be executed and waiting for a background work process to free up.
This is a status not seen very often as it is typically a very short
interval between job released and job active.
• Active: The job is being executed.
• Finished: The job has ended successfully.
• Canceled: The job has ended with errors.

Additional Information:

Z65431 Copyright © Accenture 2008 All Rights Reserved 6


SAP ABAP ECC 6.0 Bootcamp SAP ABAP ECC 6.0 bootcamp_Unit 3.ppt
Unit 3

Job Results - Job Log


Job Log

Date Time Msg. ID Message

Job Started
07.21.1998 14:00:20 00516
step001 started
07.21.1998 14:00:21 00550 (program ZTEST, variant
. . . ZVAR, . .
. . . .
. . . .
. . . .
. . . .
07.21.1998 14:00:56 00517 Job Finished
7

Key Message(s):
The job log can be displayed from within the job overview.
The job log contains all messages that are displayed with the ABAP language
command MESSAGE... (only the types I, S, A, and X is permitted, since E
and W requires user entry to an online screen, as well as system-internal
messages.
The display is language-dependent.

Additional Information:

Z65431 Copyright © Accenture 2008 All Rights Reserved 7


SAP ABAP ECC 6.0 Bootcamp SAP ABAP ECC 6.0 bootcamp_Unit 3.ppt
Unit 3

Job Results (Spool Request)


Job
Job list
list
Job
Job name
name JOBA
User
User name
name Smith
Start
Start date
date 10/29/92 WRITE...

Spool

Key Message(s):
Generated lists (ABAP language command WRITE) are automatically stored in
the a spool file. The spool file can be viewed and printed with job overview
(SM37) or via the output controller (SP01).
One list can be output for each job step unless the ABAP program uses special
statements.
Printing can be specified during scheduling or it can be initiated manually via
either the job overview of the output controller.

Additional Information:

Z65431 Copyright © Accenture 2008 All Rights Reserved 8


SAP ABAP ECC 6.0 Bootcamp SAP ABAP ECC 6.0 bootcamp_Unit 3.ppt
Unit 3

Passing Data to Memory (may not


work – Etem)
Job: Step 1:

Global TABLES: LFA1.


Global REPORT…
ABAP
ABAP DATA FLAG, F1, BEGIN OF TAB OCCURS
Memory
Memory IF...
EXPORT FLAG TAB LFA1 F1 TO MEMORY.
ENDIF.
FLAG

Step 2:
F1
REPORT...
TAB DATA FLAG, F1, BEGIN OF TAB OCCURS.
IF SY-BATCH NE SPACE
IMPORT FLAG TAB LFA1 F1
FROM MEMORY.
IF SY-SUBRC NE SPACE
AND FLAG NE SPACE.
...
9

Key Message(s):
Passing data to memory can be very useful in ABAP but is particularly useful in
ABAPs that will be executed in the background. Two important features are
that data can be passed to programs in subsequent steps or, it is possible to
pass data structures to memory, submit another program to run ( which could
alter the data etc ) and then return to the calling program with the altered data.
The example above shows how data can be passed to a subsequent program.
Global ABAP memory can be used to pass on the contents of fields, records
and internal tables to subsequent steps.

Additional Information:

Z65431 Copyright © Accenture 2008 All Rights Reserved 9


SAP ABAP ECC 6.0 Bootcamp SAP ABAP ECC 6.0 bootcamp_Unit 3.ppt
Unit 3

Authorizations for Background


Processing
Objects
Objects Fields
Fields Values
Values Description
Description
S_BTCH_JOB
S_BTCH_JOB Job
Job activities
activities DELE
DELE Delete
Delete job
job
PLAN
PLAN Schedule
Schedule jobjob
LIST
LIST Display
Display job
job list
list
PROT
PROT Display
Display job
job log
log
RELE
RELE Release
Release job
job
SHOW
SHOW Display
Display job
job

S_BTCH_NAM
S_BTCH_NAM User
User name
name <User
<User names>
names> User
User names
names that
that can
can
be
be specified
specified when
when
scheduling
scheduling aa job
job

S_PROGRAM
S_PROGRAM Authorization
Authorization <Auth.
<Auth. group>
group> Programs
Programs thatthat belong
belong
group
group to
to the
the authorization
authorization
groups
groups entered
entered here
here can
can
be
be specified
specified when
when
User
User action
action BTCSUBMIT
BTCSUBMIT scheduling
scheduling aa job.
job.

Batch User names that can be


S_BTCH_ADM <Usernames>
Administrator ID specified to maintain
batch jobs.
10

Key Message(s):
There are authorization objects which are listed above for batch processing.
The individual functions are protected by the object S_BTCH_JOB during job
processing, and during job creation by the object S_BTCH_NAM.

Additional Information:

Z65431 Copyright © Accenture 2008 All Rights Reserved 10


SAP ABAP ECC 6.0 Bootcamp SAP ABAP ECC 6.0 bootcamp_Unit 3.ppt
Unit 3

Generating Jobs Automatically

Create
Create job
job

Insert
Insert job
job steps
steps

Complete
Complete job
job

11

Key Message(s):
It is possible to dynamically generate a batch job from within an ABAP
program.
The ABAP program opens the job, inserts the job steps, and closes the job.

Additional Information:

Z65431 Copyright © Accenture 2008 All Rights Reserved 11


SAP ABAP ECC 6.0 Bootcamp SAP ABAP ECC 6.0 bootcamp_Unit 3.ppt
Unit 3

Function Modules for Generating


Jobs
JOB_OPEN
JOB_OPEN

JOB_SUBMIT
JOB_SUBMIT

JOB_CLOSE
JOB_CLOSE

12

Key Message(s):
Function modules are available to facilitate creating a job with an ABAP
program. These function modules are called up in the sequence listed above.

Additional Information:

Z65431 Copyright © Accenture 2008 All Rights Reserved 12


SAP ABAP ECC 6.0 Bootcamp SAP ABAP ECC 6.0 bootcamp_Unit 3.ppt
Unit 3

Function Module ‘JOB_OPEN’


CALL
CALL FUNCTION
FUNCTION ’JOB_OPEN’
’JOB_OPEN’

EXPORTING
EXPORTING
DELANFREP
DELANFREP == <delete
<delete internal
internal report>
report>
JOBNAME
JOBNAME == <job
<job name>
name>

IMPORTING
IMPORTING
JOBCOUNT
JOBCOUNT =<job
=<job number>
number>

EXCEPTIONS
EXCEPTIONS
CANT_CREATE_JOB
CANT_CREATE_JOB == 11
INVALID_JOB_DATA
INVALID_JOB_DATA == 22
JOBNAME_MISSING
JOBNAME_MISSING == 33
..
..
..
13

Key Message(s):
The JOB_OPEN function module opens a background job. The ABAP
program passes a job name to JOB_OPEN, and JOB_OPEN returns a job
number to the ABAP program.

Additional Information:

Z65431 Copyright © Accenture 2008 All Rights Reserved 13


SAP ABAP ECC 6.0 Bootcamp SAP ABAP ECC 6.0 bootcamp_Unit 3.ppt
Unit 3

Function Module ‘JOB_SUBMIT’


CALL
CALL FUNCTION
FUNCTION ’JOB_SUBMIT’
’JOB_SUBMIT’

EXPORTING
EXPORTING
AUTHCKNAM
AUTHCKNAM == <user>
<user>
JOBCOUNT
JOBCOUNT == <job
<job number>
number>
JOBNAME
JOBNAME == <job
<job name>
name>
REPORT
REPORT == <report
<report name>
name>
VARIANT
VARIANT == <report
<report variant>
variant>

EXCEPTIONS
EXCEPTIONS
..
..
..

14

Key Message(s):
To add a job step, use the function module JOB_SUBMIT. To do this, the
following parameters are required:
• the job name
• the job number (passed to the program from the JOB_OPEN function
module)
• the report name
• a variant (if required) as well as a batch user ID for the authorization
checks.
Instead of the function module JOB_SUBMIT, the SUBMIT statement can also
be used in the format SUBMIT <report> USER <user> VIA JOB <jobname>
NUMBER <jobnumber>. For more information, refer to the online
documentation for the SUBMIT statement.
In addition to the functions of the function module JOB_SUBMIT, the SUBMIT
statement permits to specify the selection set with the WITH parameter. The
specification of a variant is then not necessary.

Additional Information:

Z65431 Copyright © Accenture 2008 All Rights Reserved 14


SAP ABAP ECC 6.0 Bootcamp SAP ABAP ECC 6.0 bootcamp_Unit 3.ppt
Unit 3

Function Module ‘JOB_CLOSE’


CALL
CALL FUNCTION
FUNCTION ’JOB_CLOSE’
’JOB_CLOSE’

EXPORTING
EXPORTING
JOBCOUNT
JOBCOUNT == <job
<job number>
number>
JOBNAME
JOBNAME == <job
<job name>
name>
SDLSTRTDT
SDLSTRTDT == <start
<start date>
date>
SDLSTRTTM
SDLSTRTTM == <start
<start time>
time>
STRTIMMED
STRTIMMED == <immediate
<immediate start>
start>
..
..
..

IMPORTING
IMPORTING
JOB_WAS_RELEASED
JOB_WAS_RELEASED == <job
<job released
released indicator>
indicator>

EXCEPTIONS
EXCEPTIONS
..
..
..

15

Key Message(s):
The function module JOB_CLOSE closes a background job. The function
requires the following parameters: job name and the job number to do this
(mandatory). If the start date and time were not specified in the JOB_OPEN, it
is possible to make these specifications for JOB_CLOSE (optional).
In addition, the function module JOB_CLOSE allows a specification for the
immediate start (STRTIMMED = 'X').
A parameter JOB_WAS_RELEASED returns a value of ‘X’ the job was
released.
Various parameters are available for other functions - refer to the Function
Module interface documentation (SE37).

Additional Information:

Z65431 Copyright © Accenture 2008 All Rights Reserved 15


SAP ABAP ECC 6.0 Bootcamp SAP ABAP ECC 6.0 bootcamp_Unit 3.ppt
Unit 3

Example: Program to Generate a


Job
REPORT B180D025.
DATA: JOBCOUNT LIKE TBTCO-JOBCOUNT.
PARAMETERS: JOBNAME LIKE TBTCO-JOBNAME,
REPORT LIKE SY-REPID,
VARIANT LIKE RALDB-VARIANT,
BTCHUSER LIKE SY-UNAME.
START-OF-SELECTION.
CALL FUNCTION ’JOB_OPEN’
EXPORTING JOBNAME = JOBNAME
IMPORTING JOBCOUNT = JOBCOUNT.
CALL FUNCTION ’JOB_SUBMIT’
EXPORTING AUTHCKNAM = BTCHUSER
JOBCOUNT = JOBCOUNT
JOBNAME = JOBNAME
REPORT = REPORT
VARIANT = VARIANT.
WRITE: / JOBNAME, JOBCOUNT,
REPORT, VARIANT, BTCHUSER.
CALL FUNCTION ’JOB_CLOSE’
EXPORTING JOBCOUNT = JOBCOUNT
JOBNAME = JOBNAME.
16

Key Message(s):
This example shows how a job can be generated by an ABAP program.
Note: To create a multi-step job, the JOB_SUBMIT function module must be
called for each step.

Additional Information:

Z65431 Copyright © Accenture 2008 All Rights Reserved 16


SAP ABAP ECC 6.0 Bootcamp SAP ABAP ECC 6.0 bootcamp_Unit 3.ppt
Unit 3

Other Function Modules for


Generating Jobs
BP_JOBLOG_SHOW
BP_JOBLOG_SHOW BP_JOBLOG_READ
BP_JOBLOG_READ
Display
Display job
job log
log Read
Read job
job log
log

BP_JOB_COPY
BP_JOB_COPY BP_JOB_DELETE
BP_JOB_DELETE
Copy
Copy job
job Delete
Delete job
job

BP_EVENT_RAISE
BP_EVENT_RAISE BP_CHECK_EVENTID
BP_CHECK_EVENTID
Trigger
Trigger event
event Check
Check event
event name
name
17

Key Message(s):
Other function modules exist to facilitate automated job processing. For more
information refer to the SAP Help.
• BP_JOB_SELECT - Reads jobs from database
• BP_START_DATE_EDITOR - Display/request start specifications
• BP_JOB_MAINTENANCE - Job management functions
• BP_JOB_GET_PREDECESSORS - List the predecessor-jobs of a job
• BP_JOB_GET_SUCCESSORS - List the successor-jobs of a job
• BP_FIND_JOBS_WITH_PROGRAM - Read jobs that run a specific
program from database
• BP_CALCULATE_NEXT_JOB_STARTS - Determine start dates &
times for a periodic job
• BP_JOBLIST_PROCESSOR - Allow user to work with lists of jobs
• BP_JOBVARIANT_SCHEDULE - Express job scheduling
• BP_JOBVARIANT_OVERVIEW - Express job management

Additional Information:

Z65431 Copyright © Accenture 2008 All Rights Reserved 17

You might also like