cancel
Showing results for 
Search instead for 
Did you mean: 

Modify Record using Java API

Former Member
0 Kudos

Hi,

I have written a Java Code to Modify the data using Java API's.

I have done the following:

  • Connected to Server

  • Connected to Repository

  • Created the User Session

  • User enters the Table Name - I have retrieved the corresponding Table id

  • User enters the Search Parameter(Condition on which update should be made).

  • I have retrieved all the records, matching the search criteria, using the Search function.

Now I wanted to modify the selected reocrds, I am using the following code to do this.

ModifyRecordCommand modRec = new ModifyRecordCommand(connections);

modRec.setSession(sessionId);

modRec.setRecord(resSet);

modRec.setModifyAnyway(false);

try

{

modRec.execute();

}

catch(CommandException e)

{

e.printStackTrace();

return;

}

In the above Code, I donot know how to pass the values of the fields, that should be updated.

Can anyone help me to solve this.

Thanks.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Priya

Before passing Record object i.e resSet in your case.Use the following code:

resSet.setFieldValue(fields[0], new StringValue("Abc"));

resSet.setFieldValue(fields[1], new BooleanValue(true)); resSet.setFieldValue(fields[2], new IntegerValue(4567));

Thanks & Regards,

Jitesh Talreja

Former Member
0 Kudos

Hi,

In resSet, I am passing the records, that I retrieved through Search.

Now, should i create another record set and pass that in the modify statement??

If I do, so then i am getting an error as

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

at com.sap.mdm.data.commands.ModifyRecordCommand.execute(Unknown Source)

at programs.ModifyRecord.main(ModifyRecord.java:116)

Can you tell what does error mean

Thanks,

Priya.

Former Member
0 Kudos

Hi Priya,

Though i have not worked on it much but according to my understanding use the same resSet because you have to modify the existing records only and just modify the statement

setModifyAnyway(true).

Thanks & Regards,

Jitesh Talreja

Former Member
0 Kudos

Hi,

I have made the change but, still the issue is not solved.

setModifyAnyway(true).

Thanks.

Priya.

Former Member
0 Kudos

Hi,

I got the issue solved.

The error occured, as i created an Empty reord just with the table id.

Now i have changed it to table id and record id.

Thanks,

Priya.