2016 Apr 26 7:43 AM
Hi!
I have a background job which at the moment start immediately, with job frequency every minute and with a single step where the job executes a report.
I would like to change the way my background job behaves to the following:
1) From 7:00-19:00 the frequency is 6 min
2) From 19:00 to 7:00 the frequency is 30 min
3) Optional: no activity on weekends.
Can this be done with a single background job or do I have to define separate background jobs for each period of activity (working hours and off hours)?
2016 Apr 26 7:55 AM
Hi,
You have to schedule separately based on Date/Time and Period value,
Regards,
Nikhil
2016 Apr 26 7:55 AM
Hi,
You have to schedule separately based on Date/Time and Period value,
Regards,
Nikhil
2016 Apr 26 7:59 AM
2016 Apr 26 8:16 AM
Wait a minute, how do you schedule a job using standard SM36 that runs every 6 minutes but only between 7:00 and 19:00 ?
Thomas
2016 Apr 26 8:28 AM
Hi, Thomas! Haven't really confirmed yet, but I would define the Schedule Start and No Start After for the Start Condition as Date/Time, Set it as Periodic Job.
Although now that you mention it, I'm not 100% sure that it will actually start everyday
2016 Apr 26 8:30 AM
Hi Thomas,
That's what I have suggested, jobs need to be schedule separately between 7:00 to 19:00 that's what we did in one of my project we have to schedule it for every 6 min ( e.g. first job 7:00 to 7:06 next 7:06 to 7:12....... and so on )for the mentioned time. That was not for this much big period it was only for 4 hours.
Still if any other solution is available then I will definitely accept it and learn from it because earning knowledge than points is first priority for me.
Thank you!
Regards,
Nikhil
2016 Apr 26 9:08 AM
I also don't know another solution using pure SM36 other than scheduling one daily job for each of the desired start times 7:00, 7:06, 7:12, etc., which is what you meant if understand correctly, but that's quite awkward for a 12 hour window. Imagine you want to change it to an 8 minute interval...
For anything more sophisticated you need a separate scheduler, whether that is a custom ABAP program or some 3rd party tool.
I'd also like to learn if I'm missing anything here
Thomas
2016 Apr 26 9:21 AM
Thanks for your feedback, Thomas and Nikhil!
To me, it seems a little weird that I cannot schedule a background job that runs everyday during certain hours.
Just in case, i'll restate my requirements:
Background job (or two) which calls (Job Step) a ABAP Report every 6 or 30 min depending on the time of day:
Will post a solution to my complicated requirement if I manage to come up with any
2016 Apr 26 9:55 AM
Hi,
why can't you use a "wrapper report" around the actual report you want to schedule as described:
This wrapper report is executed by periodic job which runs every 6 minutes. The report then checks the time of last execution of the job, and checks the current time window (7-19 or 19-7) and decides based on the time window whether to submit the report or not.
Regards,
Alex
2016 Apr 26 10:13 AM
That would still mean that a background job would be running every 6 minutes. The point is to reduce resource consumption by the background job based on the need of the business (during work hours every 6 min and during off-hours every 30 min).
Some the answer to your question is
1) the solution is meant to reduce the load caused by background job (which currently is executed every 1 min);
2) there is no guarantee that when checking every 6mins that the switch between 2 frequencies will not inter-or overlap.
At list this is how I see it atm.
2016 Apr 26 2:00 PM
What I can recommend from my vast experience, is creating the jobs using events. It takes a bit of planning and thinking it through and -of course- you have to create the events, too and separate jobs that call up the events at the hours you want, but other than that it works like a charm.
Just schedule your jobs event - based.
The first event would define workdays 7-19, the second 19-7. You would need two events, one for each marking the end/beginning of one period. You do this in SM64.
Then you need a bit of Abapping, but that's where Thomas Zloch comes in - he could help you there (I'm no programmer, sorry).
Message was edited by: Mylene Euridice Dorias EDIT: I searched for the Abap, I wrote in 2003 and it's actually still there. This is how you call up an event based on the time of day. I am a Basis person, no developper, so this is neither elegant, nor (probably) performant or even (5 releases later) correct. But maybe this bit helps a little, so you can get a clue:
TABLES: TBTCO.
PARAMETERS: EVENT1 LIKE TBTCO-EVENTID OBLIGATORY,
EVENT2 LIKE TBTCO-EVENTID OBLIGATORY,
EVENT3 LIKE TBTCO-EVENTID OBLIGATORY.
SELECT-OPTIONS: INT1 FOR SY-UZEIT,
INT2 FOR SY-UZEIT,
INT3 FOR SY-UZEIT.
START-OF-SELECTION.
IF SY-UZEIT BETWEEN INT1-LOW AND INT1-HIGH.
CALL FUNCTION 'BP_EVENT_RAISE'
EXPORTING
EVENTID = EVENT1
EXCEPTIONS
BAD_EVENTID = 1
EVENTID_DOES_NOT_EXIST = 2
EVENTID_MISSING = 3
RAISE_FAILED = 4
OTHERS = 99.
CASE SY-SUBRC.
WHEN 0.
MESSAGE S250 WITH EVENT1.
WHEN 1.
MESSAGE E042 WITH EVENT1.
WHEN 2.
MESSAGE E042 WITH EVENT1.
WHEN 3.
MESSAGE E038.
WHEN 4.
MESSAGE E249 WITH EVENT1.
ENDCASE.
ELSEIF SY-UZEIT BETWEEN INT3-LOW AND INT3-HIGH.
CALL FUNCTION 'BP_EVENT_RAISE'
EXPORTING
EVENTID = EVENT2
EXCEPTIONS
BAD_EVENTID = 1
EVENTID_DOES_NOT_EXIST = 2
EVENTID_MISSING = 3
RAISE_FAILED = 4
OTHERS = 99.
CASE SY-SUBRC.
WHEN 0.
MESSAGE S250 WITH EVENT2.
WHEN 1.
MESSAGE E042 WITH EVENT2.
WHEN 2.
MESSAGE E042 WITH EVENT2.
WHEN 3.
MESSAGE E038.
WHEN 4.
MESSAGE E249 WITH EVENT2.
ENDCASE.
ELSEIF SY-UZEIT BETWEEN INT2-LOW AND INT2-HIGH.
CALL FUNCTION 'BP_EVENT_RAISE'
EXPORTING
EVENTID = EVENT3
EXCEPTIONS
BAD_EVENTID = 1
EVENTID_DOES_NOT_EXIST = 2
EVENTID_MISSING = 3
RAISE_FAILED = 4
OTHERS = 99.
CASE SY-SUBRC.
WHEN 0.
MESSAGE S250 WITH EVENT3.
WHEN 1.
MESSAGE E042 WITH EVENT3.
WHEN 2.
MESSAGE E042 WITH EVENT3.
WHEN 3.
MESSAGE E038.
WHEN 4.
MESSAGE E249 WITH EVENT3.
ENDCASE.
2016 Apr 26 4:50 PM
I doubt you'll find any solution without a third party job scheduler. Even with a "wrapper" report this would be quite challenging (how would you schedule the wrapper itself?) and might even defeat the purpose. Why exactly is this a requirement anyway?
The "No Start After" is very frequently misunderstood, make sure to hit F1 and read the documentation. It does not prevent the next job instance from starting after certain time, it only applies to the current job instance. You can do a simple test for this and will see easily that when you schedule a job to run at time X with "no start after" = X + 5 minutes and run periodically every minute, then as soon as the job starts, the next job instance will get scheduled with the release status. And if you check that job you'll see that "no start after" is not the same (X+5) but [the new job start] + 5.
I'm not sure actually what this option is for exactly, it seems completely useless and also confusing (you're not the first person to think it prevents the periodic job execution at certain time of day).
"No activity on the weekends" can be easily achieved with the calendar though.
@Mylene - I had the exact opposite experience, we constantly had problems with the event-based jobs. If memory serves, there was a bunch of SAP notes explaining why something didn't really work. It was a while ago though, so maybe something got improved since then.
2016 Apr 27 2:18 PM
Like I said - worked like a charm until some 3 years ago or so. We no longer have the process where we need to run RMRP000 continuously during the day (not at night) and with three different variants: morning, noon, afternoon. If you submit your abap + variant via abap + event, it does what it should. Actually, such requirements -while in no way common- pop up every now and again, especially around MM.