Skip to Content

Consider a batch job that needs to be run on 1st day of every year.


If you set it up using transaction SM36 as a repetitive batch job you see that the options provided do not match this requirement.


We can achieve this by creating a factory calendar then using the factory calendar option in SM36.


Let us see below how we configure these settings.


Configuration:

Create a new factory calendar that has one working day which is always the 1st day of  year.


You use transaction SCAL to create factory calendars. Select the Factory calendar radio button and then click on the change icon.


/wp-content/uploads/2012/07/1_119620.jpg

Then ‘Change Factory Calender: Overview’ screen appear.


Press the left upper corner ‘Create’ button to create new factory calender

/wp-content/uploads/2012/07/2_119633.jpg

Then ‘Change Factory Calender Datails’ screen appears.


Insert Factory Calender Id as ‘ZL’ and description as “First day of every year’.


As we are going to use Special rules only, we don’t need to enter a holiday calendar.


Press Save and then click on “Special rules”.

/wp-content/uploads/2012/07/3_119634.jpg


In the next screen that appears enter the specific dates for which you want the calendar to be active.

Tick the Workday check box for these dates.

/wp-content/uploads/2012/07/4_119635.jpg


/wp-content/uploads/2012/07/5_119639.jpg

Press save and go back to Overview screen. Click on the Calendar button to see what these dates look like in a calendar format.


Double-click on a year to see the work dates in a calendar format. Workdays are highlighted in yellow on your screen and non-working days are in green.

/wp-content/uploads/2012/07/6_119640.jpg

Job scheduling in SM36:


Create a new job ZLMS_BACKGROUND_JOB and click on “Start condition

/wp-content/uploads/2012/07/7_119646.jpg

Press  “Date/Time” .Insert proper starting date and time on which job sceduled.


Tick the Periodic  job check box. 

/wp-content/uploads/2012/07/8_119647.jpg

Click on the other period button one dialog box will appear .specify 12 months and press Save

/wp-content/uploads/2012/07/9_119654.jpg

/wp-content/uploads/2012/07/10_119655.jpg

Then click on “Restrictions” button. In the pop-up of Start date restrictions enter calendar id as ZL and

select Move job to next working day option which restricts the job.

/wp-content/uploads/2012/07/11_119656.jpg

Then press transfer to save the settings and go back to pop-up.

/wp-content/uploads/2012/07/12_119657.jpg


We can see the job planned start date is set to 01.01.2013(1st day of year) and frequency is set to yearly. Define the steps and complete the job set up by pressing save.

Then go to step button .It prompts us for program to be executed while executing a job.

First create a abap program in SE38 using following code.

REPORT  ZLMS_JOB_PROGRAM.

DATA ITAB TYPE STANDARD TABLE OF   ZLMS_EMP_MASTER.
DATA STRU LIKE LINE OF  ITAB.
DATA TEMP TYPE ZLMS_EMP_MASTER-CASUAL_LEAVE.

SELECT * FROM ZLMS_EMP_MASTER INTO STRU.

TEMP = STRU-CASUAL_LEAVE – STRU-CASL_LEAVE_TAKEN.
IF  TEMP >= 5.

STRU-CASL_ADJUSTMENT = 5.
ENDIF.
STRU-CASL_LEAVE_TAKEN =
0.

TEMP = STRU-EARNED_LEAVES – STRU-ERND_LEAVE_TAKEN.
IF TEMP >= 5.

STRU-ERND_ADJUSTMENT = 5.
ENDIF.

STRU-ERND_LEAVE_TAKEN = 0.

STRU-COMPENSATRY_LEAV   =  STRU-COMPENSATRY_LEAV – STRU-COMPNSTRY_LV_TKN.

STRU-COMPNSTRY_LV_TKN = 0.

STRU-LEAVE_WO_PAY = 0.

STRU-PATERNITY_LEAVE = 0.

STRU-MATERNITY_LEAVE = 0.

APPEND STRU TO ITAB.

ENDSELECT.

    MODIFY ZLMS_EMP_MASTER FROM TABLE ITAB.

/wp-content/uploads/2012/07/13_119658.jpg

After specifying Program name click ’save’ button. It redirect to step list overview page

Showing specified program as one entry in table.

/wp-content/uploads/2012/07/14_119660.jpg

Thus we have created Background Job to update table on  1st of every year.

OUTPUT:

On scheduled date and time each year  Job runs means that ABAP program is execuuted without developers or the users intervention.




To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply