cancel
Showing results for 
Search instead for 
Did you mean: 

Creating record usinf Java API

Former Member
0 Kudos

Hi All,

I am using MDM 5.5 SP6. I have created repository. In that repository, Products is a main table as default. It has two fileds as Name(Type --> Text) and Category(Type --> Lookup(Taxonomy)). I tried to add a record in the main table through belown code(Using java API).

Record r1 = RecordFactory.createEmptyRecord(new TableId(1));

FieldId fld1, fld2;

fld1 = new FieldId(2);

fld2 = new FieldId(3);

r1.setFieldValue(fld1, new StringValue("M1002"));

r1.setFieldValue(fld2, new StringValue("Mobile"));

createRecordCommand.setSession(userSessionCommand.getUserSession());

createRecordCommand.setRecord(r1);

try {

createRecordCommand.execute();

} catch (CommandException e2) {

e2.printStackTrace();

}

But it is getting Field not found exception. Here I realised , tableid = 1(for table 'products') and Field id = 2 (For field 'Name') is correct. I couldn't findout what is the field id for 'Category' field.

And also, Here How can I realize table id and field id?

I followed this article also.

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/803e9e80-21f4-2a10-8cbf-bcf6a806...

Please help to solve this.

Thanks,

Venkatesh

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Venkatesh,

the link you follow is good, but there is another way to create a empty record, and you dont have to every time enter field id . check this cod to create a new record.

TableId tId = new TableId(1);

// System.out.Println (tId);

CreateRecordCommand createRecord = new CreateRecordCommand(connPool);

Record rec = RecordFactory.createEmptyRecord(tId);

createRecord.setRecord(rec);

createRecord.setSession(session);

System.out.println ("--


44444--");

try {

// if(session=="") { System.out.println("NO SESSION "); }

createRecord.execute();

} catch (CommandException e) {

String errMsg = "Failed to Create Record repository session!";

throw new RuntimeException(errMsg);

}

Cheers,

Mary

Former Member
0 Kudos

Hi All,

Thanks for your reply. I have solved the problem. Now I getting one more doubt. In my qualified table , I am having a lookup[flat] field name as 'UOM'. It refers a lookup table for values.

As per our requirement, we are developing screens in webdynpro for inserting record in this table.For UOM field, we have given drop down box in webdynpro screen. This drop down gets values from look up table.

Here My questions, How can I insert a value to Lookup[flat] type filed(UOM) using Java API. Please help me to solve.

Thanks,

Venkatesh

Former Member
0 Kudos

Hi Venkatesh,

I think for the lookup field insertion, the process is.

identify all the associated record-ids for each of the lookup fields from their corresponding look up flat tables and then specify them while creating the looup table record.

havent worked on it, but hope this is the way..

Cheers

Mary

Former Member
0 Kudos

Hi Mary,

Thanks. I have found the way that how to work on look up values.I am having one more doubt, Is search possible in mdm using Java API?.

Here I mean, If I give a value in UI on webdynpro screen, based on that value I need to fetch the records from MDM and.

I found the way to retrive records from MDM. But I need , How to fetch records based on given value by user at runtime. Please give some idea to achive this.

Thanks

Venkatesh

Former Member
0 Kudos

Hi Venkatesh Ranganathan,

I have a PDF, hope it might help you. can u provide your id, so that i can send the Doc.

Cheers,

Mary

Former Member
0 Kudos

Hi Mary,

Thanks. I got some idea for search in MDM. I need to add images in images table using java API. Is it possible?. Please help me.

Thanks,

Venkatesh

Former Member
0 Kudos

hI venkat,

No idea, if you find a soln help me too in his case.

Cheers,

Mary

Answers (1)

Answers (1)

Greg_Austin
Active Participant
0 Kudos

Venkatesh,

You really don't want to hard code the values of the FieldIds and TableIds in your code. You can lookup these values with the getFieldId and getTableId methods of the RepositorySchema class. You can get a repository schema with the GetRepositorySchemaCommand. Look at the javadocs for these classes for more info.

-Greg

Edited by: Greg Austin on May 12, 2008 11:35 AM