You are on page 1of 37

IBM Global Services

Background Processing

Data Interfaces | 7.01

March-2005

2005 IBM Corporation

IBM Global Services

Objectives
The participants will be able to:
Describe how the SAP system handles background processing.
Create variants for ABAP programs. Create, schedule, and analyze a job using transactions SM36 and SM37. Explain the purpose of background processing.

Data Interfaces | 7.01

March-2005

2005 IBM Corporation

IBM Global Services

Background Processing
Phases of Background Processing.

Passing Data to Subsequent Job Steps.


Scheduling Job within ABAP Program.

Data Interfaces | 7.01

March-2005

2005 IBM Corporation

IBM Global Services

Work Processes

Transaction SM50

Dispatcher

Background

Dialog

Update

Enqueue

Spool

Data Interfaces | 7.01

March-2005

2005 IBM Corporation

IBM Global Services

The Background Work Process

Background Job A Step #1 Step #2


Defining a background job (SM36)
5 Data Interfaces | 7.01

Background

March-2005

2005 IBM Corporation

IBM Global Services

Phases of Background Processing

Job Scheduling

Job Processing

Job Overview

Data Interfaces | 7.01

March-2005

2005 IBM Corporation

IBM Global Services

Scheduling a Background Job

Transaction SM36

Job Scheduling

Data Interfaces | 7.01

March-2005

2005 IBM Corporation

IBM Global Services

Creating Step for Background Job


Steps
Job Scheduling

ABAP

External program

Data Interfaces | 7.01

March-2005

2005 IBM Corporation

IBM Global Services

Start Criteria for Background Job


Job Scheduling

Start Condition

Immediate

Date/Time

After Job

After Event

Jobs can be scheduled to run immediately or at a particular date/time.

Jobs can be scheduled to run after another job has been completed.

Jobs can be scheduled to run after an event has been triggered/raised.

If you start a job based on a date/time or an event, you can schedule the job to run at regular intervals, not just at a particular time.
9 Data Interfaces | 7.01 March-2005

2005 IBM Corporation

IBM Global Services

Scheduling a Periodic Job


Job Scheduling

Start date
Period values

Periodic job

By checking the Periodic Job option, you can specify that the job run at regular intervals.

With the Period Values pushbutton, you can schedule the job to run hourly, daily, weekly, monthly, etc.

10

Data Interfaces | 7.01

March-2005

2005 IBM Corporation

IBM Global Services

Scheduling Job After Another Job


Job Scheduling

Start date

After Job
After clicking on the After Job pushbutton, you must specify the name of the job that must be completed before this job will run.

X Start status-depend.

If you check the Start status-depend. option, this job will run only if the specified job ends successfully.

11

Data Interfaces | 7.01

March-2005

2005 IBM Corporation

IBM Global Services

Scheduling Job After an Event


Job Scheduling

Start date

After Event

After clicking on the After Event pushbutton, you must specify the name of the event that must be raised before this job will run. You can distinguish between different occurrences of a particular event by specifying a parameter. If you check the Periodic Job option, the system starts a new job each time the specified event is raised.

12

Data Interfaces | 7.01

March-2005

2005 IBM Corporation

IBM Global Services

Triggering/Raising Events
To trigger/raise an event from within an ABAP program, you must call the BP_EVENT_RAISE function module.

CALL FUNCTION BP_EVENT_RAISE EXPORTING EVENTID = <event name> EVENTPARM = TARGET_INSTANCE = EXCEPTIONS BAD_EVENTID =1 EVENTID_DOES_NOT_EXIST =2 EVENTID_MISSING =3 RAISE_FAILED =4 OTHERS = 5.

The only required exporting parameter is the name of the event to raise.

13

Data Interfaces | 7.01

March-2005

2005 IBM Corporation

IBM Global Services

Phases of Background Processing

Job Scheduling

Job Processing

Job Overview

14

Data Interfaces | 7.01

March-2005

2005 IBM Corporation

IBM Global Services

Processing a Background Job

Scheduler

Job

Dispatcher

Job Background

Job Processing

15

Data Interfaces | 7.01

March-2005

2005 IBM Corporation

IBM Global Services

Processing a Background Job


Application Server Work Processes
8 Online

Job Processing
Transaction SM50

1 Spool

3 Background

