Schedule event-based jobs in an SAP system?

What is an Event:

An event is a signal to the background processing system in an SAP system, that a particular status has been achieved in the SAP system. The background processing system gets events and then starts all the jobs that are linked to the event.

There are three start conditions available for event-based jobs available, they are….

  1. After event
  2. At Operation mode switch
  3. After a Job

How to define an event in an SAP system

Using transaction code SM64, Event can be defined by the system administrator. There are 2 types of events available in the sap system. They are 1. user events 2. system events. System events are events predefined by SAP that you should not or cannot modify or trigger. User events can be triggered by an user.

Step-by-step procedure to create an event

  1. Enter transaction code SM64 or Use a Menu path Tools – CCMS – Background Processing – Trigger event
  2. Click on create button in the screen that is displayed
  3. Enter the name for the event and description
  4. Click on the SAVE button. (Note: Do not select the check box System)
  5. You should be able to see the created event in the list of events

Step-by-step procedure to schedule an event-based jobs in an SAP system

  1. Enter the transaction code SM36 in the command filed
  2. Enter the name for job and click on SAVE button
  3. In the create step 1 screen, enter the ABAP program RSPFPAR and its Variant which is created in previous article
  4. Click SAVE button in the step-1 screen
  5. Click Go Back from standard toolbar which will take you to the define background job screen
  6. Click on the Start condition button from the application toolbar
  7. Click After event in the screen that appears
  8. Specify the event which is created earlier
  9. Click on the SAVE button in the same screen
  10. You can also select periodic check box, f you want to run the job periodically depends on the event
  11. Click the SAVE button in the Define background job screen
  12. You should see status: Released in the status bar to confirm whether the event-based job is scheduled or not
  13. Now, You can trigger the event to make this job to be executed
  14. To Trigger an event, Goto t-code SM64
  15. Select the Event which is created and assigned for this event-based job to run
  16. Click on the trigger button and click on Trigger again in the screen that appears
  17. Now, Goto t-code SM37 and select * as after event  in the Job start condition
  18. You should be able to see the job status either should be active or Finished

By this time, You must be able to schedule either time-dependent or event-based jobs in an SAP system.

Importance of Background Jobs in detail

