on 08-01-2014 1:51 AM
Hi Everyone,
M33.104 - build version.
I'm tried the following code
{
JobDefinition newABAPJob = jcsSession.getJobDefinitionByName("DUP_TEST");
if (newABAPJob == null) {
newABAPJob = jcsSession.getJobDefinitionByName("SAP_AbapRun").duplicate();
newABAPJob.setName("DUP_TEST");
jcsSession.persist();
}
else {
jcsOut.println("JobDefinition already exists");
}
}
When i replaced SAP_AbapRun with a job definition i already have (as below), i received a Null Pointer Exception.
newABAPJob = jcsSession.getJobDefinitionByName("ECC_FIN_AP_TEMPLATE").duplicate();
Error:
57 more
Caused by: java.lang.NullPointerException: while trying to invoke the method com.redwood.scheduler.api.model.JobDefinition.duplicate() of a null object returned from com.redwood.scheduler.api.model.SchedulerSession.getJobDefinitionByName(java.lang.String)
at com.redwood.scheduler.custom.ShellScript_nandak.execute(ShellScript_nandak.java:17)
at com.redwood.scheduler.custom.ShellScript_nandakStub.jcsExecute(ShellScript_nandakStub.java:20)
... 62 more
The Job definition exists - screenshot below. The job is not a template. I tried with different job definitions that i created, it always failed.
But when i used SAP_AbapRun or SAP_AbapRunPrint, it is successful.
Please let me know what am i doing wrong?
Thanks
Nanda
Hi Nanda,
You are looking up the job definition in the wrong partition. As you do not provide the partition to lookup in, GLOBAL is assumed. You can try the following two alternatives:
- newABAPJob = jcsSession.getJobDefinitionByName(jcsSession.getPartitionByName("FIN"), "ECC_FIN_AP_TEMPLATE").duplicate();
newABAPJob = BusinessKeyLookup.getJobDefinitionByBusinessKey(jcsSession, JobDefinition.OBJECT_TYPE + ":FIN.ECC_FIN_AP_TEMPLATE").duplicate();
Regards Gerben
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
25 | |
12 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.