Professional Documents
Culture Documents
How To Create Background Jobs in SAP Using SM36: Assumption
How To Create Background Jobs in SAP Using SM36: Assumption
SM36
Assumption
These steps are based on the assumption that you are familiar with
SAP BASIS technology and terminology for BASIS, Web AS (WAS) with
versions 610, 620, 640, 700 and 710 as well as SAP transaction codes
(SM36, SM37). Users should also know what are SAP Work Processes
specially Batch Work Process which are responsible to execute
Background Jobs in SAP.
Background
Batch jobs or Background Jobs are SAP programs (either Standard or
Custom programs) that run in the system without the user interaction
at a specified date/time which is given during the creation of the Jobs.
These jobs can be an ad-hoc job or can be run on a periodic basis
(daily, hourly, weekly, monthly and others) which is also specified
during the create step of the jobs. Any program(s) that you want to run
without any user interaction and/or at any time (periodic/non-periodic),
it is the best candidate for background job.
Some of the programs require user input before they can execute, and
if we are running the program in background (using background jobs)
we don’t want system to halt or wait for the input before it can
continue. To solve this issue we (usually developers) create a Variant
(which is an input value for the related program) and save this. While
creating/defining a background job we have to give the variant name
(if required) so the program can continue without user input and take
the values as given in the variant.
SAP Background jobs are created using transaction code SM36 and
monitored/changed using transaction code SM37. Background Jobs are
usually run after business hours as they are resource intensive and
also to avoid any business disruptions during the regular work hours.
Example:
A company may have written a program
(Z_SOME_PROGRAM_NAME) that collects all the shipment data
from their retail system database for the entire day and ships the
goods to the customer.
This program needs to be executed at a time when the regular
business hour is over hence a background job
(Z_SOME_JOB_NAME) needs to be created which can run
uninterrupted at a specified time or on periodic basis.
Important
Background Jobs are executed by SAP Batch Work Process. An SAP
System can be made of multiple SAP instances and each instance may
comprise one or many Batch Work Process. We have to make sure that
we keep that in mind when scheduling Background Jobs so we have
free batch work process to execute each Background Job.
Implementation Steps
1. Execute transaction SM36 to get to the initial screen of creating
Background job
2. Click on Button
3. Click on button
4. In the following screen enter the following details and click
Continue
a. Job Name : Z_FIRST_JOB (you can chose any name based
on your company’s naming convention policy)
b. Job Class : C – Low Priority (This is the default option)
c. TargetServer: If you want your background job to run on a
particular instance of SAP, select a value from drop down
else leave it blank
5. In our example we will be creating a background job for SAP
standard program (RSPFPAR), hence we will choose “ABAP
program step” as the option. Even if it is a custom program
(Z_ANY_NAME) you will still select “ABAP program step”. If you
want to execute an external OS command or an external
program outside of SAP, you will select the appropriate radio
button below.
Select “ABAP program step” and click Continue
6. Based on your select in step 5 above, you will get screen as
below where you will have to enter a program name (in our
example RSPFPAR) and the variant from drop down. Please
proceed with selecting the variant “Z_TEST_VAR” which we
created for this program and at the end of this tutorial, you will
see “How to create variants in SAP”.
15.To see the job that you created, you have to run transaction code
SM37 and enter the green check mark of hit the Enter key on
your keyboard
16. In the selection screen below, enter the Job name “Z_FIRST_JOB”
and user name as “*”. Select all the checkboxes and make sure
you select the From/To date appropriately (in our example case
we scheduled the job to run on 13th April, so the To date is
selected as “2009.04.13”. Click Execute
17.The resulting Job Overview screen shows that your job is in
Released status (Released means waiting for the date and time
to arrive so it can execute)
18.If you double click on the line (Z_FIRST_JOB) it will take you to
the details of the job which indicates Weekly and Start date and
time of the job.
Click Back to come to the Job Overview screen.
19. In our example we changed the date and time of the job as we
want to run it immediately to see the result (this is done just for
example purpose. You may however have a need to change job
date and time if there is a need from business).
From screen in step 17, select the line “Z_FIRST_JOB” and go to
menu option Job Change
22. As soon as we select Immediate we can see the job starts and
completes right away (the completion time of the job depends on
which program it is executing and how long the program runs
for).
24. Click the button to display the spool contents. Spool contents
are the actual content of the job
Background
RSPFPAR is a standard SAP program which shows all the system profile
parameters and their values. Since there are hundreds of system
parameters in the system, we may only have a need to see a few
parameter values. For this reason, we have to give input values in the
screen so the system can only pull out limited values based on our
selection. Since we have to execute this program in background we
want the system to pick the values from the variant that we create so
the Job can run un-interrupted without user interaction. In our example
we want to create variant for the following 3 system profile parameters
– ipc/shm_psize_40, rdisp/msserv and ztta/parameter_area. You
will see in a moment how to create this.
Implementation Steps
26.Execute transaction code SE38 from your initial SAP screen and
hit Enter on your keyboard
29. In this screen, enter the parameter names for which you would
like to see the values and click Execute button
30. You will be returned to the initial screen and this time there is a
value in the first text field; however the second text field is
blank. The green color in this button indicates that there are
values inside. You can click that button again to verify that your
parameters are specified correctly.
32. Now we want to see the same result in background mode without
user interaction. For this reason we will go back to the initial
screen as per step 5 by clicking the Back button and save the
screen input as variant by using menu option Goto Variants
Save as Variant
33. Give the variant name as Z_TEST_VAR and Meaning Variant for
Profile Parameters and click Save to save the screen.
34.You will be returned to the initial screen with this message in the
task bar