SAP Background Work Process
  1. We mainly use background work process for long running task called batch work processors
    2. Background processing is used not only for long running tasks but also for recurring tasks Ex: daily database backup or financial accounting status

    A background jobs consist of one or more steps
    a) An abap program
    b) An external command
    c) An external program

    Note:every job is processed without interruption by one single background work process.

    Background job can be scheduled with different priorities
    I. Class A highest priority
    II. Class B medium priority
    III. Class C normal priority

    Note:we must ensure that large share of all background tasks are normally scheduled as class C without target server specification (90% task)
    Ex: task scheduled using transaction DB13

    A step within a job can call one of the three actions

    1) Every ABAP program can be scheduled as a step of a job if the abap program has one or more selection screen, you can create the input required in the form of a variant.
    2) An external command is a call of a predefined script, a command or a program outside a SAP system. With external commands we can mask OS calls and stored them in SAP system under a new name.
    3) The execution of external command Is protected using SAP authorization. i.e. certain external commands can only be processed by particular users in the system.
    4) An external command is any OS command. SAP authorization concept only specifies whether a user can call external program or not.

    Start criteria for background job:
    A job can be triggered by the following options

    1) By scheduling a job on a particular data at a particular time. Ex: time control scheduling
    2) By the occurrence of a particular event defined in the sap system (event based scheduling)

    Scheduling and monitoring: use transaction SM36 to define new jobs
    • We can manually schedule the jobs as well as call the jobs wizard
    • Most of the case we schedule manually

    Required specifications for defining a job:
    1) General specification such as job name job priority and target sever (optional)
    2) Definition of one or more job steps
    3) Definition of start conditions (time or event based)

    Q) Why it is not preferred to use job wizard?
    A) Unlike classical scheduling we cannot perform individual steps with different users.

    Here we can monitor different status of background jobs

    Status of Jobs :-

    1) Schedule: The steps of job have already been defined however start condition must still been defined

    2) Released: 
    I. The job has been define completely defined including the start condition
    II. A job cannot be released without a start condition
    III. Only a relevant authorized user can release a job

    3) Ready: the start condition of a released job has been fulfilled. A job scheduler has placed job in the wait queue for a free background work process

    4) Active: the job is currently being executed and cannot be released or changed

    5) Finished: All steps of the jobs are successfully completed

    6) Canceled: the job is terminated reasons for this are
    I. An administrator deliberately terminated the job in transaction code SM37 by choosing job _ cancel active job button
    II. A job step is terminated with an error.
    Note: we can change a job status as long a job still has the status scheduled or released
    III. We can create a new job by copying an existing job by choosing JOB-copy

    Time Based Scheduling :-
    There are three options to execute a job.
    1. Immediately
    2. Particular Date/Time
    3. On a particular work day (i.e. factory calendar)

    • A job scheduler in the background handles all time-based jobs.
    • Profile parameters, which specifies the time period in which time dependent job scheduler is active  rdisp/bcttime.
    • Execution of jobs with the start condition “Immediate” usually avoids the time-based scheduler.
    • In this case the dialog work process of the user performs the job scheduling.
    • The profile parameter to configure the background work process is rdisp/wp_no_btc
    • The number of background work process depends on the number of tasks to be performed in the  background.
    • If the transport system is used there must be at least 2-background process.
    • Default time for time dependent job scheduler us set to 60 seconds (rdisp/bcttime = 60)
    Note: An ABAP program, SAP_MSSY2 (An automatic abap program), that automatically runs in a dialog work process.
    • For time based job scheduling we have a job-scheduling table in the DB.
    • Jobs that are not assigned to any particular target server can be executed by any free background work processes. This means that workload is automatically distributed between the systems.
    • If a job is scheduled on a particular target m/c it will run only based on the load of that machine. The automatic selection option is being disabled in this case.

    Standard Jobs :-
    Standard jobs refer to background jobs that should run regularly in a production system.
    • As a part of our monitoring we need to take care.
    • They mainly perform certain clean-up activity of a system such as deletion of obsolete spool requests.
    • In SM36 we go to standard jobs.
    • To schedule all default jobs, choose the “Default Scheduling” option.
    • All standard jobs that are defined in the table REORGJOBS, are scheduled with specified variant and period.
    • To schedule individual jobs choose the particular job using SM36 and set the execution period.
    • To define an additional standard job that is not yet available in the table REORGJOBS choose “Predefined New Jobs”

    Event Based Scheduling :-
    An event is a signal to the b/g processing system, that a particular status that has been achieved in the SAP system. The b/g processing system receives events and then starts all the jobs that are linked to this event.
    • An application (Central instance) Server is specified for processing of event based jobs.
    • Event based jobs can be scheduled with one of the following 3 start conditions.
    1. After Event
    2. After Job
    3. Operation mode
    • Trans-Code to define a new event is SM62
    • When defining an event, the administrator differentiates between system and user events.
    • System events are events predefined by SAP that you can neither modify nor trigger.
    •Triggering events is done in various ways
    1. Manually using SM64
    2. Using an ABAP program
    3. Outside SAP at OS Level, using the program “sapevt” which runs at OS level.

    Reservation for Class A Jobs :

    • There are very few jobs which will be reserved of type Class A. The reservation of work process for Class A jobs does not reserve any particular work process rather it ensures that a particular number of workprocess is always kept free.
    • To set number of reserved background workprocess for Class A, you define an operation mode is RZ04 and maintain the workrocess allocation for this operation mode. By doing so, we have the option of reserving work process.
    • SAP strongly recommends not to reserve more than one bgwp for processing Class A jobs.
    • A job server group contains one or more instances with available bgwp. It is possible to select a job group for a particular job.
    • TCode to setup a job group SM61
    •Ttrans-Code to setup an extended job selection SM37c

    Background Users :-
    • With the definition of jobs in SM36, we can assign each step of the job to a user.
    • This particular user shall have authorization for executing the jobs.

    There are 2 options
    1. By default, the job will be executed using the current user in which I have logged in.
    2. Enter a different user name if your job should not be performed using your own authorizations.
    • To perform this action we should have the authorization S_BTCH_NAM, to enter the names other than your names in the user field.
    • Use the “System” user type when creating background users. SU01 – Tcode to create users.
    • A dialog logon with this user is not possible.
    • If I define a job using job wizard, by default that name of logged on user, is used for authorization check.

 

