Professional Documents
Culture Documents
Background Job Scheduling in SAP
Background Job Scheduling in SAP
Background Job Scheduling in SAP
by
Samik Ghosh
Content
Batch Job Scheduling in SAP Step by Step Process to schedule Batch Job (With Screenshots)
Scheduling Jobs Specifying Job Start Conditions Job Start Management Periodicity: Specifying Automatic Job Repetition Managing Jobs from the Job Overview Jobs and Job Steps
Introduction
Background jobs are definitions of programs, printing specification, and interactively can be run automatically by the SAP background processing system. Any program that you can start interactively can be run automatically by the SAP system in the Background jobs. In background processing the system automatically runs the specified program or report at a specified and schedule time without the intervention of the user; even if you can monitor the background job and display results. Whenever you log on to the SAP System to perform any task, the R/3 System starts responding. SAP System can be operated in both interactive mode as well as non-interactive mode. In the non-interactive mode you can schedule execution of programs and reports that you need to run without further intervention by you. This mode of working is named Background Processing. Sophisticate support for the background processing is provided by the SAP System. One can execute both internal and external programs of the SAP system. You can perform variety of jobs like choosing a variety of methods for scheduling and managing the jobs offer by the SAP System. For ease of access of scheduling and management, within a single background processing job one can execute similar related programs as "job steps;" this allows the single background job to become more complex and have multiple steps. The system has a number of sophisticated tools for managing jobs and diagnosing problems that occur during the runtime, including a graphic monitor and a powerful and easy-to-use job programming interface for developing your own background-processing applications. The system also provides job scheduling wizard automates basic background job definition.
Background Scheduling
To have an idea about the background scheduling let us take an example of a long report. Suppose we execute this report in interactive mode, it takes several minutes and during time the SAP System is blocked for any further input. As a result, you will not be able to interact with SAP sessions anymore. However, when you run the report non-interactively, you can interact with the SAP sessions while processing the report in the background. For executing jobs in non-interactive mode, schedule the job for background processing. SAP system does not require users intervention and can proceed with the job even without you. It executes the report and prints the output using printer or output controller. While scheduling a job in background process, three parameters should be specified. These parameters are:
Page 2
Batch Job Scheduling in SAP Definition of programs Its start time The printing specification for getting the prints as required After this, you can check whether your job was executed successfully and display a log of any system messages. Scheduling background processing is a two-step process: Scheduling the program Releasing the job This needs to have a special authorization for releasing and scheduling the job. Generally, the system administrator, who organizes and monitors background processing, supervises the release of these jobs. Many users are also authorized to schedule background processing of reports. You cannot schedule a job unless and until you have a release authorization. If a user is authorized and has specified a start date or selected "start immediately," he or she can release the job. Authorized users can change start time. A program can be scheduled as a separate job or you can append it to an existing job, which has not yet been processed. Background process can be run while doing some other online work. However, this can adversely affect online operation and should be avoided. For example, if you run a program that locks the database, the work of online users will be hampered or stopped. Often, long-running reports are scheduled automatically or semi-automatically for background processing. First Step Initiate the job scheduling function. Standard job scheduling must be used in case of scheduling of an external command or external program as a background job and ABAP job scheduling function can be used to schedule ABAP programs. For starting a standard job scheduling function choose the following: Administration menu bar option->CCMS option->Jobs option->Definition option. For starting ABAP job scheduling function, navigate to ABAP Editor and choose Program menu bar option->Execute option->Background option. Second Step Now define a job. Using the Job Wizard you can define your job. From the Application toolbar, choose the wizard button. After this, the initial screen of the SAP Job Wizard appears. The Job Wizard is available only from the standard job scheduling function.
Page 3
Batch Job Scheduling in SAP Third Step Now, you have to save the job. When it displays the message "Job saved" it means the job has been successfully scheduled. We know that a job must be released before it is scheduled. Only authorized users can release the job, otherwise your system administrator will release your job. Fourth Step This is the last step of scheduling. In this step you have to check the status of your job. For this you need to choose System menu bar option>Own jobs option.
Page 4
Batch Job Scheduling in SAP System menu bar option->User profile option->User defaults option for displaying these options. Now you can either execute immediately (using Execute immediate) or schedule the job (using Schedule) at some specified date and time. You can also specify your job to be restarted periodically. To access the more complete function choose Goto option->Define job.
Specifying a Recipient
For specifying a recipient, select Spool lists recipient option and Execute Enter button from the initial screen. A dialog box gets displayed. In the Recipient field, enter a user's SAP office mail name, a SAP office distribution list, a SAP user ID, or an external e-mail address. If desired, activate the mailing options. The recipient receives all spool requests generated by the job. If you want to save the recipient, choose Copy.
Batch Job Scheduling in SAP ABAP program or external program can be specified to be run in the background. More than one program can be executed with a single background job. To do it you should add a job step for each program. The Users field will, by default, display your name, indicating that the user (you) is authorized to run this program. In case there is another user authorized for scheduling the job, then the default name is changed and system displays the name of the other user. Now choose ABAP and enter the name of the report. Choose variant from the Variant list. Specify the language you want the report to be in. With Print specifications, you can specify whether you want the report output to be held in the SAP spool system or have it printed as soon as the job has run. For external command, by default, the job step will run under your SAP System authorizations. So your name will appear in the User field. But if the program is running under the authorization of another user, you can change this default option by entering another user name. Then choose External command and enter the predefined SAP name. If required, enter any additional arguments required for the command. The host system on which the command should run and the type of operating system at the host should be specified. You can determine the host name using the host name command on the target host system. You can also specify how the output from the external program should be treated, as well as other runtime options by using Control flags. It is advisable to use default settings for these options. If you are authorized for background processing, you can also choose External programs as a job step option. To run an external program, enter the exact path, program or script name, arguments required by the program, and the name of the host system on which the program is to run. After this, save the job step and return to the job identification screen.
Job Scheduling
Before any background processing can actually begin, background jobs must be defined and scheduled. The scheduled time for a job runs is one part of the jobs definition. There are several ways to schedule jobs: From Transaction SM36 (Define Background Job) Created by: Samik Ghosh Page 6
With the "start program in the background" option of either Transaction SA38 (ABAP: Execute Program) or transaction SE38 (the ABAP editor). Through the background processing systems own programming interface (Many SAP applications use the internal programming interface to schedule long-running reports for background processing). Through an external interface.
Page 7
Steps:
Call Transaction SM36 or choose CCMS Jobs DefinitionAssign a job name. Decide on a name for the job you are defining and enter it in the Job Name field.
Page 8
Set the jobs priority, or Job Class: 1. 2. High priority: Class A Medium priority: Class B
3. Low priority: Class C In the Target server field, indicate whether to use system load balancing.
Server name
Name of an SAP instance at which a background job should be run. The name has the following format: <host name>_<SAP System name>_<SAP System number>, where host name is the name of the server computer on which the instance is running, as specified in the system profile parameter SAPLOCALHOST. The name of each instance is specified in the system profile parameter rdisp/myname. Example: hs0123_C11_55 In programming: As the table field EXECSERVER, shows the target instance selected by the user for running a job. As the table field REAXSERVER, shows the SAP instance at which a job was actually run.
1. For the system to use system load balancing to automatically select the most efficient application server to use at the moment, leave this field empty.
Page 9
Batch Job Scheduling in SAP 2. To use a particular application server to run the job, enter a specific target server. If spool requests generated by this job are to be sent to some one as email, specify the email address. Choose the Spool list recipient button.
Define when the job is to start by choosing Start Condition and completing the appropriate selections. If the job is to repeat, or be periodic, check the box at the bottom of this screen.
Define the jobs steps by choosing Step, then specify the ABAP program, external command, or external program to be used for each step.
Page 10
Save the fully defined job to submit it to the background processing system.
When you need to modify, reschedule, or otherwise manipulate a job after you've scheduled it the first time, you'll manage jobs from the Job Overview.
Page 11
Release the job so that it can run. No job, even those scheduled for immediate processing, can run without first being released.
Page 12
Procedure
1. Choose the Start condition button at the top of the Define Background Job screen. 2. Choose the button at the top of the Start Time screen for the type of start condition you want to use (Immediate, Date/Time, After job, After event, or At operation mode) and complete the start time definition in the screen that appears.
Page 13
3. For the job to repeat, check the Periodic job box at the bottom of the Start Time screen and choose the Period values button below it to define the frequency of repetition (hourly, daily, weekly, monthly, or another specific time-related period). Then choose the Save button in the Period values screen to accept the periodicity and return to the Start Time screen. 4. Once youve completed specifying the job start conditions, choose the Save button at the bottom of the Start Time screen to return to the Define Background Job screen. No job can be started until it is released, including jobs scheduled to start immediately. Since releasing jobs can be done only by a system administrator from the job management screen (Transaction SM37) or by other users who have been granted the appropriate Authorizations for Background Processing, no unauthorized user can start a job without explicit permission.
Page 14
Page 15
Batch Job Scheduling in SAP which will automatically and immediately release any job scheduled by that user. Job Start Conditions:
Explanation
This job will start as soon as possible, subject to job priority and the availability of background work processes. Users granted the appropriate authorizations for background processing can have their jobs released automatically as soon as they are scheduled, without special attention from a system administrator. The job will start at the date and time specified, subject to job priority and the availability of background work processes. You can further define a timeframe in which the job will run by specifying a time later than which a job will not run. One use of this feature is to prevent periodic jobs from running when they should not. For example, a routine clean-up job scheduled to run only at night is delayed. By defining a start-time window, you will keep this job from being started during the day, when dialog users are active and fewer system resources are available. The job will start on the completion of the specified job. You can specify whether the preceding job must complete successfully or not. Note: Jobs scheduled to start when a preceding job completes cannot be specified as "Periodic jobs". The job is triggered by the specified event, descriptions of which follow. This start condition lets you define a sequence of individual jobs to model complex activities in your system. For example, a data transfer program that generates a batch-input session can, once the session has been completely generated, use an event to trigger another job that processes the session. The job will start when the specified operation mode becomes active in the SAP System.
Date/time
After Job
After Event
At operation mode
Workday/Time (>>) The job will start on the specified day of the month (for example, the third to last day of the month). By specifying the appropriate SAP factory calendar,
Page 16
Batch Job Scheduling in SAP your scheduling can accommodate the occurrence of holidays or other non-workdays. You can further specify how the job should be handled if the start day lands on a non-working day. For example, you can have the job started on the workday before or after the actual scheduled date, or allow the job run in anyway, or have the job be skipped on that day entirely. Verify that the calendar you choose has been correctly defined. If, for example, the calendar ends with the current year and your job is to be started next year, the job will terminate abnormally. If a calendar problem occurs, you can review systems error messages in the job log of the terminated job.
Periodicity: Repetition
Specifying
Automatic
Job
To run your job not only at a particular time, but also to repeat it at regular intervals, you can specify a periodicity, or frequency of repetition. This can be specified in Define Background Job in Transaction SM36 (CCMS Jobs Definition). Start the process of specifying when the job will start by choosing the Start condition button. Choose the button at the top of the Start Time screen for the type of start condition you want to use (Immediate, Date/Time, After job, After event, or At operation mode) and complete the start time definition. For the job to repeat, check the Periodic job box at the bottom of the Start Time screen and choose the Period values button below it to define the frequency of repetition (hourly, daily, weekly, monthly, or another specific time-related period). Choose the Save button in the Period values to accept the periodicity and return to the Start Time screen. When a periodic jobs start time is After event, the system repeats the job every time the relevant event is triggered.
Page 17
A periodic-job series is not interrupted if one of the jobs terminates abnormally. The background processing alert monitor warns you if any jobs abort, but if the job was not executed at all, there will be no following job.
Page 18
Batch Job Scheduling in SAP repeatable job to run between 10:00pm and 6:00am does not guarantee that the job will be repeated only within this time period. Rather, the full start-time window will be applied to all of the repetitions of the job according to the rules above. For example, you schedule a job to run between 10:00 this evening and 6:00 tomorrow morning and to be repeated every hour. The job will be triggered to repeat only after it has started the first time. At 10:00, the job starts. At the same time, the system schedules it again for 11:00. The starttime window for the job has been adjusted to 11:00 and 7:00. As the system schedules each repeated job, it adjusts the start-time window to remain the length you specified. The repeat job for 1:00am, for example, will have a start time window of 1:00 to 9:00. To limit the job to the time period between 10:00 and 6:00, you could define a job that schedules separate jobs to run each hour from 10:00 to 6:00. None of the jobs should be periodic. To limit an automatically repeated job to a particular time window, youll need to write a program yourself to schedule the jobs. Your program could schedule a separate job for each repetition that falls within the time period.
Page 19
Batch Job Scheduling in SAP To repeat a single job, choose Job->Repeat scheduling. To debug an active job, choose Job ->Capture: active job. Only a single selection is allowed. If an active job seems to be running incorrectly (e.g., running for an excessively long time), you can interrupt and analyze it in debugging mode in a background process, and then either release it again or stop it altogether. You will be able to capture a background job only if you are logged on to the SAP server on which the job is running. To find server information in the Job Overview, select and mark the job, then choose Job->Job details. To review information about a job, choose Job ->Job details. Details displayed can include: current job status periodicity, or the repetition interval other jobs linked to the current job, either as previous or subsequent jobs defined job steps spool requests generated by the current job To cancel a job's "Released" status, select the job or jobs from the Job Overview list and choose Job ->Release -> Scheduled. To cancel a job from running but keep the job definition available, select the job or jobs from the Job Overview list and choose Job ->Cancel active job. To delete a job entirely, select the job or jobs from the Job Overview list and choose Job ->Delete. Jobs with the status of Ready or Running cannot be deleted. To compare the specifications of more than one job, select the jobs from the Job Overview list and choose Job->Compare jobs. To check the status of jobs, select the job or jobs from the Overview Job list and choose Job->Check status. This allows you to either change the job status back to Planned or cancel the job altogether. This is especially useful when a job has malfunctioned. To review job logs, select a job or jobs with the status Completed or Canceled from the Job Overview list and choose Go to ->Job log. To release a job so it can run, select a job from the Job Overview list and choose Go to ->Release.
Page 20
Batch Job Scheduling in SAP To ensure that you can flexibly run individual programs, you can set important attributes individually for each job step, too. Each job step can: have its own spool, or output, specifications run under the authorizations of a separate user use a different language have its own runtime options (for programs external to the SAP System), such as handling of error output and synchronicity In general, job steps run sequentially and synchronously in the order they're entered in a job: the first step starts, runs, and is completed, then the second step starts, and so on. The only exception is when you schedule an external program to run asynchronously. In this case, the background processing system starts the next job step without waiting for a return code from the external program. If the external program runs long enough, then the start of the next job step may overlap it. Job steps run partially independently of each others status. That is, the abnormal termination of one job step does not roll back the work of a previously completed job step if this previous step was executing a commit. If any job step fails, however, then the entire job fails. No further job steps are carried out, and the job's status changes to Canceled. There are two types of job steps: An executable ABAP program Only type 1, or executable, ABAP programs can be used as job steps. Module pools and function groups, which are collections of ABAP modules, are not allowed. The specifications required for an ABAP job step are: ABAP program + Variant + Print and archiving parameters + Language An external command or external program This type of job step allows you to run programs outside the SAP System. External commands are predefined, authorization-protected commands for end users. External programs are unrestricted, directly entered commands reserved for system administrators. The type of external command and external program is unrestricted, meaning that you can use either compiled programs or scripts. Such programs can be run on any computer that can be reached from the SAP System. Parameter passing to non-SAP programs is completely unrestricted except by the predefinition mechanism for external commands. Output of non-SAP programs, particularly error messages, is included in the job's log file. Specifications required for an external command or programs are: External command + Type of operating system + (Parameters) + Target host system External program + Parameters + Target host system
Page 22
Page 23
a. b. c. d.
e. f.
Time of printing: set to Send to SAP spooler Only for now Name abbreviated name to identify the job output Title free form description for the report output Authorization a value defined by Security in user profiles to allow those users to access this spool request (authorization object S_SPO_ACT, value SPOAUTH). Only users with matching authorization value in their profiles will be able to see the output. Department set to appropriate department/functional area name. This field can be used in a search later. Retention period set to Do not delete if the report output needs to be retained for more
Page 24
Batch Job Scheduling in SAP than 8 days. Once the archiving/document repository solution is in place the spool requests could be automatically moved to the archive/repository. Storage Mode parameter on the same screen could be used to immediately send the output to archive instead of creating a spool request.
On-line reports:
Exactly the same configuration can be maintained for any output produced from R/3. If a user clicks Parameters button on a SAP Printer selection dialog, it allows specifying all the parameters as described in Scheduling background jobs section. Thus any output created by an online report can be saved and accessed by any user authorized to access that spool Access to reports output: A user that had proper access (see Configuring user access above) can retrieve a job/report output through transaction SP01. Created by: Samik Ghosh Page 25
The selection screen can be configured by clicking Further selection criteria button (e.g. to bring Spool request name (suffix 2) field or hide other fields). The following fields can be used to search for a specific output (Note that Created By must be blank when searching for scheduled jobs outputs) Spool request name (suffix 2) corresponds to a spool name in Scheduling background jobs section above). Date created to find an output of a job that ran within a certain date range. Title corresponds to spool Title in Scheduling background jobs section above). Department - corresponds to spool Department in Scheduling background jobs section above). Upon entering selection criteria, the user clicks the Execute button to retrieve the list of matching spool requests.
Page 26
Batch Job Scheduling in SAP From the spool list the user can use several function such as view the content of a spool request, print the spool request, view attributed of the spool request, etc. (some functions may need special authorization, Click the Print button to print the spool request with the default attributes (usually defined with the job definition). It will print it on a printer that was specified when a job was created. Click the Print with changed attributed button to print the spool request with the different attributes (e.g. changing the printer name). Click the Display contents button to preview the spool request contents. A Print and Download functions are available from the preview mode.
Page 27