cancel
Showing results for 
Search instead for 
Did you mean: 

Getting one record using ID

Former Member
0 Kudos

Hello guys, I'm getting this exception when I try to get a record by ID.

com.sap.mdm.commands.CommandException: com.sap.mdm.internal.protocol.manual.ServerException: Qualifier values are not part of a qualified lookup record
at com.sap.mdm.data.commands.RetrieveRecordsByIdCommand.execute(RetrieveRecordsByIdCommand.java:110)

Please, take a look at this code, I think there is something is missing...


	ResultDefinition rd = new ResultDefinition(tableId);
	GetFieldListCommand getFieldsCmd = new GetFieldListCommand(conn);
	getFieldsCmd.setTableId(tableId);
	getFieldsCmd.setSession(repositorySession);
	getFieldsCmd.execute();
	FieldProperties[] fieldProps = getFieldsCmd.getFields();
	for (int i = 0; i < fieldProps.length; i++) {
		FieldProperties field = fieldProps<i>;
		rd.addSelectField(field.getId());
	}
	RetrieveRecordsByIdCommand rrbiCmd = new RetrieveRecordsByIdCommand(conn);
	rrbiCmd.setSession(userSession);
	rrbiCmd.setIds(new RecordId[] { recordId });
	rrbiCmd.setResultDefinition(rd);
	rrbiCmd.execute();
	RecordResultSet rs = rrbiCmd.getRecords();
      return rs.getCount() > 0 ? rs.getRecord(0) : null;

Regards

Accepted Solutions (1)

Accepted Solutions (1)

Greg_Austin
Active Participant
0 Kudos

Hi Julio,

It looks like you are trying to do this for a Qualified table? If so you can't get to qualified fields in this manner. You have to go through the main table Record and read the qualified lookup field that connects to this qualified table. That will give you a QualifiedLookupValue object that you can get the data from.

If you are just trying to get the possible values for the non qualified field simply change the fields you put in the ResultDefinition to only include non qualifiers, not every field on the table.

Hope this helps,

Greg

Answers (1)

Answers (1)

Former Member
0 Kudos

Thanks alot man, I've put this workaround on the code, and it's working fine now:

if(!field.isQualifier()){
	rd.addSelectField(field.getId());
}