Skip to Content
0

Modify LCM Job using SDK

Jun 16, 2017 at 03:10 PM

117

avatar image

Hi experts,

I'm in SAP BI 4.2 SP3 and I'm trying to do several things (using SDK), such as :

- Move a LCM Job from a folder to another one

- Schedule a LCM Job

- Maybe even modify a LCM Job or create a new one

Anyway, I found a very specific java class (com.businessobjects.lcm.job.IJob) in which I found a lot of very promising things but I have no clue about how to use it??? There is no documentation on it and I wonder if it's even possible to make that kind of things...

If you have any idea, please tell me =)

I'd be very pleased to share my work to you if everything works fine.

Best regards

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

6 Answers

Bharath B N Jun 16, 2017 at 05:30 PM
0

Hi Vincent,

Assuming you have Java SDK setup .

Else please refer the documents:

1.Setting up the development environment

2.Authentication

3.Common workflow

-

- Bharath

Share
10 |10000 characters needed characters left characters exceeded
Bharath B N Jun 16, 2017 at 05:38 PM
0

1. Create Enterprise Session using Java SDK:

IEnterpriseSession basicLogon() throws SDKException
{
  ISessionMgr sessionManager = CrystalEnterprise.getSessionMgr();
  IEnterpriseSession enterpriseSession = sessionManager.logon("username", "password", "<cms>:<port>", "secEnterprise");
  return enterpriseSession;
}

Learn More

2. Create LCM Job using Java SDK:

IJob create_LCM_Job (IEnterpriseSession enterpriseSession) throws SDKException
{
	IInfoStore infostore = (IInfoStore) enterpriseSession.getService("InfoStore");
	IInfoObjects newJobs = infostore.newInfoObjectCollection();
	IJob newJob = (IJob) newJobs.add(IJob.KIND);
	newJob.setTitle("myJob");
	newJob.setDescription("This is a new lcm job InfoObject.");
	newJob.setParentID(837);//set folder id
	    	
	infostore.commit(newJobs);	
        return newJob;
}

Learn More

3. Modify LCM job using Java SDK

void modify_LCM_Job(IEnterpriseSession enterpriseSession, int job_id) throws SDKException
{
	IInfoStore infostore = (IInfoStore) enterpriseSession.getService("InfoStore");
	String query = "SELECT * FROM CI_INFOOBJECTS, CI_SYSTEMOBJECTS, CI_APPOBJECTS " 
			+ "WHERE SI_KIND='" + IJob.KIND + "' "
			+ "And SI_ID='" + job_id + "'";
	IInfoObjects jobs = infostore.query(query);
	    	
	IJob job = (IJob) jobs.get(0);
	job.setTitle("MyJob_new_name");//set new name
	job.setParentID(1234);//changing folder id(moving from one folde to another)
        job.save();
        infostore.commit(jobs);
}

Learn More

4. Schedule LCM Job using Java SDK

Schedule InfoObject

-

-Bharath

Show 2 Share
10 |10000 characters needed characters left characters exceeded

Hi,

Thanks you very much for your quick response!! I tried to do what you wrote but I've got a error message when I try to launch it.

Here is the code I used :

public static void test(String User, String Password, String Host, String Authentication) throws SDKException{
		BI4_Event log= new BI4_Event();
		IEnterpriseSession enterpriseSession=log.BI4_Logon(User, Password, Host, Authentication);
		modify_LCM_Job(enterpriseSession,160000);
	}
	
static void modify_LCM_Job(IEnterpriseSession enterpriseSession, int job_id) throws SDKException
	{
		IInfoStore infostore = (IInfoStore) enterpriseSession.getService("InfoStore");
		String query = "SELECT * FROM CI_INFOOBJECTS, CI_SYSTEMOBJECTS, CI_APPOBJECTS " 
				+ "WHERE SI_KIND='" + IJob.KIND + "' "
				+ "And SI_ID='" + job_id + "'";
		System.out.println(query);
		IInfoObjects jobs = infostore.query(query);
		    	
		IJob job = (IJob) jobs.get(0);
		//job.setTitle("MyJob_new_name");//set new name
		job.setParentID(175102);//changing folder id(moving from one folder to another)


	    infostore.commit(jobs);
}

As you can see, I took your code and I just tried to launch that, knowing the query returns me 1 result in the Query Builder.

However, I have an error message :

Exception in thread "main" java.lang.NoClassDefFoundError: com/businessobjects/sdk/biar/exception/XSDException
	at com.businessobjects.lcm.job.LCMJobFactory.makePlugin(LCMJobFactory.java:30)
	at com.crystaldecisions.sdk.occa.pluginmgr.internal.PluginMgr.getPluginInterface(PluginMgr.java:349)
	at com.crystaldecisions.sdk.occa.infostore.internal.InfoObjects.continueUnpackHelper(InfoObjects.java:592)
	at com.crystaldecisions.sdk.occa.infostore.internal.InfoObjects.continueUnpack(InfoObjects.java:537)
	at com.crystaldecisions.sdk.occa.infostore.internal.InfoObjects.startUnpack(InfoObjects.java:512)
	at com.crystaldecisions.sdk.occa.infostore.internal.InternalInfoStore$XRL3WireStrategy.startUnpackTo(InternalInfoStore.java:1686)
	at com.crystaldecisions.sdk.occa.infostore.internal.InternalInfoStore$XRL3WireStrategy.startUnpackTo(InternalInfoStore.java:1666)
	at com.crystaldecisions.sdk.occa.infostore.internal.InternalInfoStore.unpackAll(InternalInfoStore.java:1064)
	at com.crystaldecisions.sdk.occa.infostore.internal.InternalInfoStore.queryHelper(InternalInfoStore.java:1098)

I think I missed something, like a JAR of something, like that?

Best regards,

0

It's ok, I finally found the solution : I missed one JAR : commentary.common.jar and everything works fine!!

Thank you very much anyway!!

1
Bharath B N Jun 16, 2017 at 06:09 PM
0
Share
10 |10000 characters needed characters left characters exceeded
Vincent LE ROUX Jun 20, 2017 at 02:30 PM
0

It's almost done : I was able to schedule a job but now I would like to change the destination CMS using SDK.

I found, into the IJob type, the function setDestCMS which only accept CMS type.

So I tried to create a CMS using import com.businessobjects.lcm.core.CMS but I don't know how to instantiate. Have you any idea of how to make it?

Best regards,

Share
10 |10000 characters needed characters left characters exceeded
Bharath B N Jun 21, 2017 at 05:43 PM
0

Please try this.

job.properties().setProperty(IDHelper.nameToID(JobConstants.LCM_JOB_DESTINATION_CMS_NAME), "destination_cms_name");

not tested code.

-Bharath

Share
10 |10000 characters needed characters left characters exceeded
Vincent LE ROUX Jun 28, 2017 at 07:50 AM
0

Unfortunalty, it doesn't work...

Here is a sample of code I just used :

As you can see, I can see the current value of CMS_NAME (but not the other properties). And if I try to change it, it doesn't change anything into the CMC.

I think the best way to change the destination of a LCM Job is to create a CMS object (but I really don't know how to do so...) and use the setDestCMS(CMS object) but there is actually no documentation on it...

Damn : I'm sure I'm not so far to find a way to make it but I'm stuck with this CMS object.

Best regards


capture.png (46.0 kB)
Show 1 Share
10 |10000 characters needed characters left characters exceeded

did you saved the object after all your changes ?

job.save(); - please check this line

0