cancel
Showing results for 
Search instead for 
Did you mean: 

Get Field Values from Table using Java api

Former Member
0 Kudos

I am using the example java code "RetrieveLimitedRecords" that can be found at :

https://help.sap.com/javadocs/MDM71/current/API/index.html

The code give the expected result and retrieves the record count for the main table

Now I want to get the values of the fields for one record

I added the lines:

Record[] records = recordResultSet.getRecords() ;

FieldId[] fields = records[0].getFields();

System.out.println ("Field Length = "+fields.length);

and the output is::

Field Length = 0

How can I get the fields of the record and read their values?

Thanks

Nicolas

Accepted Solutions (1)

Accepted Solutions (1)

Greg_Austin
Active Participant
0 Kudos

Nicolas did you put fields in the ResultDefinition object? You have to tell MDM what fields you want to retrieve.

Former Member
0 Kudos

Thanks Greg

I was assuming that the line :

ResultDefinition rd = new ResultDefinition(mainTableId);

would bring all records but it is exactly the opposite.

Do you know a way of getting all records info using ResultDefinition?

I am using ResultDefinitonEx now..

Thanks again !

Greg_Austin
Active Participant
0 Kudos

Assuming you want every field, the equivalent of "SELECT *" in SQL, you can use the RepositorySchema object to get a TableSchema, and with that get all FieldIds for the table.

If your RepositorySchema variable is rs it would be something along the lines of:


TableSchema mainTableSchema = rs.getTableSchema(mainTableId);
ResultDefinition rd = new ResultDefinition(mainTableId);
rd.setSelectFields(mainTableSchema.getFieldIds());

Hope this helps,

Greg

Former Member
0 Kudos

Yes it does.

Thanks very much for your help Greg !

Answers (0)