cancel
Showing results for 
Search instead for 
Did you mean: 

MDM Lookup - Java API

michael_pang4
Active Participant
0 Kudos

Hi,

I'm trying to use the Java API to do a free form search on the following scenario.

We have a main table Products, that contains a field Main_RM which is a key to a flat lookup table.

Flat table also called Main_RM has two fields Main_RM and Description.

Products Table

Matnr | Main_RM | ....

00001 | 001 |

Main_RM Table

Main_RM | Description |

001 | Leather |

How can I do a search like Find me all the materials where Main_RM Description has substring 'Lea'?


Search search = new Search("Products");
search.SetSearchType(Search.GlobalAndSearchCombinationType);
FreeFormTableParameter fftp_Main_RM = new FreeFormTableParameter("Main_RM");
FreeFormParameterField searchField = fftp_Main_RM.GetFields().New("Description");
searchField.GetFreeForm().NewString(cloth, FreeFormParameter.SubstringSearchType);
search.Add(fftp_Main_RM);

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Michael,

If you try to include both the search criteria in the same search, it will error out saying "Description is not a display field. Only display fields are supported in current version".

Instead, Use the LookupParameter class to do a lookup search for all the Main_RM and then loop through the result set to again check for the description.

ResultSetDefinition rsd = new ResultSetDefinition("Products");

rsd.AddField("Main_RM");

Search search = new Search("Products");

search.SetSearchType(Search.GlobalAndSearchCombinationType);

FreeFormTableParameter fftp_Main_RM = new FreeFormTableParameter("Products");

LookupParameter lkp = search.GetParameters().NewLookupParameter("Products","MAIN_RM");

A2iResultSet rs = catalog.GetResultSet(search,rsd,null,true,0);

Loop in this rs resultset and do another search for 'Lea', Put the code in the try_catch.

Hope it helps.

Avi.

Former Member
0 Kudos

Hi Michael,

Try this:

Make the description field a 'Display Field-Yes' in the MDM console and do a free-form search for 'Lea' on the main field 'Main_RM'.

ResultSetDefinition rsd = new ResultSetDefinition("Products");

rsd.AddField("Main_RM");

Search search = new Search("Products");

search.SetSearchType(Search.GlobalAndSearchCombinationType);

FreeFormTableParameter fftp_Main_RM = new FreeFormTableParameter("Products");

FreeFormParameterField searchField = fftp_Main_RM.GetFields().New("Main_RM");

searchField.GetFreeForm().NewString("Lea",FreeFormParameter.SubstringSearchType);

search.Add(fftp_Main_RM);

A2iResultSet rs = catalog.GetResultSet(search,rsd,null,true,0);

Loop in this rs resultset and check the values, Put the code in the try_catch.

I tried this and it works for me.

Hope it helps.

Avi.

michael_pang4
Active Participant
0 Kudos

Thanks Avi.

I just spoke with our MDM team about this.

Unfortunately setting the "Description" field in the "Main_RM" table to 'Display Field-Yes' is too BIG of a change for them as it involves changing IDOCs. As I don't know about that area I really cannot comment.

Is there a way to do this without changing the data structures?

Thanks again.