on 04-16-2008 11:04 AM
Hi friends,
I am trying to create an application using the MDM.java API. The requirement is I have to implement comma separated search on one of the fields. Now the question is how to do that.
FYI
I am preparing a search criteria as
public void addSearchCriteria(
FreeFormTableParameter fftp,
String fieldname,
String value,
int searchTypeSign) {
if (value != null) {
FreeFormParameterField searchField =
fftp.GetFields().New(fieldname, searchTypeSign);
searchField.GetFreeForm().NewString(value, searchTypeSign);
}
Thank You friends. I got it done after some modifications.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
What do you mean by "comma-separated search"? Are you trying to search a field for one or more values? Please explain exactly your scenario.
Walter
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Avik
Based on what i have understood from thread, The following code gets me the records based on the Alphabets using STARTSWITH Search constraint.
I hope this helps.
String[] alphabetsArray ={"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"};
RetrieveLimitedRecordsCommand retrieveLimitedRecordsCommand = null;
RetrieveRecordsByIdCommand objRecordsByIDCommand = null;
Record[] taxoSubClassRecs = null;
String subClassCode = null;
//Compose the search
//Create constraint and dimension for key word search
FieldSearchDimension classificationSearchDim = new FieldSearchDimension(fields[0]); // put the fieldID
for(int k = 0; k <alphabetsArray.length;k++ )
{
TextSearchConstraint classificationSearchConstraint = new TextSearchConstraint(alphabetsArray[k],TextSearchConstraint.STARTS_WITH); // You have options of STARTSWITH/EQUALS/etc
//Create the search and add the key word constraint
com.sap.mdm.search.Search search = new com.sap.mdm.search.Search(mainTableId);
search.addSearchItem(classificationSearchDim, classificationSearchConstraint);
//Instantiate search command
retrieveLimitedRecordsCommand = new RetrieveLimitedRecordsCommand(repository.getConnection());
retrieveLimitedRecordsCommand.setSession(repository.getAuthenticatedUserSession().getSession());
//Supply the result definitions and the search as argument to the command.
retrieveLimitedRecordsCommand.setResultDefinition(rd);
retrieveLimitedRecordsCommand.setSearch(search);
//Execute the command and print the number of records found
try
{
retrieveLimitedRecordsCommand.execute();
System.out.println("Number of records found for Alphabet: " +alphabetsArray[k]+ "=" + retrieveLimitedRecordsCommand.getRecords().getCount());
}
catch (CommandException e)
{
e.printStackTrace();
}
taxoSubClassRecs = retrieveLimitedRecordsCommand.getRecords().getRecords();
Cheers
Hi Navneet,
You have not understood my question.
I am trying to search a table in MDM and the search string that is passed is in the format "String1,String2". With reference to blog /people/andreas.seifried/blog/2006/03/26/performing-free-form-searches-with-mdm-java-api
I have tried the following.
+
public void addSearchCriteriaWithComma(
FreeFormTableParameter fftp,
String fieldname,
String value,
int searchTypeSign) {
if (value != null) {
FreeFormParameterField searchField =
fftp.GetFields().New(
fieldname,
FreeFormParameterField.SEARCH_OPERATOR_OR);
StringTokenizer valueToken = new StringTokenizer(value,",");
// StringTokenizer valueToken = new StringTokenizer("7000318,7000324", ",");
while (valueToken.hasMoreTokens()) {
value = valueToken.nextElement().toString();
searchField.GetFreeForm().NewString(value, searchTypeSign);
}
}
}
+
But this doesn't seem to work.The StringTokenizer should take the values and pass it to the searchField for Searching.
Please help.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
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.