SAP BASIS Housekeeping jobs

In every SAP live system , basis guy need to run some programs background periodically that automatically deletes old data. For examples deleting old spool requests list, batch input sessions, collecting system performance statistics. Definitely these will effect on  system performance. At below I am listing some important programs that are important to run periodically as background jobs. Use transaction code SM36 to schedule these jobs.
Job Name            Related Program              Varient Interval                Description
 SAP_REORG_JOBS          RSBTCDEL            YES         Daily      Deletes old background jobs.
SAP_REORG_SPOOL       RSPO0041            YES         Daily      Deletes old spool requests.
 SAP_REORG_BATCHINPUT          RSBDCREO          YES         Daily      Deletes old batch input sessions.
 SAP_REORG_ABAPDUMPS         RSSNAPDL           YES         Daily      Deletes old dumps produced by ABAP abnormal terminations
SAP_REORG_JOBSTATISTIC         RSBPSTDE            YES         Monthly               Deletes job statistics for jobs not run since the specified date
SAP_REORG_UPDATERECORDS RSM13002           NO         Daily      Deletes old completed update records
 SAP_COLLECTOR_FOR_JOBSTATISTIC     RSBPCOLL            NO         Daily      Generates runtime statistics for background jobs

SAP_COLLECTOR_FOR_PERFMONITOR  RSCOLL00            NO         Hourly   Collects system performance statistics

