Syndicator Batch and Java Wrapper


MDM Syndicator branch of tools include:

1. Syndicator GUI: Used to Create/Save/Export/Import Mappings, Configure Output Types etc. Can not run without a user

2. Syndication Server: Runs as an OS Service and executes configured Syndication Ports. Once configured, produces output in a designated location. Less flexible to integrate with external tools

3. Syndicator Batch: Executes syndication process in batch mode without launching fat GUI and it is highly configurable and allows flexibility to create Wrappers to work with external tools such as XML/XSL Transformers, FTP Clients and anything under your imagination

This blog walks you thru using Syndicator batch from Windows Command and creating a Java Wrapper to dynamically execute

Syndicator Batch requires a special installation and is available only on windows OS. Upon installation, it will create a windows executable "SyndicatorBatch.exe" in the designated folder and here are the options available:

image

The following shows how Syndicator Batch output when executed with appropriate parameters:
image

Caveat: Syndicator batch is required to be executed inside the installation folder. You should navigate to the installation folder in Command shell.

No big deal right? Now, I will show you how to create a simple java program that passes all Syndicator Batch parameters dynamically:

/*
* Created on Jan 5, 2007
*
*/
package com.sitacorp.mdm.util;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
/**
* @author Venkat Vadlamannati
*
* A Java Wrapper to Syndicator Batch
*
*/
public class SBDemo {
public static String SYN_BAT_DIR = "D:Program FilesSAP MDM 5.5Syndicator Batch";
public static String SYN_BAT_EXE = "SyndicatorBatch.exe";
public static void main(String[] args) {
//Define and assign required parameters
String host = args[0];
String port = args[1];
String outputFile = args[2];
String user = args[3];
String password = args[4];
String language = args[5];
String synMap = args[6];
String clientSystem = args[7];
if(args.length<8 ){
System.out.println("Usage: java SBDemo <host> <port> <outputFile> <user> <password> <language> <syndication map> <client system> ");
System.exit(-1);
}
//Construct a Command to be executed
String COMMAND = """+SYN_BAT_DIR+""+SYN_BAT_EXE+"" -f ""+outputFile+"" -o "+
" -s "+host+" -p "+port+" -u "+user+" -w "+password+
" -r ""+language+" " -a "+clientSystem+" -n "+synMap;
//Make sure command is constructed correctly
System.out.println("COMMAND: "+COMMAND);
Runtime rt = Runtime.getRuntime();
try {
//Execute Command
Process proc = rt.exec(COMMAND,null,new File(SYN_BAT_DIR));
//Buffer console output
BufferedReader consoleOutput = new BufferedReader(new InputStreamReader(proc.getErrorStream()));
String str = null;
//Show buffred output to console
while((str = consoleOutput.readLine()) != null) {
System.out.println(str);
}
int retVal = proc.exitValue();
System.out.println("Syndicator Batch Exited with Return Code "+retVal);
} catch (IOException e) {
System.out.println("Error in Syndicator Batch Location "+SYN_BAT_DIR);
e.printStackTrace();
}
}
}

Compile this java code and running it will invoke Syndicator Batch dynamically and you can add your own functionality to enhance it.

Share this:
Share this page via Email Share this page via Stumble Upon Share this page via Digg this Share this page via Facebook Share this page via Twitter
   Send article as PDF   
Posted in Uncategorized | Tagged | Leave a comment

Referencing the MDM Java API during development and runtime

How to reference the MDM Java API during development and runtime

Although there are several ways to include and reference the MDM Java API in your Java projects, I am describing here the best practice of doing it.

Use case

Typically your Java application will be deployed on the SAP NetWeaver Application Server, either as a J2EE or Web Dynpro application. The JAR files of the API should not be included in the application archive itself, but rather referenced only – both during development and runtime. The API is deployed as a library on the application server. This gives you the possibility to easily update the API:

  • On the application server by simply deploying a new version of the API. This can be done by an admin without the help of a developer.
  • On the machines used for development without the need to update several projects.
Download the MDM Java API

You find the JAR files in the archive MDMJavaAPI_Ver<build-number>.zip on the installation media you received. You can download it also, especially important after an update of the MDM Server, from the SAP Service Marketplace: http://service.sap.com/swdc

-> Download
-> Support Packages and Patches
-> Entry by Application Group
-> SAP NetWeaver
-> SAP MDM
-> SAP MDM 5.5
-> MDM JAVA API

During development in NWDS

  1. Unpack the archive with the JAR files and the Javadoc of the MDM Java API on your PC. Copy or move all the JAR files into any folder. Always use the same folder name every time you update to a new version. Example folder name: C:\MDMJavaAPI

  2. In the Preferences dialog of the NWDS, go to JavaClasspath Variables and create a new variable with the name SAP_MDM_JAVA_API and the path set to the folder of step 1.

  3. In the properties dialog of your NWDS project, go to Java Build PathLibraries and add each JAR file of the API using the Add Variable button. You need to select the variable created in step 2, click on Extend and select all 6 JAR files (mdm4j.jar, mdm-admin.jar, mdm-common.jar, mdm-core.jar, mdm-data.jar, mdm-protocol.jar).

  4. If you are developing an J2EE application: Open the deployment descriptor application-j2ee-engine.xml and create a reference to the MDM Java API using the values:

    – Reference target: com.sap.mdm.tech.mdm4j

    – Reference type: hard

    – Reference target type: library

    – Provider name: sap.com

  5. If you are developing a Web Dynpro application: Open the properties dialog of the project, go to Web Dynpro ReferencesLibrary Referencesand add a new entry for the MDM Java API using the name com.sap.mdm.tech.mdm4j.

Deploy on the application server

Deploy the MDM Java API using the SCA named MDMJAVAAPI<SP-number>_<Patch-number>.sca.

Share this:
Share this page via Email Share this page via Stumble Upon Share this page via Digg this Share this page via Facebook Share this page via Twitter
   Send article as PDF   
Posted in SAP MDM Tutorials | Leave a comment