Search This Blog

Showing posts with label Background Jobs. Show all posts
Showing posts with label Background Jobs. Show all posts

Monday, May 5, 2008

Creating Background Jobs - Job Steps

 

¨ ABAP programs. With this option, you can specify the execution of ABAP reports as steps of a background job. Module pools or functions groups are not allowed for definition as steps.

 

¨ External commands. These are predefined commands that should have been previously defined by the system administrator. Normal users with the required authorization can schedule these job steps.

Since this is a way of executing programs or commands outside R/3, for security reasons users have to specify the operating system type and cannot change the predefined arguments.

 

¨ External programs. These programs are unrestricted operating system programs or shell scripts that require batch administrator privileges. There is no need to define these commands using transaction SM69. The requirement is that the computer must be reached from within the SAP server and have either remote shell support, a running SAP gateway, or a SAP instance that is on the reach of a SAP gateway.

 

 

Scheduling ABAP Programs as Job Steps

 

When scheduling ABAP reports as job steps, there are several type parameters which can be specified. The most important one is usually the selection criteria for the execution of the report as it would be normally specified when launching the report online. A group of selection criteria is saved in variants.

When an ABAP program is specified as part of a background job, if it needs selection criteria, the variant must have been previously created, otherwise you will not be able to save the ABAP step.

 

To define an ABAP program as a job step, from the initial job definition screen, press the Step button, and then click on the ABAP Program button on the Create step screen. Then proceed as follows:

¨ The User input field will be filled automatically with your own user name. But you can select another user name which will be used by the system to check the

    authorizations for the running job. You can only enter another user name if your own user is authorized to do so.

¨ Enter the name of the ABAP program in the Name input field.

¨If the ABAP program has selection fields, you must enter a variant in the Variant input field. If you don't know the name of the variant, click on the Variant list 

   button and select one. If you don't have any variant defined, you have to first define at least one variant, otherwise the system will not let you schedule the job. You

   can leave this field blank only in the case that the program does not require variants.

¨ Finally, in the Language input field, you can select a different language than the default, which is the one used when logging in to the system. Since SAP R/3 is a

    multilanguage system, there might be some language−dependent texts in the program which will be affected by the value of the language field.

 

 In the definition of steps with ABAP programs, you can also specify print parameters to instruct the system on where and how to print the job output.

When finished entering the needed information in the input fields, you can check your definition by clicking on the Check button. The system will display a message in the status bar if it finds any errors in the job definition. If there are no errors, click the Save icon to save your step.

 

 

Scheduling External Commands

 

Both external commands and external programs are executed by means of the sapxpg program. This program is called either by a remote shell (rsh, remsh, and others) or by the SAP gateway (the usual way under Windows NT systems).

External commands to be scheduled must have been previously defined by the system administrator (transaction code SM69).

 

¨To define these commands as job steps, first click on the External command push button on the Create step dialog box.

¨On the Name input field, click on the possible entries arrow to select one of the available external commands.

¨Only the commands available for the target operating system can be successfully executed.

¨The Parameters input field is used for specifying additional flags or parameters for the command.

¨Select Operating system from the available options, and the target host where the command will be executed.

¨Finally, verify the definition by clicking on the Check icon. If no errors are found, proceed by saving the step definition.

 

 

Scheduling External Programs

 

You can schedule external programs as job steps. These external programs can be of any type as long as they can be reached from the R/3 server and the host where the program resides can execute the program itself. It can be any compiled or executable program, shell script, and so forth.

 

The step definition for external programs allows you to include any parameters the program needs in a complete transparent way. The error messages generated by external programs are included in the log file for the background job.

 

To enter an external program as part of a job, when on the Create step screen, click on the external program.

The system will change the colors for the relevant input fields while graying out the field for the ABAP programs. Notice how the command buttons in the lower part of the screen change as well, depending on the type of program.

Enter the following information for the external program:

¨ Name. Enter the name and path of the external program. You should enter the path to ensure that the program can be found in the target system except if the

   program is in the search path of the SAP user with which the R/3 gateway was started (normally the <sid>adm user). For example: enter /home/dd1adm/copy.sh,

   instead of entering just copy.sh.

