Skip to Content

As of BI4.2 SP5 release, a new Java SDK for Promotion Management is available for managing the transport of objects between systems. The SDK provides 3 scenario based workflows as does the Performance Management tool in the CMC and the LCM command line interface. These scenarios are:

  • An import scenario, importing from an LCM archive to a live system
  • A promote scenario, promoting between two live systems
  • An export scenario, exporting from a live system to an LCM archive

Each of these scenarios can be run on demand or scheduled to run at a later time.

 

The SDK follows the same basic workflow as when creating a Promotion job in the Promotion Management UI.

  • Log onto a system that will run the job
  • Create a new Promotion Management Job
  • Log onto your source CMS or specify an import LCM archive
  • Log onto your target CMS or specify an export LCM archive
  • Browse to the objects to be added to the job
  • Test and/or run the job.
  • Log off

You can find the SDK Reference guide in the Development section of the following link:
https://help.sap.com/viewer/product/SAP_BUSINESSOBJECTS_BUSINESS_INTELLIGENCE_PLATFORM/

The title of the guide is: “SAP Business Intelligence Platform Promotion Management SDK Reference”  (Note you must be logged on to view the material)

The SDK is available in the lcm.jar file as of BI 4.2 Support Package 5 release. The jar can be found in the following location: <BO Install dir>\SAP BusinessObjects Enterprise XI 4.0\java\lib

The classes in the SDK can generally be broken down into categories. In order to try and help understand the purpose of these classes, I will compare the categories to different steps when creating a Promotion Management Job in the CMC.

Category Class Description
Host support

HostFactory

Host

A Host is equivalent to a new job in the Promotion Management tool.
LCM Archive Support

LcmArchiveFactory

LcmArchive

Used to set the import or export Lcm Archive filename and path depending on the scenario
Scenario Support

ImportScenario

ExportScenario

PromoteScenario

ScenarioOptions

Defines the scenario to be created and run by the Host. You can run, schedule or test promote (dryRun) the scenario. The ScenarioOptions class allows setting security, comment and rollback options.
Resource Selection

ObjectBrowser

ObjectMatcher

Similar to the Add Objects window, these classes let you add or remove objects as InfoObjects, CUIDs or from a query and compute dependencies.
Execution Support

RunResult

SchedulingStatus

Allows for tracking the status of a job while executing
User Feedback

Logger

ILoggerOutput

IProgressMonitor

AbstractProgressMonitor.

This is not part of the UI but these classes provide the ability to log and follow progress of a job.

 

The sample code below steps through the export scenario to demonstrate the basic workflow.

public class ExportToLcmbiar {

	
// Export Scenario for Live to LCMBiar
public static void main(String[] args) throws SDKException, LCMException {
				
	// log on to CMS that will run the job
	IEnterpriseSession mySession;
	ISessionMgr sessionManager = CrystalEnterprise.getSessionMgr();
	mySession = sessionManager.logon( userName, password, myCMS, authType);
	mySession.setLocale(Locale.ENGLISH);
		
	// check that logged on user has Admin Rights
	boolean isAdmin = com.businessobjects.sdk.lcm.SDKUtils.isConnectedAsAdmin(mySession);
	System.out.println("user is Admin: " + isAdmin);

	//get all objects from the folder with ID 1234
	String qry = "SELECT SI_CUID from CI_INFOOBJECTS where SI_PARENTID=1234";
	
	//Create a new LCM Job to export to lcmbiar file
	Host host = HostFactory.newInstance(mySession);
	ExportScenario myScenario = host.newExportScenario("LCMSDK_ExportTest");
		
	//Log onto Source CMS
	IEnterpriseSession sourceSession = sessionManager.logon(srcUserName, srcPassword, srcCMS, authType);
		
	//set the export destination for the LCMBiar file
	LcmArchive myExport = LcmArchiveFactory.newInstance("c:\\test\\SDKExport.lcmbiar");
	myScenario.setDestination(myExport);
	
	//Add objects to be exported
	ObjectBrowser oBrowser = myScenario.setSource(sourceSession);
	oBrowser.addQuery(qry);
	oBrowser.computeDependencies();
	for (Set<IInfoObject> dependencies :oBrowser.getDependencies().values())
	{
		oBrowser.addObjects(dependencies);
	}
	
	//Run the scenario and release the host
	myScenario.run();
	host.release();
			
	//log off
	sourceSession.logoff();
	mySession.logoff();
	System.out.println("Session Logged off");
}

 

The above code will not persist the job in the CMS. The job is deleted when the host is released. In order to persist and see the job in the Promotion Management Tool, a scheduled job should be created instead.

The progress is logged to the output window. The below output is from the above code:

