0% found this document useful (0 votes)
33 views51 pages

Zombie Job Cleanup in SAP Background Processing

The document outlines the concept of background processing in SAP, emphasizing its role in automating long-running tasks that do not require user interaction. It details the various states of background jobs, including Planned, Released, Ready, Active, Finished, and Cancelled, as well as the methods for scheduling these jobs based on immediate, time-based, or event-based conditions. Additionally, it provides insights into troubleshooting and the technical aspects of job scheduling within the SAP environment.

Uploaded by

James Jung
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views51 pages

Zombie Job Cleanup in SAP Background Processing

The document outlines the concept of background processing in SAP, emphasizing its role in automating long-running tasks that do not require user interaction. It details the various states of background jobs, including Planned, Released, Ready, Active, Finished, and Cancelled, as well as the methods for scheduling these jobs based on immediate, time-based, or event-based conditions. Additionally, it provides insights into troubleshooting and the technical aspects of job scheduling within the SAP environment.

Uploaded by

James Jung
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

Background Processing

SAP AGS China


August 2015

INTE
RNA
L
Agenda

• Concept of Background processing


• States of Background Jobs
• Scheduling background job
• Troubleshooting

© 2015 SAP AG. All rights reserved. Customer 2


Concept of Background processing

Objective:
- Reports and transactions doesn’t run only for short time (Not run online)
- Long running tasks are to be performed that do not require user interaction
(SAP dialog dispatching)

SAP background processing automates routine tasks and helps you


optimize your organizations SAP computing resources.

© 2015 SAP AG. All rights reserved. Customer 3


States of Background Jobs

Planned

Released

Ready

Active

Finished Cancelled

© 2015 SAP AG. All rights reserved. Customer 4


States of Background Jobs

Planned
Steps that make up the job have already been defined, but the Planned

start condition has not yet been defined.

Released Released

The job has been fully defined, including a start condition.


Without a start condition, a job cannot be released.
Only an administrator or a user with appropriate authorizations Ready
for background processing can release a job, preventing
unauthorized users from running jobs without approval.
Active
Ready
The start condition of a released job has been met. A job
scheduler has put the job in line to wait for an available Finished Cancelled
background work process.

© 2015 SAP AG. All rights reserved. Customer 5


States of Background Jobs

Finished
All steps that make up this job have completed successfully. Planned

Canceled
Released
The job has terminated abnormally. This can happen in two
ways:
• An administrator intentionally terminates a job with Ready
Transaction SM37:
Job > Cancel active job
• A job step contains a program that produces an error, e.g. Active
an E or A error message in an ABAP program.

Finished Cancelled

© 2015 SAP AG. All rights reserved. Customer 6


Scheduling background job
Overview

We have to distinguish several cases and subcases, because the method of starting
a batch job depends on the type of the start condition of the job.

Technically, there are three different types of start conditions:


• Immediate start
• Time based start
• Event based start

For each type of start condition there is a technically different method of starting a
job, and each such method has its algorithm of distributing the batch jobs (without
target server) to the batch servers.

© 2015 SAP AG. All rights reserved. Customer 7


Scheduling background job
SAP Background processing ABAP program

SAPMSSY2 contains all system modules for batch scheduling


and job starting

Screen Short Description


4004 Initial Screen for Time-Driven Job Scheduler
4005 Initial Screen for Job Execution
4006 Initial Screen for Zombie Job Cleanup
4007 Initial Screen for Event-Driven Job Scheduler
4008 Initial Screen for Scheduler Extensions
4009 Auto-Deletion of a Job
4010 Operation Mode Switching

© 2015 SAP AG. All rights reserved. Customer 8


Scheduling background job
(1) Immediate start batch job

Start immediately when the job released.

In the case of an immediate start, the batch job may possibly be scheduled directly
in the context of the function call that created the entry in database table TBTCO,
without involvement of the actual batch scheduler.

Logic :

An attempt is made to find a suitable server instance that has a free batch work
process.

If such a server is found, BTC request is directly submitted to that server instance
so that the job can run immediately.

