Skip to Content
This example uses a portal component which opens a connection to a repository running on MDM Server,
retrieves data from the repository, and closes the connection.
There are 5 steps we will implement:

  1. Set the connector libraries in the deployment descriptor file portalapp.xml
  2. Open a connection to a repository
  3. Get the physical connection via the native interface
  4. Get data from a repository
  5. Close the connection

Step 1: configure the potalapp.xml file

The MDME Connector uses the SAP Connector Framework and MDME4J libraries as a shared library.
You need to add these libraries into portalapp.xml.

&ltapplication> &ltapplication-config> &ltproperty name="SharingReference" value="com.sap.portal.pcd.glservice, com.sap.portal.ivs.connectorservice, SAPJ2EE::library:MDME4J"/> </application-config> </application>

Step 2 : Open a connection to a repository (using the connector gatway service)

The useful EP6 features of system object aliases and single=sign-on user mapping are available
only by using the Connector Gatway Services approach.

// Get the Connector Gateway Service IConnectorGatewayService cgService = (IConnectorGatewayService) PortalRuntime.getRuntimeResources().getService( IConnectorService.KEY); // Create ConnectionProperties for portal user ConnectionProperties prop = new ConnectionProperties(request.getLocale(), request.getUser()); // Get a connection IConnection connection = cgService.getConnection("MDME_SYSTEM_ALIAS_NAME", prop);

Step 3: Get the physical connection via the native interface

Retrieve the native interface from the connection, and invoke getNative method.

// Retrieve Native inteface INative nativeInterface = connection.retrieveNative(); // Get the CatalogData the physical connection CatalogData catalog = (CatalogData) nativeInterface.getNative(CatalogData.class.getName());

Step 4: Get data from a repository

All methods of the CatalogData object are available for retrieving data.
The following code uses the GetResultSet method as an example.

// Create ResultSetDefinition for products table ResultSetDefinition rsd = new ResultSetDefinition("Products"); rsd.AddField("Name"); // Create Search for products table Search search = new Search("Products"); // Get Data from table A2iResultSet rs = catalog.GetResultSet(search, rsd, "Name", true, 0);

Step 5:Close the connection

connection.close();
To report this post you need to login first.

5 Comments

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

  1. Darrell Huffman
    The new sp2 version of MDM 5.5 offers portal iViews and templates.that connect already…providing searches on free form text, hierarchial and attribute, as well as a pick list.
    (0) 
    1. Udi Katz Post author
      Hi Darrell,

      you are correct that the SP2 coes with MDM iviews.

      This code example comes to show how to use the Java API if you want to extend the current available iviews or create some new features.

      Regards,
                Udi

      (0) 
  2. S. Valkenburg
    Hi,
    I have deployed the com.sap.mdm.tech.mdm4j.sda with and want to make a connection from a session bean to MDM. And I want to implement the “How to use the MDM Java Connector in SAP Web As”. But I am facing a problem with finding the connectionFactory.getConnectionSpec() method because it isn’t there in the MDM4J.JAR. I only have the com.a2i.xcat.internal.connections.IConnectionFactory getInstance(int) method. It seems to me that the connection has been changed from sp2 to sp5

    Regards,
    Sander Valkenburg

    (0) 
  3. Quan Tan
    Udi, Great blog!

    When I use NW Developer Studio (2.0.16) to try out the example, I entered a problem with shared applications “com.sap.portal.pcd.glservice,com.sap.portal.ivs.connectorservice” not starting.

    The EP6 is SP16 on windows2003. Would this be a problem with the EP6 or anything else? Thanks.


    => deployed with warning : file:/C:/DOCUME~1/020413/LOCALS~1/Temp/temp18884Test.ear
    Finished with warnings: development component ‘Test’/’local’/’LOKAL’/’0.2006.06.15.23.30.35’:
    Caught exception during application startup from SAP J2EE Engine’s deploy service:
    java.rmi.RemoteException: Error occurred while starting application local/Test and wait. Reason: Clusterwide exception: server ID 2336150:com.sap.engine.services.deploy.container.DeploymentException: Clusterwide exception: Failed to prepare application ”local/Test” for startup. Reason=Clusterwide exception: Failed to start application ”local/Test”: The referenced application ”com.sap.portal.pcd.glservice,com.sap.portal.ivs.connectorservice” can”t be started. Check the causing exception for details. Hint: Is the referenced application deployed correctly on the server?
         at com.sap.engine.services.webdynpro.WebDynproContainer.prepareStart(WebDynproContainer.java:1421)
         at com.sap.engine.services.deploy.server.application.StartTransaction.prepareCommon(StartTransaction.java:239)
         at com.sap.engine.services.deploy.server.application.StartTransaction.prepare(StartTransaction.java:187)
         at com.sap.engine.services.deploy.server.application.ApplicationTransaction.makeAllPhasesOnOneServer(ApplicationTransaction.java:301)
         at com.sap.engine.services.deploy.server.application.ParallelAdapter.makeAllPhasesImpl(ParallelAdapter.java:327)
         at com.sap.engine.services.deploy.server.application.ParallelAdapter.runInTheSameThread(ParallelAdapter.java:111)
         at com.sap.engine.services.deploy.server.application.ParallelAdapter.makeAllPhasesAndWait(ParallelAdapter.java:230)
         at com.sap.engine.services.deploy.server.DeployServiceImpl.startApplicationAndWait(DeployServiceImpl.java:4700)
         at com.sap.engine.services.deploy.server.DeployServiceImpl.startApplicationAndWait(DeployServiceImpl.java:4605)
         at com.sap.engine.services.deploy.server.DeployServiceImpl.startApplicationAndWait(DeployServiceImpl.java:4578)
         at com.sap.engine.services.deploy.server.DeployServiceImplp4_Skel.dispatch(DeployServiceImplp4_Skel.java:1163)
         at com.sap.engine.services.rmi_p4.DispatchImpl._runInternal(DispatchImpl.java:304)
         at com.sap.engine.services.rmi_p4.DispatchImpl._run(DispatchImpl.java:193)
         at com.sap.engine.services.rmi_p4.server.P4SessionProcessor.request(P4SessionProcessor.java:122)
         at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
         at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
         at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
         at java.security.AccessController.doPrivileged(Native Method)
         at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100)
         at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170)

    (0) 

Leave a Reply