on 02-15-2006 3:57 PM
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.
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
}
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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.
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.
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
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...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.