If there is no free work process, it changed to time based started job (start time =
system time)

© 2015 SAP AG. All rights reserved. Customer 9


Scheduling background job
(1) Immediate start batch job

1.) Create immediate start batch


Immediate start job
batch job

© 2015 SAP AG. All rights reserved. Customer 10


Scheduling background job
(1) Immediate start batch job

1.) Create immediate start batch


Immediate start job
batch job TBTCO
2.) Store the job in TBTCO (batch
job header) table

© 2015 SAP AG. All rights reserved. Customer 11


Scheduling background job
(1) Immediate start batch job

1.) Create immediate start batch


Immediate start job
batch job TBTCO
2.) Store the job in TBTCO (batch
job header) table
3.) Find free batch resources
Free BTC WPs?

Server 1 Server N
BTC BTC …… BTC BTC
Free Free Free Run

© 2015 SAP AG. All rights reserved. Customer 12


Scheduling background job
(1) Immediate start batch job

1.) Create immediate start batch


Immediate start job
batch job TBTCO
2.) Store the job in TBTCO (batch
job header) table
3.) Find free batch resources
4-1.) BTC request is directly
submitted to that server instance

Server 1 Server N
BTC BTC …… BTC BTC
Run Free Free Run

Run the batch job

© 2015 SAP AG. All rights reserved. Customer 13


Scheduling background job
(1) Immediate start batch job

1.) Create immediate start batch


Immediate start job
batch job TBTCO
2.) Store the job in TBTCO (batch
job header) table
3.) Find free batch resources
Free BTC WPs? 4-1.) BTC request is directly
submitted to that server instance
4-2.) If there is no free work
Server 1 Server N process,
BTC BTC …… BTC BTC
Run Run Run Run

© 2015 SAP AG. All rights reserved. Customer 14


Scheduling background job
(1) Immediate start batch job

1.) Create immediate start batch


Time-based job
batch job TBTCO
2.) Store the job in TBTCO (batch
job header) table
3.) Find free batch resources
4-1.) BTC request is directly
submitted to that server instance
4-2.) If there is no free work
Server 1 Server N process,
BTC BTC …… BTC BTC 5.) it changed to time based
started job (start time = system
Run Run Run Run time)

© 2015 SAP AG. All rights reserved. Customer 15


Scheduling background job
(2) Time-based batch scheduler

Time-based batch job has a start date and start time as start condition.

On every server instance that has at least one batch work process, the time based
batch scheduler runs every rdisp/btctime seconds or immediate after a batch job
has been finished.

Logic :

When you get time-based batch job request, it will update to TBTCO table.

Dispatcher triggers batch scheduler every rdisp/btctime. Batch scheduler is ABAP


program which is run in dialog work processor.

Batch scheduler check any batch job in TBTCO table, and request it to Batch work
processor.

© 2015 SAP AG. All rights reserved. Customer 16


Scheduling background job
(2) Time-based batch scheduler

Disp. Request Queues


Dispatcher NOWP 1.) internal Dispatcher Loop

DIA

Port 32xx BTC

DIA 0 DIA 1 BTC 10

Job Status

Released

© 2015 SAP AG. All rights reserved. Customer 17


Scheduling background job
(2) Time-based batch scheduler

Disp. Request Queues


Dispatcher NOWP 1.) internal Dispatcher Loop

DIA 1 2.) DIA request for sapmssy2


every rdisp/btctime
Port 32xx BTC

DIA 0 DIA 1 BTC 10

Job Status

Released

© 2015 SAP AG. All rights reserved. Customer 18


Scheduling background job
(2) Time-based batch scheduler

Disp. Request Queues


Dispatcher NOWP 1.) internal Dispatcher Loop

DIA 2.) DIA request for sapmssy2


every rdisp/btctime
Port 32xx BTC
3.) sapmssy2 as a job scheduler
(time-scheduler)

DIA 0 DIA 1 BTC 10


sapmssy2

Job Status
3
Released