¨ Parameter. Enter here any parameters, flags, or options that the external program might need. For example, if the program /usr/bin/ps needs the option −eaf, enter

   this value in the parameter field.

¨ Target host. You have to enter here the hostname of the server where the external program is to be executed. This host must be reachable from the R/3 server.

 

Defining Background Jobs

 

Starting background jobs is a two−step process: you first define the job and then you have to release it.

 

When users define a job and save it, they are actually scheduling the report, that is, specifying the job components, the steps, the start time, and the print parameters. So, to schedule a job is the same thing as to define it. More precisely a scheduled job is a job definition which has been saved.

When users schedule programs for background processing, they are instructing the system to execute an ABAP report or an external program in the background.

 

Scheduled background jobs, however, are not actually executed until they are released. When jobs are released, they are sent for execution to the background processing system at the specified start time.

Jobs are released automatically if the user is authorized to release jobs, and they automatically start the execution in the background system if the user has chosen the start immediately option.

Both the scheduling and the releasing of jobs require authorizations. Standard SAP users have authorization which allow them to schedule jobs; however, releasing jobs is a task normally assigned to the system administration and requires another authorization. Protecting the releasing of jobs with authorization enables system administrators to better monitor and maintain the background system and allows the available resources to be better distributed. The drawback is that scheduling jobs is such a common task that it can surpass the administrator's ability to maintain the whole system. Therefore, reserve some time for studying which users should be allowed to release their own jobs.

 

When users do not have release authorization, the start time or frequency they specify does not have any affect at all, except for informing the administrator in charge of releasing them of their preference for executing the job. Administrators or users with authorization for releasing jobs can change the start time

specifications and the interval.

 

When scheduling jobs, users can specify several steps, each having a different report or program. Each step has its own attributes, such as authorized users or print parameters. The same job can contain steps with ABAP reports and steps with external programs or commands.

 

When defining jobs, users also have the option of scheduling a program as a separate job or modifying an existing job which has not yet been processed and adding it to the list of job steps.

Users, and especially administrators, should avoid having too many released jobs during normal, operative working hours, since the system processes the background jobs during online operation where there are available background work processes. Remember that a background job will perform the same tasks as if the functions were performed online. So, if a background job does lock a table or updates the database, it will have an immediate result and can affect the work of online users.

 

 

Tuesday, April 29, 2008

Introduction to Background Jobs

(For the Beginners)

A SAP background job defines the program or group of programs which are going to be executed by the background work processes.


Components of the Background Jobs

A background job has the following components:

¨ Job name. Defines the name assigned to the job.
¨ Job class. Indicates the type of background processing priority assigned to the job.
¨ Target host. It's the SAP instance where the job will be executed.
¨ Job steps. A job step defines the program (either ABAP or external) which will be executed.
¨ Start time and repeat interval. Define when the job will be started and whether it should
be periodically executed.
¨ Job print lists. These lists specify the printing parameters for the job output.
¨ Job log. The logs for the jobs include log information about the job execution such as starting
time or any other information coded in the programs.
¨ Job spool recipient list. A recipient list can be used for specifying one or more recipients
who will receive automatically the spool list generated by the job.



Starting Background Processing

Starting background processing means to reach any type of job definition screen in order to specify the needed data for the background execution of programs. There are several ways to start the background processing system:

¨ From the initial job definition screen
¨ From the ABAP reporting service screen. From any menu, you can select System Services
Reporting, then enter the report name. The reporting screen includes the option for
background execution by selecting Program Background from the menu.
¨ From the ABAP workbench editor. On the editor initial screen, enter the name of the program
in the input field and select Program Execute Background from the menu.
¨ Sometimes working with business applications, especially navigating through the many
information system and reporting functions, the system allows for background execution.

The last three methods mentioned are virtually the same thing, though the system can display different selection screens. With these three methods of starting background processing, after indicating background execution, the R/3 system displays the Execute report in background screen. The job will have automatically included the report as the first job step, whereas the user has to enter additional job definition fields, such as the job class, target host, start time, and so on.