on 07-30-2007 10:11 PM
Hello guys:
Does anyone have a piece of code that shows how can I do a search, using the keyword and the SOUNDS_LIKE mod, like on the Data Manager?
I've seen the blog "Performing Free Form Searches with MDM Java API" but I'm afraid this doesn't apply (it's about free-form, as the name says)
Thanks!
Alejandro
Hi Alejandro,
maybe this piece of code helps you a bit. The most important is the static attribute SOUNDS_LIKE of the TextSearchConstraint class.
Also try to find the MDM Java Example files @ service.sap.com/installMDM . There is a complete introduction on how to search against an MDM repository which is very useful.
// assumption:
// you have connected to some repository which contains a field "Material Number"
// with a session and you have already read the MainTable properties to identify
// the MainTableID, as well as some fields yo want to read.
// set search conditions
Search search = new Search(<yourMainTableId>);
String fieldname = "Material Number";
ResultDefinition rd = new ResultDefinition(<yourMainTableId>);;
FieldId field = <someFieldFromYourRepository>;
rd.add(field);
// add some additional fields you want to select here ...
FieldSearchDimension searchDimension = new FieldSearchDimension(field);
TextSearchConstraint searchString = new TextSearchConstraint(materialNumber, TextSearchConstraint.SOUNDS_LIKE);
search.addSearchItem(searchDimension, searchString);
RetrieveLimitedRecordsCommand limitingCommand = new RetrieveLimitedRecordsCommand(<yourConnection>);
limitingCommand.setSession(<yourSession>);
limitingCommand.setResultDefinition(rd);
limitingCommand.setSearch(search);
limitingCommand.setPageSize(10);
try {
limitingCommand.execute();
RecordResultSet rs = limitingCommand.getRecords();
catch(Exception e){
e.printStackTrace();
}
If you need more help, let me know
Best regards,
Martin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Alejandro,
although I thonk you should not use the old API anymore because it will most likely not be supported in future versions, I crawled through some old code and found this:
/* retrieve one record where the "name 2" field sounds like "Smith" */
FreeFormTableParameter tableParam = search.GetParameters().NewFreeFormTableParameter(table);
FreeFormParameterField field = tableParam.GetFields().New("Name 2");
field.GetValues().NewString("Smith", FreeFormParameter.SoundsLikeSearchType );
/* go on and perform the search */
... the important part here is the FreeFormTableParameter.SoundsLikeSearchType ...
I hope this helps
Best Regards,
Martin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.