© 2015 SAP AG. All rights reserved. Customer 19


Scheduling background job
(2) Time-based batch scheduler

Disp. Request Queues


Dispatcher NOWP 1 1.) internal Dispatcher Loop

DIA 2.) DIA request for sapmssy2


every rdisp/btctime
Port 32xx BTC
3.) sapmssy2 as a job scheduler
(time-scheduler)
4.) NOWP request to dispatcher

DIA 0 DIA 1 BTC 10


sapmssy2

Job Status
4
Ready

© 2015 SAP AG. All rights reserved. Customer 20


Scheduling background job
(2) Time-based batch scheduler

Disp. Request Queues


Dispatcher NOWP 1 1.) internal Dispatcher Loop

DIA 2.) DIA request for sapmssy2


every rdisp/btctime
Port 32xx BTC
3.) sapmssy2 as a job scheduler
(time-scheduler)
4.) NOWP request to dispatcher
5.) Notify Dispatcher

DIA 0 DIA 1 BTC 10


sapmssy2

Job Status
5
Ready

© 2015 SAP AG. All rights reserved. Customer 21


Scheduling background job
(2) Time-based batch scheduler

Disp. Request Queues


Dispatcher NOWP 1.) internal Dispatcher Loop

DIA 2.) DIA request for sapmssy2


every rdisp/btctime
Port 32xx BTC 1
3.) sapmssy2 as a job scheduler
6 (time-scheduler)
4.) NOWP request to dispatcher
5.) Notify Dispatcher
6.) forward to BTC queue

DIA 0 DIA 1 BTC 10

Job Status

Ready

© 2015 SAP AG. All rights reserved. Customer 22


Scheduling background job
(2) Time-based batch scheduler

Disp. Request Queues


Dispatcher NOWP 1.) internal Dispatcher Loop

DIA 2.) DIA request for sapmssy2


every rdisp/btctime
Port 32xx BTC 1
3.) sapmssy2 as a job scheduler
7 (time-scheduler)
4.) NOWP request to dispatcher
5.) Notify Dispatcher
6.) forward to BTC queue
7.) dispatches BTC request

DIA 0 DIA 1 BTC 10

Job Status

Ready

© 2015 SAP AG. All rights reserved. Customer 23


Scheduling background job
(2) Time-based batch scheduler

Disp. Request Queues


Dispatcher NOWP 1.) internal Dispatcher Loop

DIA 2.) DIA request for sapmssy2


every rdisp/btctime
Port 32xx BTC
3.) sapmssy2 as a job scheduler
(time-scheduler)
4.) NOWP request to dispatcher
5.) Notify Dispatcher
6.) forward to BTC queue
7.) dispatches BTC request
8.) sapmssy2 as job/starter
DIA 0 DIA 1 BTC 10
sapmssy2

Job Status
8
Active

© 2015 SAP AG. All rights reserved. Customer 24


Scheduling background job
(2) Time-based batch scheduler

Disp. Request Queues


Dispatcher NOWP 1.) internal Dispatcher Loop

DIA 2.) DIA request for sapmssy2


every rdisp/btctime
Port 32xx BTC
3.) sapmssy2 as a job scheduler
(time-scheduler)
4.) NOWP request to dispatcher
5.) Notify Dispatcher
6.) forward to BTC queue
7.) dispatches BTC request
8.) sapmssy2 as job/starter
DIA 0 DIA 1 BTC 10
9.) Batch Job execution
BTC Job

Job Status
9
Active

© 2015 SAP AG. All rights reserved. Customer 25


Scheduling background job
(2) Time-based batch scheduler

Disp. Request Queues


Dispatcher NOWP 1.) internal Dispatcher Loop

DIA 2.) DIA request for sapmssy2


every rdisp/btctime
Port 32xx BTC
3.) sapmssy2 as a job scheduler
(time-scheduler)
4.) NOWP request to dispatcher
5.) Notify Dispatcher
6.) forward to BTC queue
7.) dispatches BTC request
8.) sapmssy2 as job/starter
DIA 0 DIA 1 BTC 10
9.) Batch Job execution
10.) Batch job finishes

