cancel
Showing results for 
Search instead for 
Did you mean: 

Read Qualified Look Up(MultiValue) Table Values From Main Table

Former Member
0 Kudos

Hi all,

I have a requirement to read my MDM main table using MDM Java APIs. In that main table there is a qualified look up flat table (MultiValue). Kindly give me sample code to do the same.

Regards,

Yogesh Bhatia.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hello Yogesh,

Below are Steps to achieve the same:

Step 1: Fetch the tableId.

Step 2: Retrieve the field Ids of all the fields using:

int numOfFields = schema.getTableSchema(tableId).getFields().length;

/** Create an array to hold the field ids*/

FieldId fields[] = new FieldId[numOfFields];

/** Store the properties of each field in an array of <b>FieldProperties</b>*/

FieldProperties[] fieldProperties =

schema.getTableSchema(tableId).getFields();

for (int i = 0; i < numOfFields; i++) {

/** Store the field Properties into the array */

fields<i> = fieldProperties<i>.getId();

}

Step 3: Define ResultSet and use RetrieveLimitedRecordsCommand command to get all the records:

TableId tableId = getTableId(tableName);

FieldId fields[] = getAllFieldIdsOfTable(tableName);

/*Defining ResultSetDefinition/

ResultDefinition resultDef = new ResultDefinition(tableId);

resultDef.setSelectFields(fields);

Search search = new Search(tableId);

int j=1;

int pageIndx = 0;

RecordResultSet recordSet = null;

TableSchema tableSchema = null;

RetrieveLimitedRecordsCommand limitedRecordsCommand =

new RetrieveLimitedRecordsCommand(simpleConnection);

limitedRecordsCommand.setSearch(search);

limitedRecordsCommand.setSession(userSession);

limitedRecordsCommand.setPageIndex(pageIndx);

limitedRecordsCommand.setResultDefinition(resultDef);

limitedRecordsCommand.execute();

recordSet = limitedRecordsCommand.getRecords();

tableSchema = recordSet.getRecordMetadata();

if (recordSet.getCount() > 0) {

for (int i = 0; i < recordSet.getCount(); i++) {

recordsArr.add(new MdmRecord(recordSet.getRecord(i), tableSchema));

}

}

Iterator itr = recordsArr.iterator();

records = new MdmRecord[recordsArr.size()];

while(itr.hasNext()){

records[cnt] = (MdmRecord)itr.next();

cnt++;

}

records will give you all the records.

Step 4: Use

FieldProperties[] fields=tableSchema.getFields();

MdmValue mdmValue = mdmRecord.getFieldValue(fields[index].getId());

mdmValue will be the recordId of the look up field and using recordId we can easily get the record.

I think it will solve your problem

Former Member
0 Kudos

Hi Yogesh,

Though I don't have sample code , I would suggest you to explore the mdm api QualifiedLookupValue .

To get a documentation about the api use the below link

https://help.sap.com/javadocs/MDM/SP06/index.html

Regards