Vous êtes sur la page 1sur 37

IBM Global Services

Background Processing

Data Interfaces |

Dec-2008

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 |

Dec-2008

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 |

Dec-2008

2005 IBM Corporation

IBM Global Services

Transaction

Work Processes

SM50

Dispatcher

Background

Dialog

Update

Data Interfaces |

Enqueue

Spool

Dec-2008

2005 IBM Corporation

IBM Global Services

The Background Work Process

Background
Background Job
Job A
A

Background

Step #1
Step #2
Defining a
background job (SM36)

Data Interfaces |

Dec-2008

2005 IBM Corporation

IBM Global Services

Phases of Background Processing

Job
Job
Scheduling
Scheduling

Job
Job
Processing
Processing

Job
Job
Overview
Overview

Data Interfaces |

Dec-2008

2005 IBM Corporation

IBM Global Services

Scheduling a Background Job

Transaction
SM36

Job
Job
Scheduling
Scheduling

Data Interfaces |

Dec-2008

2005 IBM Corporation

IBM Global Services

Creating Step for Background Job


Steps

Job
Job
Scheduling
Scheduling

ABAP

External program

Data Interfaces |

Dec-2008

2005 IBM Corporation

IBM Global Services

Start Criteria for Background Job


Job
Job
Scheduling
Scheduling

Start Condition

Immediate

Date/Time

Jobs can be scheduled to


run immediately or at a
particular date/time.

After Job

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

After Event

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.

Data Interfaces |

Dec-2008

2005 IBM Corporation

IBM Global Services

Scheduling a Periodic Job


Job
Job
Scheduling
Scheduling

Start date
Period values

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

10

Data Interfaces |

With the Period


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

Dec-2008

2005 IBM Corporation

IBM Global Services

Scheduling Job After Another Job


Job
Job
Scheduling
Scheduling

Start date

After Job

X Start status-depend.

After clicking on the After


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

If you check the Start status-depend.


option, this job will run only if the
specified job ends successfully.

11

Data Interfaces |

Dec-2008

2005 IBM Corporation

IBM Global Services

Scheduling Job After an Event

Start date

After Event

Job
Job
Scheduling
Scheduling

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 |

Dec-2008

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.

13

Data Interfaces |

The only required


exporting parameter is the
name of the event to raise.

Dec-2008

2005 IBM Corporation

IBM Global Services

Phases of Background Processing

Job
Job
Scheduling
Scheduling

Job
Job
Processing
Processing

Job
Job
Overview
Overview

14

Data Interfaces |

Dec-2008

2005 IBM Corporation

IBM Global Services

Processing a Background Job

Scheduler

Job
Job

Dispatcher

Job
Job

Background

Job
Job
Processing
Processing

15

Data Interfaces |

Dec-2008

2005 IBM Corporation

IBM Global Services

Processing a Background Job


Application
Application Server
Server
Work
Work Processes
Processes
8 Online

1 Spool

Job
Job
Processing
Processing

3 Background

Transaction
SM50

16

Data Interfaces |

Dec-2008

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

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

PRINT SPOOL

Job
Job
Processing
Processing

List
All WRITE
statement output
from job step.

End Module

17

Data Interfaces |

Dec-2008

2005 IBM Corporation

IBM Global Services

Phases of Background Processing

Job
Job
Scheduling
Scheduling

Job
Job
Processing
Processing

Job
Job
Overview
Overview

18

Data Interfaces |

Dec-2008

2005 IBM Corporation

IBM Global Services

Job Overview
Transaction
SM37

Job Status

Job
Job
Overview
Overview

Spool List

19

Data Interfaces |

Dec-2008

2005 IBM Corporation

IBM Global Services

Job Analysis Using Job Log


System and Program
Messages

Job
Job
Overview
Overview

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

20

Data Interfaces |

Dec-2008

2005 IBM Corporation

IBM Global Services

Job Analysis Using Job Spool

Display
Report

21

Data Interfaces |

Dec-2008

2005 IBM Corporation

IBM Global Services

Other Background Processing Topics

Scheduling Job within ABAP Program


Passing Data to Subsequent Job Steps

22

Data Interfaces |

Dec-2008

