Create Scheduled Job using SAP SM36 Transaction
This SAP tutorial shows how to create scheduled background job using SM36 transaction and configure job start time to run every time a specific SAP event is raised using Start time configuration. I used SAP event to trigger background job in a case where I could not submit ABAP report in Update mode during output processing.
This solution is prepared for a case where an invoice is created and an interface document should be immediately send to third party company. So the easiest way was to define a new output type for the related billing document type. The print program only raise SAP event which triggers background job. And the job submits ABAP program which sends output data.
Of course it is also possible to process outputs periodically like every 15 minutes or every hour, etc. But this case is for immediate processing after billing document is created on SAP system.
Create SAP Job
In this SAP tutorial, this section is showing how to use SM36 SAP transaction to create a scheduled SAP job to execute certain ABAP programs periodically.
Users can define the start time of a background job to a certain SAP event.
Let's start to define a new SAP job by calling transaction SM36 first.
SAP SM36 transaction code is used to create new job in SAP systems
The initial screen of SM36 transaction will enable the SAP user to define the name of the background job. After you enter the name of the background job, press Save button on toolbar menu.
Define background job in SAP using SM36 tcode
Define Job Steps
After you save the background job definition, you will be directed to the next step where you define what will the job do. SAP users can execute an ABAP program, an external program or an external command using this recently created background job.
SAP background job can run ABAP program, external program or external command
Since I want to run ABAP program using SAP job, I entered the name of the ABAP program on the first option area. Although I did not provide any program variant, you can choose one of the variants created for target ABAP program to use with this SAP background job.
After you check entered data is valid using the Check button, continue to next step by pressing Save button at the bottom of the screen.
Existing steps defined within the background job is shown as a list on the next screen.
Background job step list
Create Job Start Condition and Start Time
Now you can go back and define start conditions which will trigger job defined as a background job in SAP system. Press the Start Condition button in the job definition screen.
Define Start Condition for background job
When Start Condition button is pressed, Start Time definition screen is displayed.
There are 5 options for users to choose for SAP. These are Immediate, Date/Time, After job, After event and At operation mode.
Within above listed 5 start time options, I will choose "After Event" start time option for the case ilustrated in this SAP tutorial.
Defining start time for background job
Since I want to run this background job right after I raise an event in an ABAP program, I will define the start time using After event option. Continue to process by pressing After event button on screen. When After event button is pressed, related section on the screen will be enabled for data entry.
Within After event section, in the Event textbox, I enter the name of the SAP event I've created before. I did not supply any parameter. Because this process will be repeated each time a new output is created, it will work numerous times. So I mark the Periodic job option. Otherwise if you do not mark Periodic job option, your job will be created as a one time job.
Choose After Event start time option to execute SAP background job each time after event is raised
Check your configuration and save using the button at the bottom of the dialog screen. When you are redirected to job definition main screen, press Save to save all changes related with your new SAP background job. Following message will be displayed to indicate all changes are successfully saved
Job SAP_job_name saved with status: Released
Message no. BT112