cancel
Showing results for 
Search instead for 
Did you mean: 

accessing MDM using JAVA APIs

brahmanandam_ausali
Participant
0 Kudos

hi all,

i am new to MDM,

i want to connect MDM using java,

i have APIs with me,

can any body please tell me the step by step procedure to connect to MDM or links to the docs.

thanks,

regards,

Brahmanandam Ausali.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Sorry, this is the solution

package com.sap.nwrig.MDM.workshop;

import a2i.common.CatalogData;

import a2i.core.StringException;

import a2i.generated.RC;

public class Exercise_1_Solution {

static private CatalogData catalog = null;

static private String hostname = "BOGN00408258A";

static private int port = 2345;

static private String username = "Admin";

static private String password = "";

static private String language = "English [US]";

public static void main(String[] args) {

//

// login

//

// create catalogdata object

catalog = new CatalogData();

// try logging in

// NOTE: CatalogData.Login() will also throw a java.net.ConnectException

int resultLogin = catalog.Login(hostname, port, username, password, language);

if (resultLogin != RC.RC_OK) {

System.out.println(

"Error logging into MDME server: " + RC.GetTextForError(resultLogin) + " (" + resultLogin + ")");

System.exit(-1);

}

System.out.println("Logged into MDME server.\n");

//

// status

//

// get information on the current catalog connection

System.out.println("Status of server:\n");

System.out.print("\t Status of catalog connection: ");

int resultReadyStatus = catalog.GetReadyStatus();

switch (resultReadyStatus) {

case CatalogData.READY_STATE_CONNECTED :

System.out.println("connected");

break;

case CatalogData.READY_STATE_CONNECTING :

System.out.println("connecting");

break;

case CatalogData.READY_STATE_DISCONNECTED :

System.out.println("disconnected");

break;

default :

System.out.println("unknown status " + resultReadyStatus);

break;

}

// display some catalog information

System.out.println("\t Connections: " + catalog.GetConnectionCount());

System.out.println("\t Server: " + catalog.GetServer());

System.out.println("\t Port: " + catalog.GetPort());

System.out.println("\t User: " + catalog.GetUser());

System.out.println("\t Software version: " + catalog.GetSoftwareVersion());

System.out.println();

// status call to catalog

int resultStatus = catalog.CatalogStatus(hostname, port, username, password);

System.out.println("Status of catalog: " + RC.GetTextForError(resultStatus) + " (" + resultStatus + ")\n");

//

// logout

//

// catch possible exception

try {

catalog.Logout();

System.out.println("Logged out of MDM server.");

} catch (StringException e) {

System.out.println("Error logging out of MDM server: " + e.getMessage());

} finally {

// exit the console application

}

}

}

brahmanandam_ausali
Participant
0 Kudos

hello Mario Galvis.

can u please tell me, what are the settings need to be done in NDS, and the jars to be added in my project.

i have some sda files, is it necessary to deploy them on to the J2EE server.

thanks,

regards ,

Brahmanandam Ausali.

Former Member
0 Kudos

Hello brahmanandam:

The only thing you have to do is add the MDM4J.jar.

The sda files are a support package in this case specifically for Enterprise Portal features.

Chao...

Mario Galvis

Former Member
0 Kudos

Hi,

You need to put the MDM4J.jar file in the CLASSPATH, which comes along with the software.

Regarding the sda files:

<b>First of all which version of MDM u are using ?</b>

You need to deploy the SDA's/SCA's , if at all you want to use /develop the iviews for Portal.

Thanks and Regards

Subbu

brahmanandam_ausali
Participant
0 Kudos

hi all,

thanks for your quick reply.

i developed stand alone java application,

i added the jars into the class path,

on running the application i am getting the following error,

ClientSocket.Login error

No message for RC (0xffaa0200) (-5635584)

can u please tell me what could be the reason.

thanks,

regards,

Brahmanandam ausali

Former Member
0 Kudos

Hi,

Please make sure that you are using jar file compatible to the Server version you have.

Regards,

Rajani

brahmanandam_ausali
Participant
0 Kudos

hi rajani,

i am using both of same version.

thanks and regards ,

brahmanandam ausali

Former Member
0 Kudos

Hi,

Check the following.

1. Whether repository is running or not.

2. Make sure you entered the correct port number or not.

Let me know if you still have problems.

Thanks and Regards

Subbu

brahmanandam_ausali
Participant
0 Kudos

hi friends,

thanks to you all, now i could connect to the MDM

repository seccess fully, the problem was there

with wrong port number.

Now, i want to explore more on the MDM APIs ie the functionalities it provides, for instance getting tables in the repository, inserting,deleting,updating records in to the table.

valuable suggestions appreciated.

thanks and regards,

Brahmanandam Ausali.

Former Member
0 Kudos

Hi,

To display the list of tables, please use the following code after the login method.

CMTableInfoArray tables = catalog.GetTables();

int tablesCount = tables.GetSize();

for (int i=0;i<tablesCount ;i++ )

{

CMTableInfo tableInfo = tables.GetCMTableInfoAt(i);

System.out.print(info.GetName());

System.out.println("\t -->" + CMTableType.GetTableTypeAsString(info.GetType()));

}

