cancel
Showing results for 
Search instead for 
Did you mean: 

Inserting record with new java api

Former Member
0 Kudos

Hi expert,

i have a issue:

I create a record with

Record rec = RecordFactory.createEmptyRecord(mainTableId);

afert i set value in that record with

rec.setFieldValue

.

when i try to insert the record in table i have a exception:

when i use :


ModifyRecordCommand modifyRecord =
   new ModifyRecordCommand(connection);
modifyRecord.setSession(session);
modifyRecord.setRecord(rec);
modifyRecord.setModifyAnyway(false);
modifyRecord.execute();

I get :

com.sap.mdm.commands.CommandException: Can not update record with modification status NEW

And when i use :


CreateRecordCommand create_command =
    new CreateRecordCommand(connection);
create_command.setSession(session);
create_command.setRecord(rec);
create_command.execute();

I get :

com.sap.mdm.commands.CommandException: com.sap.mdm.internal.protocol.manual.ServerException: Nessun campo di ricerca qualificato

What i can do to insert a record in a table ?

Thanks.

Regards.

Andrea

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Andrea,

Could you send me the link of the wole code becuse I am not getting how i have to write code for setFieldValue() method of Record interface.

I have clicked over your provided links named code but they are not reaching at the code.

It'll be great help to me.

Please help me.

Thanks and Regards.

Tarun Sharma

Former Member
0 Kudos

i haven't a link for the code.

But i can help you to write the usage of setFieldValue.

You insert a record in the lookup table.

From this record you can get the id getId()

and then you add a field in the main table.

setFieldValue(fieldId,new LookupValue(the id of record of lookup Table))

I hope thi is usefull.

Regards

Andrea

Former Member
0 Kudos

Hi Andrea,

First of all thanks for you reply.

Could you please tell me the steps or code for adding record in Lookup table ASAP?

Thanks

Tarun Sharma

Former Member
0 Kudos

//Create empty record from lookup tableId

try{

Record lookup_record = RecordFactory.createEmptyRecord(tableId);

//add value to the record

lookup_record.setFieldValue(<FieldId>, new MdmValue(<value>));

} catch (Exception e2) {

}

CreateRecordCommand create_command = new CreateRecordCommand(connection);

create_command.setSession(session);

create_command.setRecord(lookup_record);

try {

create_command.execute();

} catch (Exception e) {

System.out.println(e.toString());

}

RecordId record_id = create_command.getRecord().getId();

Former Member
0 Kudos

Hi Andrea,

Thanks for your reply.

By reading your Code i came to know that i'll have to use two createRecordCommnd() commands.

one for adding record in lookup and another for adding lookup into the Main table.

Please suggest if I am wrong.

Thanks and Regards

Tarun Sharma

Former Member
0 Kudos

Hi Tarun,

it's right !

Regards

Andrea

Former Member
0 Kudos

Hi Andrea,

Thanks very much for your support.

For getting poing you can give me the same answer on this link.

Could you let me know the process for inserting the value into taxonomy.

Thanks

Tarun Sharma

Former Member
0 Kudos

Thanks ,

continue in this thread,

Former Member
0 Kudos

Hi Andrea,

Could you send me the link of the wole code becuse I am not getting how i have to write code for setFieldValue() method of Record interface.

I have clicked over your provided links named code but they are not reaching at the code.

It'll be great help to me.

Please help me.

Thanks and Regards.

Tarun Sharma

Former Member
0 Kudos

Is it multivalued record?