Modifying record in MDM using JAVA API

hello all
I have created record in MDM using JAVA API now I want to update record using API. I used ModifyRecordCommand. But this requires input as Record but I have RecordID of the record to be modified. How do I get Record value from RecordID.

Hi,
                  You can use RetrieveRecordsByIdCommand to get the record by Record Id.
            RetrieveRecordsByIdCommand recordbyidcom = new  RetrieveRecordsByIdCommand(con);
            recordbyidcom.setSession(session);
            recordbyidcom.addId(recordid);
            recordbyidcom.setResultDefinition(resultdefinition);
            recordbyidcom.execute();
            RecordResultSet rs = recordbyidcom.getRecords();
            Record record = rs.getRecord(0);
            //Modify the record
            record.setFieldValue(fieldid,value);
            ModifyRecordCommand modify = new ModifyRecordCommand(con);
            modify.setSession(session);
            modify.setRecord(record);
            modify.execute();
Regards,
Sreenivasulu Thimmanapalli.
Edited by: Sreenivasulu Thimmanapalli on Dec 8, 2008 2:36 AM

Similar Messages

  • Req. Sample code for the Updation of Master record in MDM using Java API..

    Hi All,
    Can anyone provide me the same code for Updation of master record in MDM using Java API ??

    Hi SakthiNarayananD,
    You can additionally go through the following links to work with MDM and Java API:
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/2d18d355-0601-0010-fdbb-d8b143420f49  (Java API)
    http://help.sap.com/javadocs/MDM/SP05/(Java api programs)
    https://help.sap.com/javadocs/MDM/current/index.html  (java api codes)
    http://help.sap.com/javadocs/MDM/SP06P2/index.html (Java Docs for SP06)
    Reg: Using JAVA API - Search
    Re: Retrieving Drop Down List Value using JAVA API - Lookup values
    How to retreive records from Lookuptable of type flat - Lookup Values
    Reg: MDM with webdynpro - READ,INSERT,MODIFY
    Hope It Helped
    Thanks & Regards
    Simona Pinto

  • How to retrieve data from MDM using java API

    hi experts
    Please explain me the step by step procedure
    how to retrieve data from MDM using java API
    and please tell me what are the
    important classes and packages in MDM Java API
    thanks
    ramu

    Hi Ramchandra,
    You can refer to following links
    MDM Java API-pdf
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/2d18d355-0601-0010-fdbb-d8b143420f49
    webinr of java API
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/89243c32-0601-0010-559d-80d5b0884d67
    Following Fourm Threads will also help.
    Java API
    Java API
    Re: usage of  java API ,
    Matching Record
    Need Java API for Matching Record
    Thanks and Regards,
    Shruti.
    Edited by: Shruti Shah on Jul 16, 2008 12:35 PM

  • Search for a Multilingual value in MDM using JAVA API

    Good day,
    Could you kindly assist.
    I am trying to search for a field in MDM, from Portal using JAVA API. I do retrieve the value in English, but the problem is when I am trying to retrieve it in other languages. Please see sample code:
         private Search getSearch(MDMConnection mdmconnection,String value, TableId tableid){
              Search search =null;
              FieldSearchDimension fielddimension=null;
              TextSearchConstraint textcontrain=null;
              RepositorySchema reposchema =mdmconnection.reposchema;          
                                               if(value!=null)
                   search= new Search(tableid);
                   fielddimension=new FieldSearchDimension(reposchema.getFieldId("ATTR_VAL_ABBR","TEXT_VALUE"));
                   textcontrain=new TextSearchConstraint(value,TextSearchConstraint.EQUALS);
                   search.addSearchItem(fielddimension,textcontrain);
                   search.setComparisonOperator(Search.AND_OPERATOR);
              return search;
    Thank you in advance.
    Regards,
    Simni

    Hi ,
    Mdm- Multilingual value in MDM using JAVA API:
    you can check the first point as its reagrdign youisue related pdf and soloutions for your question.
    1.  http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/b0e8aedc-cdfe-2c10-6d90-bea2994455c5?QuickLink=index&overridelayout=true
    2.  http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/b0e8aedc-cdfe-2c10-6d90-bea2994455c5?QuickLink=index&overridelayout=true
    Hope this information helps you in solving the  issue!!
    Thanks&Regards
    AswinChandraGirmaji

  • Need help to create a new record in mdm using java webdynpro

    hi all,
    I have to develop an application to create a new record in mdm by using java WebDynpro  . Please help me what is the process that i have to follow to do this and provide me if you have any step by step guidance for this.
    thanks & regards,
    Mahi.

    Hi,
    The below link will help u to make the application in JAVA webdynpro
    The article has code to for creating records.
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/803e9e80-21f4-2a10-8cbf-bcf6a8060be3
    Hope this may help u .
    Rgds
    Ankit

  • How to send records to the MDM workflow using Java APIs

    Hi All,
        Using Java APIs i want to send group/single records to the backend MDM workflows for further processing. Can this be acheived? Please provide me with some code samples if you have any
    Regards
    Suresh

    Hi,
    Just go through this URL
    https://help.sap.com/javadocs/MDM/current/index.html
    In this <b>com.sap.mdm.workflow.commands </b> will Provide u commands for managing workflows.
    I hope this helps you.
    Regards
    Nisha
    Message was edited by:
            Nisha Lalwani

  • Iterate through all the records in a table using Java API

    Hi All,
    What is the easiest way to iterate through all the records in a given table using Java API? I cannot find any methods that will return all records in a table and the only way I can use is to perform a free form search with a condition that is always true. The code works but is pretty ugly. Is there an alternative to this approach?
    Thanks!
    Kenny

    Hi Kenny,
    You can construct a new Search object with your table's code name, a new ResultSetDefinition object for your table and just execute this search using the GetResultSet method of CatalogData.
    Please look at the following code:
    Search search = new Search(<code name of your table>);
    ResultSetDefinition rsd = new ResultSetDefinition(<code name of your table>);
    rsd.AddField<code name of a field>);
    rsd.AddField(<code name of a field>);
    String sortField = <code name of your sort field>;
    boolean sortAscending = true;
    int page = 0; //page number
    A2iResultSet rs = <your CatalogData object>.GetResultSet(search, rsd, sortField, sortAscending, page);
    for (int i = 0; i < rs.GetRecordCount(); i++)
        Value fieldValue = rs.GetValueAt(i, <code name of a field>);
    Hope this helps,
    Nir
    PS - I really recommend you to start using the new API, as it is much more efficient and straight-forward.

  • How to upload Image to MDM 5.5 SP3 using Java APIs

    Hi,
    I am trying to upload Image to Images table in MDM 5.5 using JAVA API for MDM. But. I'm not able to find particular field in Images table where I need to set the Blob object ( Image data ).
    I'm not aware of the method to set the Blob, there is one for getting the Image data.
    I have gone through I am not able to add images into Catalog thru java API forums posts and tried the code. But with no luck....
    I think this code is for some other MDM version as the fields mentioned are not present in the Images table e.g. DataObject - this field is used in the above posts to set the Blob data but this field does not exist in Images table in MDM 5.5
    Can anyone suggest the solution?
    Thanks and Regards,
    Mausam

    Hi Mausam,
    Please try the following:
    // adding to a image table
    // get the bytes for the image
    byte[] imageBuf = readFile("C:\pic.bmp");
    // setup A2iFields
    fields = new A2iFields();
    fields.Add(new A2iField("DataObject", new
    Value(imageBuf))); // the image binary (required)
    fields.Add(new A2iField("Name", new Value("pic.bmp")));
    // a name for the image
    fields.Add(new A2iField("OrigName", new
    Value("pic.bmp"))); // the original image file name
    (required)
    fields.Add(new A2iField("DataGroupId", new Value(888)));
    // the data group to add to (required)
    fields.Add(new A2iField("OrigLocationId", new
    Value(999))); // the data location of the image
    (required)
    fields.Add(new A2iField("Description", new Value("a
    short description"))); // a short description here
    // add the image
    String imageTable = "Images";
    catalog.AddRecord(imageTable, fields, -1, -1);
    It's taken out of the API guide for SP3 (the example for method AddRecord.
    Best regards,
    Amit

  • Uploading images whit thumbnail to MDM repository using Java API

    Hello,
    can someone tell me how to upload images whit thumbnail to MDM repository using Java API?
    i get following message using setHasThumbnail(true):
    com.sap.mdm.commands.CommandException: com.sap.mdm.internal.protocol.manual.ServerException: Ungültiger Wert für Parameter
    thanks

    You can upload images to MDM via the API, but the only way to create thumbnails is via the MDM Data Manager application which uses some embedded libraries to do the work.
    Walter

  • Need help in getting MDM relationship details using Java Apis

    Hi,
    Is it possible to search records which are in relationship using Java Apis? Suppose Record A is Parent record and Record B,C,D ... are child records.
    I have to search all the records which are in relationship with record A.
    Can any one send code snippet on this.
    Regards,
    Niraj

    Hi Niraj,
    You can use RetrieveRelationshipsCommand api to get the relationship child of the Anchor Record.
    RetrieveRelationshipsCommand command = new RetrieveRelationshipsCommand(connectionAccesor);
    command.setSession(session);
    command.setAnchorRecord(anchorRecord); / command.setAnchorRecordId(anchorRecordId); (use any of the two statements)
    command.setRelationship(relationshipId); //For child int type is 10, and for Parent_child int type is 5
    command.setMemberResultDefinition(resultDefinition);
    command.execute();
    //Get Member Records' resuld definition
    ResuldDefinition rd = command.getMemberResultDefinition();
    Hope this helps you.

  • Need Sample Code for Vendor creation using JAVA API

    Hi,
    I have a scenario like Vendor creation using <b>Java API</b>.
    1.I have Vendors (Main) Table.
    2.I have <b>look up</b> tables like Account Group.
    3.Also <b>Qualifier table</b>(Phone numbers) too.
    Could you please give me the sample code which helps me to create Vendor records using Java API?
    <b>I need Code samples which should cover all of the above scenario.</b>
    <b>Marks will be given for the relevent answers.</b>
    Best Regards
    PK Devaraj

    Hi Devraj,
    I hope the below code might solve all your problem:-
    //Adding Qualified field
    //Creating empty record in Qualifed table 
    //Adding No Qualifiers
    Record qualified_record = RecordFactory.createEmptyRecord(new TableId(<TableId>));
    try {
    qualified_record.setFieldValue(new FieldId(<fieldId of NoQualifier), new StringValue(<StringValue>));//Adding No Qualifier
    catch (IllegalArgumentException e2) {
    // TODO Auto-generated catch block
    e2.printStackTrace();
    catch (MdmValueTypeException e2) {
    // TODO Auto-generated catch block
    e2.printStackTrace();
    //Creating Record in Qualified table
    CreateRecordCommand create_command = new CreateRecordCommand(connections);
    create_command.setSession(sessionId);
    create_command.setRecord(qualified_record);
    try
    create_command.execute();
    catch(Exception e)
    System.out.println(e.toString());
    RecordId record_id = create_command.getRecord().getId();
    //Adding the new record to Qualifed Lookup value and setting the Yes Qualifiers
    QualifiedLookupValue lookup_value = new QualifiedLookupValue();
    int link = lookup_value.createQualifiedLink(new QualifiedLinkValue(record_id));
    //Adding Yes Qualifiers
    lookup_value.setQualifierFieldValue(0 , new FieldId(<FieldID of Yes Qualifier>) , new StringValue(<StringValue>));
    //Now adding LookUP values
    //Fetch the RecordID of the value selected by user using the following function
    public RecordId getRecordID(ConnectionPool connections , String sessionID , String value , String Fieldid , String tableid)
    ResultDefinition rsd = new ResultDefinition(new TableId(tableid));
    rsd.addSelectField(new FieldId(Fieldid));
    StringValue [] val = new StringValue[1];
    val[0] = new StringValue(value);
    RetrieveRecordsByValueCommand val_command = new RetrieveRecordsByValueCommand(connections);
    val_command.setSession(sessionID);
    val_command.setResultDefinition(rsd);
    val_command.setFieldId(new FieldId(Fieldid));
    val_command.setFieldValues(val);
    try
         val_command.execute();
    catch(Exception e)
    RecordResultSet result_set = val_command.getRecords();
    RecordId id = null;
    if(result_set.getCount()>0)
         for(int i = 0 ; i < result_set.getCount() ; i++)
         id = result_set.getRecord(i).getId();     
    return id;
    //Finally creating the record in Main table
    com.sap.mdm.data.Record empty_record = RecordFactory.createEmptyRecord(new TableId("T1"));
    try {
         empty_record.setFieldValue(new FieldId(<FieldId of text field in Main table>),new StringValue(<StringValue>));
         empty_record.setFieldValue(new FieldId(<FieldId of lookup field in Main table>), new LookupValue(<RecordID of the value retrieved using the above getRecordID function>));
    empty_record.setFieldValue(new FieldId(<FieldId of Qualified field in Main table>), new QualifiedLookupValue(<lookup_value>));//QualifiedLookUp  value Retrieved above
    } catch (IllegalArgumentException e1) {
    // TODO Auto-generated catch block
         e1.printStackTrace();
    } catch (MdmValueTypeException e1) {
         // TODO Auto-generated catch block
         e1.printStackTrace();
    //Actually creating the record in Main table
    CreateRecordCommand create_main_command = new CreateRecordCommand(connections);
    create_main_command.setSession(sessionId);
    create_main_command.setRecord(empty_record);
    try
         create_main_command.execute();
    catch(Exception e)
         System.out.println(e.toString());
    Thanks
    Namrata

  • Best option to push Mass data using Java API

    Hi All,
    Can any one let me know how Java API push data to MDM? Is it a good option when ti comes to perfromance point of view? We have around 2000/5000 records to be imported every time using Java API and wondering what would be best way to acheive this using Java API?
    Is java API is best option than Web services?
    Thanks
    Rajeev

    Rajeev,
    It is perfectly fine to use API to push data into MDM, you just need to make sure that your API does all those tasks which import manager does by default. For example, it should know when to insert and when to update. if an error happens during insertion of record, you should be able to notify the users.
    Having said that, where does the number 2000/5000 comes in? will you be creating users in batch and then invoke MDM API to store these in a single shot or willl it be a delta insert/update from Java to MDM?
    Thanks
    Aamir

  • How to build a small application using Java API

    Hai expertise,
         I want to retreive MDM repository info using JAVA API, i am following these blogs:
    /people/andreas.seifried/blog/2006/03/26/performing-free-form-searches-with-mdm-java-api
    /people/udi.katz/blog/2005/08/21/retrieving-data-from-mdm-server-using-the-mdm-java-api
    /people/udi.katz/blog/2005/07/17/mdm-connectivity-to-java-application
    <b>where to get the jar and sda files to build the application??
    In Developer Studio.. Windows -> Preferences -> Java -> Classpath variables. Is this the only place where we need to give the jar file path??
    Are there any other configurations to do(except setting container variable to MDM4J jar file) to connect my java application to MDM repository???</b>
    Regards,
    Chand.

    Hi Govada,
    (1)You need to add the MDM4j and other JAR files at:-
    right click on project -> Java Build Path -> Libraries -> Add External JARs
    (2)If the project is Web Dynpro project one
    then right click on project -> Web Dynpro Reference -> Library Reference -> and add sap.com/com.sap.mdm.tech.mdm4j
    Are you using JAVA API 1 or 2???
    Thanking you
    Namrata Dixit

  • How to initialize a replica by using Java API?

    Hi, I used to initialize a replica by adding the attribute nsDS5BeginReplicaRefresh=start to the replica agreement and it works fine by using the ldapmodify commandline utility. Now I am trying to use the Java API to do the same, but I always get the Object class violation error. And I noticed that when I use the Java API to create the replica, it has the different attributes than the one created by the commandline utility. The former has the serializedJavaData and javaClass, ... And I can't find any documentation on this issue. It's really frustrating! I am wondering if the replica agreement has different attribute for initializing? If so, why it's never documented?
    I badly need your help!!!
    Louis

    Hi Govada,
    (1)You need to add the MDM4j and other JAR files at:-
    right click on project -> Java Build Path -> Libraries -> Add External JARs
    (2)If the project is Web Dynpro project one
    then right click on project -> Web Dynpro Reference -> Library Reference -> and add sap.com/com.sap.mdm.tech.mdm4j
    Are you using JAVA API 1 or 2???
    Thanking you
    Namrata Dixit

  • GetSelectedFields()  for time stamp and user stamp using java api

    using Java API's
    getSelectedFields() returns NULL  value if values presented also, for Time stamp and User stamp
    properties in Flat tables , is there any other alternative way to get the SelectedFields values ?
    Edited by: Vijaya Sekhar Reddy Alla on Mar 19, 2008 3:16 PM

    Well, I can't say I solved the problem, because I got another one afterwards.
    As usually I created a GetFieldListCommand, set its needed attributes and executed it. Then I read all the field properties out:
    FieldProperties[] fieldProp = getFieldListCommand.getFields();
    Afterwards it is possible to do what you want. Using a for-loop.
    for (FieldProperties fp : fieldProperties) {
        UserStampFieldProperties usfp = (UserStampFieldProperties) fp; // <= Cast error
        FieldId[] fieldIDs = usfp.getSelectedFields();
    And this is what I get now:
    Exception in thread "main" java.lang.ClassCastException: com.sap.mdm.schema.fields.FixedWidthTextFieldProperties cannot be cast to com.sap.mdm.schema.fields.UserStampFieldProperties
    Why this happens, I don't know. But it should somehow be solveable.

Maybe you are looking for