For Add,Modify and delete:

use the CatalogData's <b>AddRecord()</b>, <b>UpdateRecord()</b> and <b>DeleteRecords()</b> method

Thanks

Subbu.

Former Member
0 Kudos

I am still getting errors:

D:\SAP\workspace\MDMConnectionTest\source\com\sap\mdm\api\adm\test>javac MDMConnection.java

MDMConnection.java:15: package a2i.common does not exist

import a2i.common.CatalogData;

^

MDMConnection.java:16: package a2i.core does not exist

import a2i.core.StringException;

^

MDMConnection.java:17: package a2i.generated does not exist

import a2i.generated.RC;

^

MDMConnection.java:21: cannot resolve symbol

symbol : class CatalogData

location: class com.sap.mdm.api.adm.test.MDMConnection

static private CatalogData catalog = null;

^

MDMConnection.java:35: cannot resolve symbol

symbol : class CatalogData

location: class com.sap.mdm.api.adm.test.MDMConnection

catalog = new CatalogData();

^

MDMConnection.java:40: cannot resolve symbol

symbol : variable RC

location: class com.sap.mdm.api.adm.test.MDMConnection

if (resultLogin != RC.RC_OK) {

^

MDMConnection.java:42: cannot resolve symbol

symbol : variable RC

location: class com.sap.mdm.api.adm.test.MDMConnection

"Error logging into MDME server: " + RC.GetTextForError(resultLogin) + " (" + resultLogin + ")");

^

MDMConnection.java:56: cannot resolve symbol

symbol : variable CatalogData

location: class com.sap.mdm.api.adm.test.MDMConnection

case CatalogData.READY_STATE_CONNECTED :

^

MDMConnection.java:59: cannot resolve symbol

symbol : variable CatalogData

location: class com.sap.mdm.api.adm.test.MDMConnection

case CatalogData.READY_STATE_CONNECTING :

^

MDMConnection.java:62: cannot resolve symbol

symbol : variable CatalogData

location: class com.sap.mdm.api.adm.test.MDMConnection

case CatalogData.READY_STATE_DISCONNECTED :

^

MDMConnection.java:79: cannot resolve symbol

symbol : variable RC

location: class com.sap.mdm.api.adm.test.MDMConnection

System.out.println("Status of catalog: " + RC.GetTextForError(resultStatus) + " (" + resultStatus

+ ")\n");

^

MDMConnection.java:89: cannot resolve symbol

symbol : class StringException

location: class com.sap.mdm.api.adm.test.MDMConnection

} catch (StringException e) {

^

12 errors

Former Member
0 Kudos

How can we use your solution to display content from the table?

Former Member
0 Kudos

After the program ran correct the first time, when I ran it a second time I get the following error message:

Error logging into MDME server: No message for RC (0x8002000e) (-2147352562)

What that means? And How can I fix it?

Former Member
0 Kudos

Look at my message in this topic:

Answers (1)

Answers (1)

Former Member
0 Kudos

Hello:

This is an example of a connection to MDM repository:

package com.sap.nwrig.MDM.workshop;

import a2i.common.CatalogData;

import a2i.core.StringException;

import a2i.generated.RC;

public class Exercise_1 {

static private CatalogData catalog = null;

//TODO specify MDM server and catalog information

static private String hostname = "BOGN00408258A";

static private int port = 2345;

static private String username = "Admin";

static private String password = "";

public static void main(String[] args) {

int resultLogin = -1;

//

// login

//

// TODO create catalogdata object

// try logging in

// NOTE: CatalogData.Login() will also throw a java.net.ConnectException

//TODO login and capture return code

if (resultLogin != RC.RC_OK) {

System.out.println(

"Error logging into MDM server: " + RC.GetTextForError(resultLogin) + " (" + resultLogin + ")");

System.exit(-1);

}

System.out.println("Logged into MDM server.\n");

//

// status

//

// get information on the current catalog connection

System.out.println("Status of server:\n");

System.out.print("\t Status of catalog connection: ");

int resultReadyStatus = catalog.GetReadyStatus();

switch (resultReadyStatus) {

case CatalogData.READY_STATE_CONNECTED :

System.out.println("connected");

break;

case CatalogData.READY_STATE_CONNECTING :

System.out.println("connecting");

break;

case CatalogData.READY_STATE_DISCONNECTED :

System.out.println("disconnected");

break;

default :

System.out.println("unknown status " + resultReadyStatus);

break;

}

// TODO display some catalog information: user, port, server

System.out.println("\t Connections: " + catalog.GetConnectionCount());

System.out.println("\t Software version: " + catalog.GetSoftwareVersion());

System.out.println();

// status call to catalog

int resultStatus = catalog.CatalogStatus(hostname, port, username, password);

System.out.println("Status of catalog: " + RC.GetTextForError(resultStatus) + " (" + resultStatus + ")\n");

//

// logout

//

// catch possible exception

try {

//TODO call logout method

catalog.Logout();

System.out.println("Logged out of MDM server.");

} catch (StringException e) {

//TODO display an error message

} finally {

// exit the console application

System.exit(0);

}

}

}

Chao...