  •  user is Admin: true
  • Logging on to the central CMS “BIPW12R2:6400” …
  • Logged in to central as “Administrator”
  • Running housekeeping …
  • Housekeeping complete
  • Creating job “LCMSDK_ExportTest” …
  • Job created
  • Logging on to the source CMS “BIPW12R2:6400” …
  • Logged in to source as “Administrator”
  • Running query on browser …
  • Query returned 1 object(s)
  • Added 1 resource(s)
  • Computing dependencies …
  • Dependencies computed
  • Added 3 resource(s)
  • Saving job “LCMSDK_ExportTest” …
  • Job saved
  • Exporting resources from source “bipw12r2:6400” to file “SDKExport.lcmbiar” …
  • Resources exported
  • Session Logged off

 

Hopefully this brief introduction to the Promotion Management SDK helps explain how to use the SDK.

Since I cannot attach the source as a zip file, I have also included the Import and Promote (Live-to-Live) Scenarios below:

public class ImportFromLcmbiar {

	//Import Scenario from lcmbiar file to live CMS
	public static void main(String[] args) throws SDKException, LCMException {
		// TODO Auto-generated method stub
		
		// log on to host CMS
		IEnterpriseSession mySession;
		ISessionMgr sessionManager = CrystalEnterprise.getSessionMgr();
		mySession = sessionManager.logon( userName, password, myCMS, authType);
		mySession.setLocale(Locale.ENGLISH);
		
		// check that logged on user has Admin Rights
		boolean isAdmin = com.businessobjects.sdk.lcm.SDKUtils.isConnectedAsAdmin(mySession);
		System.out.println("user is Admin: " + isAdmin);
 
		
		//Create a new LCM Job to import lcmbiar file
		Host host = HostFactory.newInstance(mySession);
		ImportScenario myScenario = host.newImportScenario("LCMSDK_ImportTest");
		
		//load source file for import job.
		String importPath = "c:\\test\\SDKimport.lcmbiar";
		LcmArchive importFile = LcmArchiveFactory.newInstance(importPath);
		importFile.getFile();
		myScenario.setSource(importFile);
		
		//Log onto Destination CMS
		IEnterpriseSession destinationSession = sessionManager.logon(userName, password, destinationCMS, authType);
		myScenario.setDestination(destinationSession);

		myScenario.run();
		
		host.release();
		
		//Log off all sessions
		destinationSession.logoff();
		mySession.logoff();
		System.out.println("Session Logged off");

	}

 

public class promoteLiveToLive {
	
	static String myCMS = "localhost";
	static String sourceCMS = "192.168.1.65";
	static String destinationCMS = "localhost";
	static String authType = "secEnterprise";
	static String userName = "Administrator";
	static String password = "Secret123";


	public static void main(String[] args) throws SDKException, LCMException {
		// TODO Auto-generated method stub
		
		// log on to source CMS
		IEnterpriseSession mySession;
		ISessionMgr sessionManager = CrystalEnterprise.getSessionMgr();
		mySession = sessionManager.logon( userName, password, myCMS, authType);
		mySession.setLocale(Locale.ENGLISH);
		
		// check that logged on user has Admin Rights
		boolean isAdmin = com.businessobjects.sdk.lcm.SDKUtils.isConnectedAsAdmin(mySession);
		System.out.println("user is Admin: " + isAdmin);

		//Create a new LCM Job to promote from an older system
		Host host = HostFactory.newInstance(mySession);
		PromoteScenario myScenario = host.newPromoteScenario("LCMSDK_PromoteTest");
		
		
		//Log onto Source CMS                                  
		IEnterpriseSession sourceSession = sessionManager.logon(userName, password, sourceCMS, authType);
		
		//contents of samples folder on older BI4.1SP5 system
		String qry = "SELECT SI_CUID from CI_INFOOBJECTS where SI_PARENTID=186681";

		//Add objects to be exported
		ObjectBrowser oBrowser = myScenario.setSource(sourceSession);
		oBrowser.addQuery(qry);
		oBrowser.computeDependencies();
		for (Set<IInfoObject> dependencies :oBrowser.getDependencies().values())
		{
			oBrowser.addObjects(dependencies);
		}

		//Log onto Destination CMS
		IEnterpriseSession destinationSession = sessionManager.logon(userName, password, destinationCMS, authType);
		myScenario.setDestination(destinationSession);

		myScenario.run();
		host.release();
		
		//log off all sessions
		mySession.logoff();
		sourceSession.logoff();
		destinationSession.logoff();
		System.out.println("Session Logged off");

	}

}

 

 

 

 

 

 

To report this post you need to login first.

2 Comments

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

  1. Kunal Kharat

    Hi Daniel,

    Thank you for publishing this.

    Its truely a great share.

    Your article was very helpful.

     

    I have a question; based on the ExportToLCMbiar code. I am not sure if this is universal, but using computeDependencies()

    It spawns multiple threads, which keep running, even when the dependencies are computed and the lcmbiar is made. Due to this the code never exits. I have to manually hit Ctrl+C to exit from command line.

    Do you face a similar issue?

     

    Regards,

    Kunal Kharat

     

    (0) 

Leave a Reply