on 09-07-2007 12:22 PM
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
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;
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Michal: In examples creating / updating record is not present and I am not able to open the pdf you mentioned it gives me error pdf is damaged is there any other place where I can find the pdf ?
Mausam: I am using Java API 2 and not able to find the class CreateEmptyRecordCommand but there is one class called CreateRecordCommand can I use the same or is there any other way for that?
Is possible for you to paste the code here so that I can get better idea.
Thanks
Ninad
Message was edited by:
Ninad
Hi Mausam,
Thanks a lot for your help I could able to add a empty record in it but now I want to have values in it. and I think we can do it by setFieldValue method of record but for that I need a MdmValue type value for this method and I could not able to create new Mdm value can you please help me in this case?
Thanks
Ninad
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
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
is that what you need?
Regards,
michal
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 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.