My Java code:
if (pro.getType() == 42) {//qualified Value
subFieldIndex = new Hashtable<String, Integer>();
subFieldSap = new Hashtable<String, String>(); */
String subTableName = subFieldSap.get(sap_fieldCode);
SubInfos subInfos = subInfoTable.get(subTableName);
String splitChar = subInfos.getSplitChar();
String splitField = subInfos.getSysCode();
String splitValue[] = null;
Record[] records;
if (splitField != null) {
String splitvalues = (String) model.getFromView(splitField);
splitValue = splitvalues.split(splitChar);
records = new Record[splitValue.length];
} else {
records = new Record[1];
}
TableId tableId = subInfos.getTableid();
SubInfo[] subInfoArray = subInfos.getSubInfoArray();
if (splitValue != null) {
for (int j = 0; j < splitValue.length; j++) {
Record record = RecordFactory.createEmptyRecord(tableId);
TXIModel subModel = new TXIModel(null);
for (int i = 0; i < subInfoArray.length; i++) {
String subValue = "";
SubInfo subInfo = subInfoArray[i];
String subCode = subInfo.getSubCode();
String sysCode = subInfo.getSysCode();
String subType = subInfo.getType();
String defaultValue = subInfo.getDefaultVale();
if (sysCode != null && sysCode.equals(splitField)) {
subValue = splitValue[j];
} else if (defaultValue != null) {
subValue = defaultValue;
} else if ("Date".equalsIgnoreCase(subType)) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
subValue = sdf.format(new Date());
} else if (sysCode != null) {
if (sysCode.indexOf(",") > 0) {
String[] sysCodes = sysCode.split(",");
for (int k = 0; k < sysCodes.length; k++) {
subValue = (String) model.getFromView(sysCodes[k]);
if (subValue != null) {
break;
}
}
}
}
if (subValue == null) {
subValue = "";
}
subModel.set(subCode, subValue);
if (subInfo.getReferedTableId() != null) {
FieldId fieldId = subInfo.getFieldId();
record.setFieldValue(fieldId, new LookupValue(getRecordId(subInfo.getReferedTableId(), subInfo.getReferFieldId(), subValue)));
} else {
record.setFieldValue(subInfo.getFieldId(), getmdmValue(subInfo.getFieldProperty(), subValue, subCode, null));
}
}
subInfos.addTXIModel(subModel);
records[j] = record;
}
} else {
Record record = RecordFactory.createEmptyRecord(tableId);
TXIModel subModel = new TXIModel(null);
for (int i = 0; i < subInfoArray.length; i++) {
String subValue = "";
SubInfo subInfo = subInfoArray[i];
String subCode = subInfo.getSubCode();
String sysCode = subInfo.getSysCode();
String subType = subInfo.getType();
String defaultValue = subInfo.getDefaultVale();
if (defaultValue != null) {
subValue = defaultValue;
} else if ("Date".equalsIgnoreCase(subType)) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
subValue = sdf.format(new Date());
} else if (sysCode != null) {
subValue = (String) model.getFromView(sysCode);
}
subModel.set(subCode, subValue);
if (subInfo.getReferedTableId() != null) {
FieldId fieldId = subInfo.getFieldId();
record.setFieldValue(fieldId, new LookupValue(getRecordId(subInfo.getReferedTableId(), subInfo.getReferFieldId(), subValue)));
} else {
record.setFieldValue(subInfo.getFieldId(), getmdmValue(subInfo.getFieldProperty(), subValue, subCode, null));
}
}
subInfos.addTXIModel(subModel);
records[0] = record;
}
//Create Record in Qualified Lookup table
Record[] result = new Record[records.length];
for (int i = 0; i < records.length; i++) {
CreateRecordCommand cmd = new CreateRecordCommand(connections);
cmd.setRecord(records[i]);
log("subTableName="+subTableName+" i="+i+" "+records[i].toString());
cmd.setSession(sessionStr);
cmd.execute();
result[i] = cmd.getRecord();
}
System detail error :
com.sap.mdm.commands.CommandException: Unique constraint violated (0x84000013)
at com.sap.mdm.data.commands.CreateRecordCommand.executeImpl(CreateRecordCommand.java:260)
at com.sap.mdm.commands.AbstractCommandBase.execute(AbstractCommandBase.java:129)
at com.outer.SapImpl.TXISendSapMdmInfo.processQualifiedData(TXISendSapMdmInfo.java:706)
at com.outer.SapImpl.TXISendSapMdmInfo.getmdmValue(TXISendSapMdmInfo.java:636)
at com.outer.SapImpl.TXISendSapMdmInfo.generateRecords(TXISendSapMdmInfo.java:596)
at com.outer.SapImpl.TXISendSapMdmInfo.XiSapRecordsOPerator(TXISendSapMdmInfo.java:225)
at com.outer.SapImpl.TXISendSapMdmInfo.main(TXISendSapMdmInfo.java:1186)
Caused by: com.sap.mdm.internal.protocol.manual.ServerException: Unique constraint violated (0x84000013)
at com.sap.mdm.internal.protocol.manual.AbstractProtocolCommand.execute(AbstractProtocolCommand.java:132)
at com.sap.mdm.data.commands.CreateRecordCommand.executeImpl(CreateRecordCommand.java:215)
... 6 more