Skip to Content
author's profile photo Former Member
Former Member

Retrieve Data using Java API

Hi,

I am trying to use Java API to retrieve data from SAP MDM.

  • I am able to connect to the MDM Repository and login to the User Session, but I am not able to retrieve the records, as Java API's requires the Table Id to retrieve the records from the server.

Can any one please let me know, how to retrieve the TableId, when Table Name is given as input to the program.

I am using MDM Version 5.5 SP5 (5.5.40.83).

Thanks in advance.

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Mar 26, 2008 at 07:02 AM

    Hi venkat,

    Please check it once

    // create connection pool to a MDM server

    String tag = "LOCALHOST";

    ConnectionPool connections = null;

    try {

    connections = ConnectionPoolFactory.getInstance(tag);

    } catch (ConnectionException e) {

    e.printStackTrace();

    return;

    }

    // specify the repository to use

    // alternatively, a repository identifier can be obtain from the GetMountedRepositoryListCommand

    String repositoryName = "TestRepos";

    String dbmsName = "LOCALHOST";

    RepositoryIdentifier reposId = new RepositoryIdentifier(repositoryName, dbmsName, DBMSType.MS_SQL);

    // create a repository session

    CreateRepositorySessionCommand sessionCommand = new CreateRepositorySessionCommand(connections);

    sessionCommand.setRepositoryIdentifier(reposId );

    try {

    sessionCommand.execute();

    } catch (CommandException e) {

    e.printStackTrace();

    return;

    }

    String sessionId = sessionCommand.getRepositorySession();

    // authenticate the repository session

    String userName = "Admin";

    String userPassword = "";

    AuthenticateRepositorySessionCommand authCommand = new AuthenticateRepositorySessionCommand(connections);

    authCommand.setSession(sessionId);

    authCommand.setUserName(userName);

    authCommand.setUserPassword(userPassword);

    try {

    authCommand.execute();

    } catch (CommandException e) {

    e.printStackTrace();

    return;

    }

    // retrieve the list of tables and pick the main table

    GetTableListCommand tableListCommand = new GetTableListCommand(connections);

    tableListCommand.setSession(sessionId);

    try {

    tableListCommand.execute();

    } catch (CommandException e) {

    e.printStackTrace();

    return;

    }

    TableProperties mainTable = null;

    TableProperties[] tables = tableListCommand.getTables();

    for (int i = 0; i < tables.length; i++) {

    if (tables<i>.getType() == TableProperties.MAIN)

    mainTable = tables<i>;

    }

    // retrieve the list of fields from the main table

    // this is useful for resolving conflicting field names the new field might create

    GetFieldListCommand getFieldListCommand = new GetFieldListCommand(connections);

    getFieldListCommand.setSession(sessionId);

    getFieldListCommand.setTableId(mainTable.getId());

    try {

    getFieldListCommand.execute();

    } catch (CommandException e) {

    e.printStackTrace();

    return;

    }

    Please follow these code

    I think it may help u.

    Regards

    Hari

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 25, 2008 at 03:20 PM

    Hi,

    Here is one solution:

    Use the GetRepositorySchemaCommand() to get a RepositorySchema object, and store it at application scope. Now you can use the

    getTableId(java.lang.String tableCode) and getFieldId(java.lang.String tableCode, java.lang.String fieldCode) functions to lookup table and field ID's for other commands that require them.

    Walter

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.