Job Status
10 Finished/
Cancelled

© 2015 SAP AG. All rights reserved. Customer 26


Scheduling background job
(3) Event-based batch scheduler

An event based batch job has a batch event as start condition. The start con-
dition is fulfilled, when the event is triggered.
Whenever an event is triggered, the event scheduler is started and start all
jobs, which have been waiting for this event.

Case 1 : the event has been triggered (directly or via some indirections) by the func-
tion module BP_EVENT_RAISE.

Case 2 : The event has been triggered by the C-program sapevt.


SAP delivers the program sapevt as a standalone executable with the kernel, and it
can trigger an event in an SAP system from a remote machine. This remote ma-
chine does not even have to be part of an SAP system.

Case 3: When the event SAP_END_OF_JOB has been triggered

If there is no resources for event-based batch job, the job changed to time-based
job.

© 2015 SAP AG. All rights reserved. Customer 27


Scheduling background job
(3) Event-based batch scheduler – event SAP_END_OF_JOB triggered

Disp. Request Queues


Dispatcher NOWP 1.) internal Dispatcher Loop

DIA

Port 32xx BTC

DIA 0 DIA 1 BTC 10

Job Status

Released

© 2015 SAP AG. All rights reserved. Customer 28


Scheduling background job
(3) Event-based batch scheduler – event SAP_END_OF_JOB triggered

Disp. Request Queues


Dispatcher NOWP 1.) internal Dispatcher Loop

DIA 1 2.) DIA request for sapmssy2

Port 32xx BTC

DIA 0 DIA 1 BTC 10

Job Status

Released

© 2015 SAP AG. All rights reserved. Customer 29


Scheduling background job
(3) Event-based batch scheduler – event SAP_END_OF_JOB triggered

Disp. Request Queues


Dispatcher NOWP 1.) internal Dispatcher Loop

DIA 2.) DIA request for sapmssy2

BTC 3.) sapmssy2 as a job scheduler


Port 32xx

DIA 0 DIA 1 BTC 10


sapmssy2

Job Status
3 Released

© 2015 SAP AG. All rights reserved. Customer 30


Scheduling background job
(3) Event-based batch scheduler – event SAP_END_OF_JOB triggered

Disp. Request Queues


Dispatcher NOWP 1 1.) internal Dispatcher Loop

DIA 2.) DIA request for sapmssy2

BTC 3.) sapmssy2 as a job scheduler


Port 32xx
4.) NOWP request to dispatcher

DIA 0 DIA 1 BTC 10


sapmssy2

Job Status
4 Ready

© 2015 SAP AG. All rights reserved. Customer 31


Scheduling background job
(3) Event-based batch scheduler – event SAP_END_OF_JOB triggered

Disp. Request Queues


Dispatcher NOWP 1 1.) internal Dispatcher Loop

DIA 2.) DIA request for sapmssy2

BTC 3.) sapmssy2 as a job scheduler


Port 32xx
4.) NOWP request to dispatcher
5.) Notify Dispatcher

DIA 0 DIA 1 BTC 10


sapmssy2

Job Status
5 Ready

© 2015 SAP AG. All rights reserved. Customer 32


Scheduling background job
(3) Event-based batch scheduler – event SAP_END_OF_JOB triggered

Disp. Request Queues


Dispatcher NOWP 1.) internal Dispatcher Loop

DIA 2.) DIA request for sapmssy2

BTC 1 3.) sapmssy2 as a job scheduler


Port 32xx
4.) NOWP request to dispatcher
6
5.) Notify Dispatcher
6.) Forward to BTC queue

DIA 0 DIA 1 BTC 10

Job Status

Ready

© 2015 SAP AG. All rights reserved. Customer 33


Scheduling background job
(3) Event-based batch scheduler – event SAP_END_OF_JOB triggered

Disp. Request Queues


Dispatcher NOWP 1.) internal Dispatcher Loop

DIA 2.) DIA request for sapmssy2