2005 IBM Corporation

IBM Global Services

Scheduling Job within ABAP Program


Open
Open Background
Background Job
Job
JOB_OPEN
JOB_SUBMIT is
called for each
step that is to be
added to the job

Insert
Insert Job
Job Step
Step
JOB_SUBMIT

Close
Close Background
Background Job
Job
JOB_CLOSE

23

Data Interfaces |

Dec-2008

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 |

Dec-2008

2005 IBM Corporation

IBM Global Services

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

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

25

Data Interfaces |

Background Job`
<job name>
<job #>

Step #1

Step #2

Dec-2008

2005 IBM Corporation

IBM Global Services

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

Background Job
<job name>
<job #>

Step #1
Importing:
job_was_released =
<flag2>

26

Data Interfaces |

Step #2

Dec-2008

2005 IBM Corporation

IBM Global Services

ABAP Program Example

Open
Open Job
Job

Submit
Submit Step
Step

Close
Close Job
Job

27

REPORT YDI00001.
DATA: JOBNUM TYPE JOBCOUNT.
PARAMETERS: JOBNAME TYPE JOBNAME,
PROGRAM TYPE REPID,
VARIANT TYPE VARIANT,
USER TYPE 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.

Data Interfaces |

Dec-2008

2005 IBM Corporation

IBM Global Services

Passing Data to Subsequent


Job Steps

DBTABLE
id1

data1

FILENAME

id2 data2

Background
Background Job
Job

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

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

28

Data Interfaces |

Dec-2008

2005 IBM Corporation

IBM Global Services

Passing Data to Subsequent


Job Steps (Contd.)

DBTABLE
id1

data1

FILENAME

id2 data2

Background
Background Job
Job

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

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

29

Data Interfaces |

Dec-2008

2005 IBM Corporation

IBM Global Services

Using the Database to Pass Data between Job Steps


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

INDX
MANDT RELID SRTFD

30

..

CLUSTR

CLUSTD

800

SP

SPH_I

254

FF05010102

800

12345

53

FF05016876

800

ST
ST

ABCL

73

800

TM

KVERM

97

FF05075372
FF03578902

Data Interfaces |

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

Dec-2008

2005 IBM Corporation

IBM Global Services

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


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

INDX
MANDT RELID SRTFD

31

..

CLUSTR

CLUSTD

800

SP

SPH_I

254

FF05010102

800

12345

53

FF05016876

800

ST
ST

ABCL

73

800

TM

KVERM

97

FF05075372
FF03578902

Data Interfaces |

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

Dec-2008

2005 IBM Corporation

IBM Global Services

Structure of the Data Cluster Table


Cluster
Length

Key fields to
uniquely identify
Data Cluster
Area
Client

Cluster
Data

INDX
MANDT RELID SRTFD

800
800
800
800

SP
ST
ST

SPH_I

TM

KVERM

12345
ABCL

SRTF2

0
0
0
0

... CLUSTR

CLUSTD

254 FF0501010254787
53 FF0501687618710
73 FF0507110005472
97 FF0357890541472

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 |

Dec-2008

2005 IBM Corporation

IBM Global Services

Structure of the Data Cluster Table (Contd.)


Cluster
Length

Key fields to
uniquely identify
Data Cluster
Area
Client

Cluster
Data

INDX
MANDT RELID SRTFD

800
800
800
800

SP
ST
ST

SPH_I

TM

KVERM

12345
ABCL

SRTF2

0
0
0
0

... CLUSTR

CLUSTD

254 FF0501010254787
53 FF0501687618710
73 FF0507110005472
97 FF0357890541472

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 |

Dec-2008

2005 IBM Corporation

IBM Global Services

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

34

Data Interfaces |

Dec-2008

2005 IBM Corporation

IBM Global Services

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

35

Data Interfaces |

Dec-2008

2005 IBM Corporation

IBM Global Services

Summary
Job
Job
Scheduling
Scheduling

Job
Job
Processing
Processing

Job
Job
Overview
Overview

Job Log
Step #1
Spool List

Step #2

Background

36

Data Interfaces |

Dec-2008

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 |

Dec-2008

2005 IBM Corporation

Vous aimerez peut-être aussi