on 04-09-2009 10:45 AM
Hi,
I am using below code for modifying records usind MDM java API. There seems to be some problem with my modify command, not able to modify the fields in the MDM repository.
ConnectionAccessor simpleConnection=null;
String connection ="psimdm";
RepositorySchema repositorySchema;
String session;
String repository ="repo";
int totalRecord;
DBMSType dbmsType =DBMSType.ORACLE;
RepositoryIdentifier repIdentifier;
RegionProperties regionProperties;
try {
regionProperties = new RegionProperties();
regionProperties.setLocale(Locale.ENGLISH);
regionProperties.setName("English US");
regionProperties.setRegionCode("engUSA"); RegionProperties dataRegion=regionProperties;
simpleConnection = SimpleConnectionFactory.getInstance("psimdm");
repIdentifier = new RepositoryIdentifier(repository,"M10",dbmsType);
CreateUserSessionCommand createUserSessionCommand = new CreateUserSessionCommand(simpleConnection);
createUserSessionCommand.setRepositoryIdentifier(repIdentifier);
createUserSessionCommand.setDataRegion(dataRegion);
createUserSessionCommand.execute();
session = createUserSessionCommand.getUserSession();
AuthenticateUserSessionCommand authenticateUserSessionCmd = new AuthenticateUserSessionCommand(simpleConnection);
authenticateUserSessionCmd.setSession(session);
authenticateUserSessionCmd.setUserName("test");
authenticateUserSessionCmd.setUserPassword("");
authenticateUserSessionCmd.execute();
GetRepositorySchemaCommand getRepositorySchemaCommand = new GetRepositorySchemaCommand(simpleConnection);
getRepositorySchemaCommand.setSession(session);
getRepositorySchemaCommand.execute();
repositorySchema = getRepositorySchemaCommand.getRepositorySchema();
TableId tableId= repositorySchema.getTable("Products").getId();
FieldId[] fields = new FieldId[11];
fields[0] = repositorySchema.getFieldId("Products","Title");
fields[1] = repositorySchema.getFieldId("Products","Name");
fields[2]=repositorySchema.getFieldId("Products","DOB");
fields[3] = repositorySchema.getFieldId("Products","Gender");
fields[4] = repositorySchema.getFieldId("Products","Marital_Status");
fields[5]=repositorySchema.getFieldId("Products","Indian");
fields[6] = repositorySchema.getFieldId("Products","Resident_of_India");
fields[7] = repositorySchema.getFieldId("Products","Current_Address");
fields[8]=repositorySchema.getFieldId("Products","City_State");
fields[9] = repositorySchema.getFieldId("Products","Pin_Code");
fields[10] = repositorySchema.getFieldId("Products","Father_Name");
Record newRec=RecordFactory.createEmptyRecord(tableId,wdContext.currentContextElement().getRecordID());
newRec.setFieldValue(fields[0], new LookupValue(wdContext.currentTitle_personalElement().getTitle_ID().getId()));
newRec.setFieldValue(fields[1], new StringValue("prasanthi1"));
newRec.setFieldValue(fields[3], new BooleanValue(false));
Calendar c=Calendar.getInstance();
c.setTime(wdContext.currentContextElement().getDOB_personal());
newRec.setFieldValue(fields[2], new DateTimeValue(c));
newRec.setFieldValue(fields[4], new LookupValue(wdContext.currentMaritalStatus_personalElement().getMaritalStatus_ID().getId()));
newRec.setFieldValue(fields[10], new StringValue("test"));
ModifyRecordCommand modRec = new ModifyRecordCommand(simpleConnection);
modRec.setSession(session);
modRec.setRecord(newRec);
//wdComponentAPI.getMessageManager().reportSuccess("record modified");
modRec.execute();
wdComponentAPI.getMessageManager().reportSuccess("record modified");
} catch (ConnectionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (CommandException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (MdmValueTypeException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
i am able to get the table ID and field IDs. Modify command is giving some problem. Kindly suggest.
Edited by: prasanthi reddy on Apr 9, 2009 11:48 AM
Edited by: prasanthi reddy on Apr 9, 2009 11:51 AM
I am getting below exception. Anybody have some idea why it is coming?
Exception Occured2com.sap.mdm.commands.CommandException: com.sap.mdm.internal.protocol.manual.ServerException: Information out of date
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I am not gettimg exceptions (CommandException) while running ModifyRecordsCommand,but when I check MultipleRecordResult as follows,
MultipleRecordsResult multipleRecordsResult=commandd.getResult();
multipleRecordsResult.getFailedRecordMessage();
I will get message "Could not modify record".
There is no other exception thrown.What could be the reason for failing this modification operation?Is it related to ChangeStamp?
Please help on this issue.
Thanks,
Anuja
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I am using ModifyRecordCommand for modyfing record.After executing command no exception is thrown,but record is not getting modifyied.
I can use ModifyRecordsCommand,but it does not have setModifyAnyway() option.But I needsetModifyAnyway(true) option.
Please help on this issue.
Thanks,
Anuja
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Prasanthi/Becky,
Can you please update us on your issue? This would be helpful for all those working on MDM Java APIs
Regards,
Jitesh Talreja
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Prasanti,
Information out of date error is generally caused due to the ChangeStamp. You need to set the changestamp before updating the record in MDM. Try setting the changestamp in RS and then try.
Cheers,
Arafat
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
modify command is not working...
if i print the filed ID's i am passing, they are giving the result. Table ID and Record ID are also proper.
I am not able to print a message also after the execution of modify command. The control is going only till the beggining of executeModify conmmand.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Prasanthi,
It must be throwing some exception. Remove all the catch statements and write the below code
Catch(Exception e)
{
wdComponentAPI.getMessageManager().reportSuccess("Exception Occured"+e.toString());
}
With this you will get the exact the reason why it is failing
Regards,
Jitesh Talreja
Hi Prasanthi/Becky,
Check the below code
ModifyRecordCommand modRec = new ModifyRecordCommand(simpleConnection);
modRec.setSession(session);
modRec.setRecord(newRec);
modrec.setModifyAnyway(true); //this accepts the boolean parameter and the value is case sensitive
modRec.execute();
wdComponentAPI.getMessageManager().reportSuccess("record modified");
Regards,
Jitesh Talreja
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
24 | |
12 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.