Background JOB Administration :-

  1. We mainly use background work process for long running task called batch work processors
    2. Background processing is used not only for long running tasks but also for recurring tasks Ex: daily database backup or financial accounting status

    A background jobs consist of one or more steps
    a) An abap program
    b) An external command
    c) An external program

    Note:every job is processed without interruption by one single background work process.

    Background job can be scheduled with different priorities
    I. Class A highest priority
    II. Class B medium priority
    III. Class C normal priority

    Note:we must ensure that large share of all background tasks are normally scheduled as class C without target server specification (90% task)
    Ex: task scheduled using transaction DB13

    A step within a job can call one of the three actions

    1) Every ABAP program can be scheduled as a step of a job if the abap program has one or more selection screen, you can create the input required in the form of a variant.
    2) An external command is a call of a predefined script, a command or a program outside a SAP system. With external commands we can mask OS calls and stored them in SAP system under a new name.
    3) The execution of external command Is protected using SAP authorization. i.e. certain external commands can only be processed by particular users in the system.
    4) An external command is any OS command. SAP authorization concept only specifies whether a user can call external program or not.

    Start criteria for background job:
    A job can be triggered by the following options

    1) By scheduling a job on a particular data at a particular time. Ex: time control scheduling
    2) By the occurrence of a particular event defined in the sap system (event based scheduling)

    Scheduling and monitoring: use transaction SM36 to define new jobs
    • We can manually schedule the jobs as well as call the jobs wizard
    • Most of the case we schedule manually

    Required specifications for defining a job:
    1) General specification such as job name job priority and target sever (optional)
    2) Definition of one or more job steps
    3) Definition of start conditions (time or event based)

    Q) Why it is not preferred to use job wizard?
    A) Unlike classical scheduling we cannot perform individual steps with different users.

    Here we can monitor different status of background jobs

    Status of Jobs :-

    1) Schedule: The steps of job have already been defined however start condition must still been defined

    2) Released: 
    I. The job has been define completely defined including the start condition
    II. A job cannot be released without a start condition
    III. Only a relevant authorized user can release a job

    3) Ready: the start condition of a released job has been fulfilled. A job scheduler has placed job in the wait queue for a free background work process

    4) Active: the job is currently being executed and cannot be released or changed

    5) Finished: All steps of the jobs are successfully completed

    6) Canceled: the job is terminated reasons for this are
    I. An administrator deliberately terminated the job in transaction code SM37 by choosing job _ cancel active job button
    II. A job step is terminated with an error.
    Note: we can change a job status as long a job still has the status scheduled or released
    III. We can create a new job by copying an existing job by choosing JOB-copy

    Time Based Scheduling :-
    There are three options to execute a job.
    1. Immediately
    2. Particular Date/Time
    3. On a particular work day (i.e. factory calendar)

    • A job scheduler in the background handles all time-based jobs.
    • Profile parameters, which specifies the time period in which time dependent job scheduler is active  rdisp/bcttime.
    • Execution of jobs with the start condition “Immediate” usually avoids the time-based scheduler.
    • In this case the dialog work process of the user performs the job scheduling.
    • The profile parameter to configure the background work process is rdisp/wp_no_btc
    • The number of background work process depends on the number of tasks to be performed in the  background.
    • If the transport system is used there must be at least 2-background process.
    • Default time for time dependent job scheduler us set to 60 seconds (rdisp/bcttime = 60)
    Note: An ABAP program, SAP_MSSY2 (An automatic abap program), that automatically runs in a dialog work process.
    • For time based job scheduling we have a job-scheduling table in the DB.
    • Jobs that are not assigned to any particular target server can be executed by any free background work processes. This means that workload is automatically distributed between the systems.
    • If a job is scheduled on a particular target m/c it will run only based on the load of that machine. The automatic selection option is being disabled in this case.

    Standard Jobs :-
    Standard jobs refer to background jobs that should run regularly in a production system.
    • As a part of our monitoring we need to take care.
    • They mainly perform certain clean-up activity of a system such as deletion of obsolete spool requests.
    • In SM36 we go to standard jobs.
    • To schedule all default jobs, choose the “Default Scheduling” option.
    • All standard jobs that are defined in the table REORGJOBS, are scheduled with specified variant and period.
    • To schedule individual jobs choose the particular job using SM36 and set the execution period.
    • To define an additional standard job that is not yet available in the table REORGJOBS choose “Predefined New Jobs”

    Event Based Scheduling :-
    An event is a signal to the b/g processing system, that a particular status that has been achieved in the SAP system. The b/g processing system receives events and then starts all the jobs that are linked to this event.
    • An application (Central instance) Server is specified for processing of event based jobs.
    • Event based jobs can be scheduled with one of the following 3 start conditions.
    1. After Event
    2. After Job
    3. Operation mode
    • Trans-Code to define a new event is SM62
    • When defining an event, the administrator differentiates between system and user events.
    • System events are events predefined by SAP that you can neither modify nor trigger.
    •Triggering events is done in various ways
    1. Manually using SM64
    2. Using an ABAP program
    3. Outside SAP at OS Level, using the program “sapevt” which runs at OS level.

    Reservation for Class A Jobs :

    • There are very few jobs which will be reserved of type Class A. The reservation of work process for Class A jobs does not reserve any particular work process rather it ensures that a particular number of workprocess is always kept free.
    • To set number of reserved background workprocess for Class A, you define an operation mode is RZ04 and maintain the workrocess allocation for this operation mode. By doing so, we have the option of reserving work process.
    • SAP strongly recommends not to reserve more than one bgwp for processing Class A jobs.
    • A job server group contains one or more instances with available bgwp. It is possible to select a job group for a particular job.
    • TCode to setup a job group SM61
    •Ttrans-Code to setup an extended job selection SM37c

    Background Users :-
    • With the definition of jobs in SM36, we can assign each step of the job to a user.
    • This particular user shall have authorization for executing the jobs.

    There are 2 options
    1. By default, the job will be executed using the current user in which I have logged in.
    2. Enter a different user name if your job should not be performed using your own authorizations.
    • To perform this action we should have the authorization S_BTCH_NAM, to enter the names other than your names in the user field.
    • Use the “System” user type when creating background users. SU01 – Tcode to create users.
    • A dialog logon with this user is not possible.
    • If I define a job using job wizard, by default that name of logged on user, is used for authorization check.