on 09-20-2018 9:27 PM
Our WIPS and DSL servers were down for approx 3 hours. During that time, a lot of scheduled jobs failed.
As an administrator, I can find all the jobs that failed in Instance Manager. I can also re-run them from here, but it will run the job as the "Administrator".
Instead, I need to re-run the job as the user who scheduled the job, as to consider their business and data security profiles.
Can I achieve this?
Extending from my comment above...
Date exDate;
calendar = Calendar.getInstance();
calendar.add(Calendar.DATE, 1);
exDate = calendar.getTime();
...
Integer iOwner = (Integer) oI.properties().getProperty("SI_OWNERID").getValue();
oSched.getSchedulingInfo().setScheduleOnBehalfOf(iOwner);
oSched.getSchedulingInfo().setRightNow(true);
oSched.getSchedulingInfo().setType(CeScheduleType.ONCE);
while(oSched.getSchedulingInfo().getDependencies().size() > 0)
oSched.getSchedulingInfo().getDependencies().remove(0);
oSched.getSchedulingInfo().setEndDate(exDate);
oInfoStore.schedule(oScheds);
oI.deleteNow();
This is just a snippet of a much larger program. I initially get the failed instances with:
IInfoObjects oInfoObjects = oInfoStore.query("select top 10000 * from ci_infoobjects where si_schedule_status = 3 and si_update_ts between " + timeCondition + " and si_name not like '%trigger%' and si_kind != 'scopebatch'");
"timeCondition" is calculated based on the current time and date, and will look something like "'2018.09.26 01.00.00' and '2018.09.26 08.00.00'"
I simply iterate over the results:
Integer total = oInfoObjects.size();
for(int x = 0;x < total;x++)
{
IInfoObject oI = (IInfoObject)oInfoObjects.get(x);
Note that I'm referencing both oI and oSched. I have logic that performs another CMS query on the same object and retrieves it into oSched. I don't remember why I did this, and it seems unnecessary.
IInfoObjects oScheds = oInfoStore.query("select * from ci_infoobjects,ci_appobjects where si_id = " + oI.getID());
if(oScheds.size() == 0)
{
System.out.println("Could not get existing schedules.");
continue;
}
IInfoObject oSched = (IInfoObject) oScheds.get(0);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You may need to go for a custom SDK code as I dont see any alternative solutions. Check for Idea place entry for this requirement, if not please create a one.Idea place
It can be done with the SDK. This is a portion of the program I use to reschedule a batch of failed reports: I just call setScheduleOnBehalfOf(), passing the instance's owner ID. I also set the job to run "Now", remove any events, and set the end date to tomorrow.
Date exDate;
calendar = Calendar.getInstance();
calendar.add(Calendar.DATE, 1);
exDate = calendar.getTime();
...
Integer iOwner = (Integer) oI.properties().getProperty("SI_OWNERID").getValue();
oSched.getSchedulingInfo().setScheduleOnBehalfOf(iOwner);
oSched.getSchedulingInfo().setRightNow(true);
oSched.getSchedulingInfo().setType(CeScheduleType.ONCE);
while(oSched.getSchedulingInfo().getDependencies().size() > 0)
oSched.getSchedulingInfo().getDependencies().remove(0);
oSched.getSchedulingInfo().setEndDate(exDate);
oInfoStore.schedule(oScheds);
oI.deleteNow();
Please support the idea: https://influence.sap.com/sap/ino/#/idea/101435
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.