16

Data Interfaces | 7.01

March-2005

2005 IBM Corporation

IBM Global Services

Processing a Background Job


Job Log

Scheduler

Entries from start and end modules. All messages issued by job steps and system.

Start Module

PRINT SPOOL

Job Step #1 Job Step #2 Job Step #3

Job Processing

List All WRITE statement output from job step.

End Module

17

Data Interfaces | 7.01

March-2005

2005 IBM Corporation

IBM Global Services

Phases of Background Processing

Job Scheduling

Job Processing

Job Overview

18

Data Interfaces | 7.01

March-2005

2005 IBM Corporation

IBM Global Services

Job Overview
Transaction SM37

Job Status

Job Overview

Spool List

19

Data Interfaces | 7.01

March-2005

2005 IBM Corporation

IBM Global Services

Job Analysis Using Job Log


Job Overview

System and Program Messages

You can use this Job Log to analyze each step of a finished or cancelled background job.

20

Data Interfaces | 7.01

March-2005

2005 IBM Corporation

IBM Global Services

Job Analysis Using Job Spool

Display Report

21

Data Interfaces | 7.01

March-2005

2005 IBM Corporation

IBM Global Services

Other Background Processing Topics

Passing Data to Subsequent Job Steps

Scheduling Job within ABAP Program

22

Data Interfaces | 7.01

March-2005

2005 IBM Corporation

IBM Global Services

Scheduling Job within ABAP Program


Open Background Job JOB_OPEN

JOB_SUBMIT is called for each step that is to be added to the job

Insert Job Step JOB_SUBMIT

Close Background Job JOB_CLOSE


23 Data Interfaces | 7.01 March-2005

2005 IBM Corporation

IBM Global Services

JOB_OPEN

JOB_OPEN Exporting: jobname = <job name>

Background Job <job name>

<job #>

Importing: jobcount = <job #>

24

Data Interfaces | 7.01

March-2005

2005 IBM Corporation

IBM Global Services

JOB_SUBMIT
JOB_SUBMIT

Exporting: authcknam = <user> jobcount = <job #> jobname = <job name> report = <report> variant = <variant>