BTC 1 3.) sapmssy2 as a job scheduler


Port 32xx
4.) NOWP request to dispatcher

7 5.) Notify Dispatcher


6.) Forward to BTC queue
7.) dispatches BTC request

DIA 0 DIA 1 BTC 10

Job Status

Ready

© 2015 SAP AG. All rights reserved. Customer 34


Scheduling background job
(3) Event-based batch scheduler – event SAP_END_OF_JOB triggered

Disp. Request Queues


Dispatcher NOWP 1.) internal Dispatcher Loop

DIA 2.) DIA request for sapmssy2

BTC 3.) sapmssy2 as a job scheduler


Port 32xx
4.) NOWP request to dispatcher
5.) Notify Dispatcher
6.) Forward to BTC queue
7.) dispatches BTC request
8.) sapmssy2 as job/starter

DIA 0 DIA 1 BTC 10


sapmssy2

Job Status

8 Active

© 2015 SAP AG. All rights reserved. Customer 35


Scheduling background job
(3) Event-based batch scheduler – event SAP_END_OF_JOB triggered

Disp. Request Queues


Dispatcher NOWP 1.) internal Dispatcher Loop

DIA 2.) DIA request for sapmssy2

BTC 3.) sapmssy2 as a job scheduler


Port 32xx
4.) NOWP request to dispatcher
5.) Notify Dispatcher
6.) Forward to BTC queue
7.) dispatches BTC request
8.) sapmssy2 as job/starter
9.) steps executed

DIA 0 DIA 1 BTC 10


steps
Different

Job Status

9 Finished/
Canceled

© 2015 SAP AG. All rights reserved. Customer 36


Scheduling background job
(3) Event-based batch scheduler – event SAP_END_OF_JOB triggered

Disp. Request Queues


Dispatcher NOWP 1.) internal Dispatcher Loop

DIA 2.) DIA request for sapmssy2

BTC 3.) sapmssy2 as a job scheduler


Port 32xx
4.) NOWP request to dispatcher
5.) Notify Dispatcher
6.) Forward to BTC queue
7.) dispatches BTC request
8.) sapmssy2 as job/starter
Event
9.) steps executed
SAP_END_OF_JOB
10.) event scheduler request
DIA 0 DIA 1 BTC 10
finished
steps
Different

Event-driven Job Status


10
Released

© 2015 SAP AG. All rights reserved. Customer 37


Scheduling background job
(3) Event-based batch scheduler – event SAP_END_OF_JOB triggered

Disp. Request Queues


Dispatcher NOWP 1.) internal Dispatcher Loop

DIA 1 2.) DIA request for sapmssy2


11
BTC 3.) sapmssy2 as a job scheduler
Port 32xx
4.) NOWP request to dispatcher
5.) Notify Dispatcher
6.) Forward to BTC queue
7.) dispatches BTC request
8.) sapmssy2 as job/starter
9.) steps executed
10.) event scheduler request
DIA 0 DIA 1 BTC 10
11.) DIA request for event scheduler

Event-driven Job Status

Released

© 2015 SAP AG. All rights reserved. Customer 38


Scheduling background job
(3) Event-based batch scheduler – event SAP_END_OF_JOB triggered

Disp. Request Queues


Dispatcher NOWP 1.) internal Dispatcher Loop

DIA 2.) DIA request for sapmssy2


12 3.) sapmssy2 as a job scheduler
Port 32xx BTC
4.) NOWP request to dispatcher
5.) Notify Dispatcher
6.) Forward to BTC queue
7.) dispatches BTC request
8.) sapmssy2 as job/starter
9.) steps executed
10.) event scheduler request
DIA 0 DIA 1 BTC 10
11.) DIA request for event scheduler
scheduler
Event

12.) execute event scheduler

Event-driven Job Status


Released

© 2015 SAP AG. All rights reserved. Customer 39


Scheduling background job
(4) Additional : Dynamic time-based batch scheduler

Note 923228 - Background job sched.: using processes that have become free

If the time scheduler runs every


