Skip to Content
In my previous Weblog MDM connectivity to java application. I have introduced the SAP MDM connector.
In this Weblog I will go deeper and show how to establish a connection and retrieve data from MDM using the connector APIs.

The classes in the MDM Java library expose the functionality of the MDM catalog to a java application. The main functionality are:

  1. Establishing connection
  2. catalog data model,
  3. multi-dimensional search
  4. catalog data retrieval
  5. catalog data management.

The main class in the library is the CatalogData class, which exposes all the services of the MDM Server.
Among the services that it provides outside of those of the MDM catalog itself are a local catalog data cache,
a pool of MDM Server connections, and full thread-safety. Other objects in the library exist to support the
CatalogData class. They are either used as arguments to methods or return values for methods and properties
of the CatalogData class.

The following code shows how to retrieve categories from the MDM repository.

Step 1: Obtain a connection to the MDM repository.
1.1 get the context :
Context ctx = new InitialContext();

1.2 lookup in the JDNI to get the connection factory class
IConnectionFactory connectionFactory = (IConnectionFactory)ctx.lookup(“deployedAdapters/MDMEFactory/shareable/MDMEFactory”);

1.3 Get Connection Spec to set connection properties
IConnectionSpec spec = connectionFactory.getConnectionSpec();

1.4 Set Connection Properties
spec.setPropertyValue(“UserName”, “Administrator”);
spec.setPropertyValue(“Password”, “123456”);
spec.setPropertyValue(“Server”, “server1”);
spec.setPropertyValue(“Port”, “50000”);
spec.setPropertyValue(“RepositoryLanguage”, “Chinese [HK]”);

1.5 Get the Connection
IConnection connection = connectionFactory.getConnectionEx(spec);

Step 2 : obtain access to the native object

2.1 Retrieve Native inteface
INative nativeInterface = connection.retrieveNative();

2.2 Get the CatalogData the physical connection
CatalogData catalog = (CatalogData) nativeInterface.getNative(CatalogData.class.getName());

Step 3: Retrieve data from Catalog

3.1 Create ResultSetDefinition for products table
ResultSetDefinition resultdefenition = new ResultSetDefinition(“Categories”);

3.2 Create Search object for Categories table
Search search = new Search(“Categories”);

3.3 Get Data from repository.
A2iResultSet rs = catalog.GetResultSet(search, resultdefenition, “Id”, true, 0);

Once we have all the data in the result set, one can do manipulation on it and retrieve the data.

Step 4: Close the connection

The last step is configuration:
Step 5: Set the connector libraries in the application-j2ee-engine.xml file

The MDME Connector uses the SAP Connector Framework and MDME4J libraries as a shared library.
You need to add these libraries into the application-j2ee-engine.xml file.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE application-j2ee-engine SYSTEM "application-j2ee-engine.dtd"> &ltapplication-j2ee-engine> &ltreference reference-type="hard"> &ltreference-target provider-name="" target-type="library"> tc/conn/connectorframework </reference-target> </reference> &ltreference reference-type="hard"> &ltreference-target provider-name="" target-type="library">MDME4J</reference-target> </reference> &ltprovider-name&</provider-name> &ltfail-over-enable mode="disable"/> </application-j2ee-engine>
To report this post you need to login first.


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

  1. Former Member
    I’ve installed MDM sp2, and the JNDI path you use above is incorrect for this particular version.  Using the Visual Administrator, the path that I see is as follows:

    deployedAdapters/MDM Factory/shareable/MDM Factory

    Yes, there are embedded spaces in the path.  However, doing a lookup with the above path with the spaces removed will find the factory object.

    When using the DevStudio, what application libs do I have to reference to have access to IConnectionFactory, IConnectionSpec, IConnection, and INative?


      1. Former Member Post author
        Hi Ken,

        The classes you described : IConnectionFactory, IConnectionSpec, IConnection, and INative
        are a part of this package: com.sapportals.connector.connection
        and it is a part of the GenericConnector.jar



Leave a Reply