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

Creating / updating record from Java API 2

Hi All,

I am trying to create / update record through java API but not able to do so can any one give me the sample code for the same.

Thanks

Add a comment
10|10000 characters needed characters exceeded

Related questions

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Sep 07, 2007 at 01:11 PM

    Hi Ninad,

    For create:

    Please try CreateEmptyRecordCommand. Set the table ID before executing the command.

    Here, you just specify TableID. It will create a new Record into that table.

    If you provide RecordID for CreateEmptyRecordCommand, it will give you reference of existing record.

    For Update:

    First you will have to use CreateEmptyRecordCommand with the existing recordID.

    You will get "Record" as output of this.

    Then, you can use ModifyRecordCommand where Record is a mandatory parameter.

    Thanks,

    Mausam

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      HI Ninad,

      Even i am trying to insert values into a record.

      I am trying to insert value into a Look Up Table, i understood that by using setFieldValue.

      i have created an Empty Record by using Create Empty Record command,then i need to insert values into it.

      If u have any idea please share with me,any peice of code?

      With Thanks,

      Mary Joseph

  • Posted on Sep 07, 2007 at 11:30 AM

    hi,

    did you have a look at those two:

    this one contains many examples in ZIP file:

    MDM 5.5 SP05 - Java API Examples (ZIP File) - changed: 06/26/2006

    https://websmp101.sap-ag.de/~sapidb/011000358700000535912007E

    this is an overall example:

    How to Identify Identical Master Data Records Using SAP MDM 5.5 Java APIs

    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/a06478f5-b28d-2910-e083-c28eb96bbb60

    is that what you need?

    Regards,

    michal

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 03, 2007 at 03:03 PM

    Hello Ninad,

    I am a little late but maybe my code helps to understand a little!

    I am Writing into a Record that i retrieved by a search at an earlier point.

    Then I define the FieldId that should be changed and the Value that it should be. the Value must be a MdmValue Type.

    The Code works fine for me.

    Greetz

    Tobi

    	/**
    	 * Method to write record to MDM
    	 * @param ProductRecord - the Record the value should be written to
    	 * @param FieldToBeWritten - the FieldId that the value should be written to
    	 * @param ValueToBeWritten - MDMValue that should be written
    	 * @return Boolean that indicates if writing was successfully 
    	 **/
    	public boolean writeRecord(Record ProductRecord, FieldId FieldToBeWritten, MdmValue ValueToBeWritten){
    		// Change Data
    		try {
    			ProductRecord.setFieldValue(FieldToBeWritten, ValueToBeWritten);
    		} catch (IllegalArgumentException e1) {
    			// TODO Auto-generated catch block
    			e1.printStackTrace();
    			return false;
    		} catch (MdmValueTypeException e1) {
    			// TODO Auto-generated catch block
    			e1.printStackTrace();
    			return false;
    		}
    		// Create the command to commit record
    		ModifyRecordCommand mrcTest = new ModifyRecordCommand(mdmcon.getCpConnectionPool());
    		mrcTest.setRecord(ProductRecord);
    		mrcTest.setSession(mdmcon.getSession());
    		mrcTest.setModifyAnyway(false);
    		try {
    			mrcTest.execute();
    		} catch (CommandException e) {
    			// TODO Auto-generated catch block
    			e.printStackTrace();
    			return false;
    		}
    		return true;
    	}
    

    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.