60 seconds on each server (de-
fault behaviour) and if there are
many short running jobs in the
system, which have runtime of
only a few seconds.

Each time when the event


scheduler processes the event
SAP_END_OF_JOB, it starts
(after processing this event) the
time scheduler.

© 2015 SAP AG. All rights reserved. Customer 40


Scheduling background job
(4) Additional : Dynamic time-based batch scheduler

Disp. Request Queues


Dispatcher NOWP 1.) 1st Batch job finishes

DIA

Port 32xx BTC

DIA 0 DIA 1 BTC 10


Batch job

© 2015 SAP AG. All rights reserved. Customer 41


Scheduling background job
(4) Additional : Dynamic time-based batch scheduler

Disp. Request Queues


Dispatcher NOWP 1.) 1st Batch job finishes

DIA 2.) Raise SAP_END_OF_JOB

BTC event and event scheduler


Port 32xx
requested

Event
SAP_END_OF_JOB
DIA 0 DIA 1 BTC 10
finished
Batch job

© 2015 SAP AG. All rights reserved. Customer 42


Scheduling background job
(4) Additional : Dynamic time-based batch scheduler

Disp. Request Queues


Dispatcher NOWP 1.) 1st Batch job finishes

DIA 1 2.) Raise SAP_END_OF_JOB


3
BTC event and event scheduler
Port 32xx
requested
3.) DIA request for event scheduler

DIA 0 DIA 1 BTC 10

© 2015 SAP AG. All rights reserved. Customer 43


Scheduling background job
(4) Additional : Dynamic time-based batch scheduler

Disp. Request Queues


Dispatcher NOWP 1.) 1st Batch job finishes

DIA 2.) Raise SAP_END_OF_JOB

BTC event and event scheduler


Port 32xx
requested
3.) DIA request for event scheduler
4.) Execute event scheduler

DIA 0 DIA 1 BTC 10


scheduler
Event

© 2015 SAP AG. All rights reserved. Customer 44


Scheduling background job
(4) Additional : Dynamic time-based batch scheduler

Disp. Request Queues


Dispatcher NOWP 1.) 1st Batch job finishes

DIA 2.) Raise SAP_END_OF_JOB

BTC event and event scheduler


Port 32xx
requested
3.) DIA request for event scheduler
4.) Execute event scheduler
5.) Execute time-based scheduler

DIA 0 DIA 1 BTC 10


scheduler
time

© 2015 SAP AG. All rights reserved. Customer 45


Scheduling background job
(4) Additional : Dynamic time-based batch scheduler Dynamic
time-scheduler trace log

Disp. Request Queues


Dispatcher NOWP 1.) 1st Batch job finishes

DIA 2.) Raise SAP_END_OF_JOB

BTC event and event scheduler


Port 32xx
requested
3.) DIA request for event scheduler
4.) Execute event scheduler
5.) Execute time-based scheduler
6.) Execute 2nd time-based job

DIA 0 DIA 1 BTC 10


Batch job

© 2015 SAP AG. All rights reserved. Customer 46


Troubleshooting

Check point :
- Batch job does not run and stay state in “Released”, “Ready”, or “Canceled”

Analysis tools :
- SM37 : Background job overview
- SM65 : Background healthy check

Detail troubleshooting guide :


[Link]
d3a/[Link]

© 2015 SAP AG. All rights reserved. Customer 47


Troubleshooting

SM37 shows batch job status


• Released – check batch scheduler or batch jobs
• Ready – check batch request queue is overflowed
• Canceled – check ST22 (ABAP runtime error)

© 2015 SAP AG. All rights reserved. Customer 48


Troubleshooting

SM65 tests external program execution and check profile parameters

© 2015 SAP AG. All rights reserved. Customer 49


Troubleshooting
OCC simulator exercises

Batch job status in “released” : 4, 5, 10, 20

Batch job status in “canceled” : 11, 12

Batch job status in “ready” : 24

© 2015 SAP AG. All rights reserved. Customer 50


Thank You!

You might also like