Background Job` <job name>

<job #>

Exporting: authcknam = <user> jobcount = <job #> jobname = <job name> report = <report> variant = <variant>

Step #1

Step #2

25

Data Interfaces | 7.01

March-2005

2005 IBM Corporation

IBM Global Services

JOB_CLOSE
JOB_CLOSE

Background Job
<job name>

Exporting: jobcount = <job #> jobname = <job name> sdlstrtdt = <start date> sdlstrttm = <start time> strtimmed = <flag1>

<job #>

Step #1 Importing: job_was_released = <flag2>

Step #2

26

Data Interfaces | 7.01

March-2005

2005 IBM Corporation

IBM Global Services

ABAP Program Example

Open Job Submit Step

Close Job

REPORT YDI00001. DATA: JOBNUM LIKE TBTCJOB-JOBCOUNT. PARAMETERS: JOBNAME LIKE TBTCJOB-JOBNAME, PROGRAM LIKE SY-REPID, VARIANT LIKE RALDB-VARIANT, USER LIKE SY-UNAME. CALL FUNCTION JOB_OPEN EXPORTING JOBNAME = JOBNAME IMPORTING JOBCOUNT = JOBNUM. CALL FUNCTION JOB_SUBMIT EXPORTING AUTHCKNAM = USER CHECK JOBCOUNT = JOBNUM SY-SUBRC JOBNAME = JOBNAME REPORT = PROGRAM VARIANT = VARIANT. CALL FUNCTION JOB_CLOSE EXPORTING JOBCOUNT = JOBNUM JOBNAME = JOBNAME.
March-2005

27

Data Interfaces | 7.01

2005 IBM Corporation

IBM Global Services

Passing Data to Subsequent Job Steps


Background Job Step #1 ... EXPORT <obj1 objn>TO DATABASE <dbtable> ID <id1>. EXPORT < obj1 objn>TO DATASET <filename> ID <id2>.

DBTABLE

id1

data1

FILENAME id2 data2

Step #2 ... IMPORT < obj1 objn> FROM DATABASE <dbtable>ID <id1>.
IMPORT < obj1 objn> FROM DATASET <filename> ID <id2>.

28

Data Interfaces | 7.01

March-2005

2005 IBM Corporation

IBM Global Services

Passing Data to Subsequent Job Steps (Contd.)


Background Job Step #1 ... EXPORT <obj1 objn>TO DATABASE <dbtable> ID <id1>. EXPORT < obj1 objn>TO DATASET <filename> ID <id2>.

DBTABLE

id1

data1

FILENAME id2 data2

Step #2 ... IMPORT < obj1 objn> FROM DATABASE <dbtable>ID <id1>.
IMPORT < obj1 objn> FROM DATASET <filename> ID <id2>.

29

Data Interfaces | 7.01

March-2005

2005 IBM Corporation

IBM Global Services

Using the Database to Pass Data between Job Steps

INDX
MANDT RELID SRTFD

Job Step Background #1 TABLES: INDX. DATA: var1(9) TYPE p DECIMALS 2. ... EXPORT var1 TO DATABASE indx(st) ID 12345
CLUSTR CLUSTD

..

800 800 800 800

SP ST ST TM

SPH_I 12345 ABCL KVERM

254 53 73 97

FF05010102 FF05016876 FF05075372 FF03578902

Step #2 TABLES: INDX. DATA: var1(9) TYPE p DECIMALS 2. ... IMPORT var1 FROM DATABASE indx(st) ID 12345.
March-2005

30

Data Interfaces | 7.01

2005 IBM Corporation

IBM Global Services

Using the Database to Pass Data between Job Steps (Contd.)

INDX
MANDT RELID SRTFD

Job Step Background #1 TABLES: INDX. DATA: var1(9) TYPE p DECIMALS 2. ... EXPORT var1 TO DATABASE indx(st) ID 12345
CLUSTR CLUSTD

..

800 800 800 800

SP ST ST TM

SPH_I 12345 ABCL KVERM

254 53 73 97

FF05010102 FF05016876 FF05075372 FF03578902

Step #2 TABLES: INDX. DATA: var1(9) TYPE p DECIMALS 2. ... IMPORT var1 FROM DATABASE indx(st) ID 12345.
March-2005

31

Data Interfaces | 7.01

2005 IBM Corporation

IBM Global Services

Structure of the Data Cluster Table


Key fields to uniquely identify Data Cluster Area Client
MANDT RELID SRTFD

Cluster Length

INDX
SRTF2

Cluster Data
CLUSTR CLUSTD FF0501010254787 FF0501687618710 FF0507110005472 FF0357890541472

...

800 800 800 800

SP ST ST TM

SPH_I 12345 ABCL KVERM

0 0 0 0

254 53 73 97

Fields to store information pertaining to cluster data, not automatically updated by export, need to be explicitly set before the export statement
32 Data Interfaces | 7.01 March-2005

2005 IBM Corporation

IBM Global Services

Structure of the Data Cluster Table (Contd.)


Key fields to uniquely identify Data Cluster Area Client
MANDT RELID SRTFD

Cluster Length

INDX
SRTF2

Cluster Data
CLUSTR CLUSTD FF0501010254787 FF0501687618710 FF0507110005472 FF0357890541472

...

800 800 800 800

SP ST ST TM

SPH_I 12345 ABCL KVERM

0 0 0 0

254 53 73 97

Fields to store information pertaining to cluster data, not automatically updated by export, need to be explicitly set before the export statement
33 Data Interfaces | 7.01 March-2005

2005 IBM Corporation

IBM Global Services

Demonstration
Creation, scheduling and analyzing a background job using transactions SM36 and SM37.

34

Data Interfaces | 7.01

March-2005

2005 IBM Corporation

IBM Global Services

Practice
Creation, scheduling and analyzing a background job using transactions SM36 and SM37.

35

Data Interfaces | 7.01

March-2005

2005 IBM Corporation

IBM Global Services

Summary
Job Scheduling Job Processing Job Overview

Job Log Step #1 Spool List

Step #2

Background

36

Data Interfaces | 7.01

March-2005

2005 IBM Corporation

IBM Global Services

Questions
What are the various types of work processes present in the R/3 system ?

What are the main phases of background processing ?


What are the main function modules used to create background job through ABAP program ?

37

Data Interfaces | 7.01

March-2005

2005 IBM Corporation

You might also like