cancel
Showing results for 
Search instead for 
Did you mean: 

User Exit for filtering Tuple Tables - setFilterTupleValues

roberto_reinert
Discoverer
0 Kudos

Hello MDM experts,

In SAP MDM SP15 there is a new method for filtering tuple values called: "setFilterTupleValues".

In this method i need to create an object of type FilterTupleValues passing the following parameters in class constructor:

FilterTupleValues filterTupleValues = new FilterTupleValues(tupleSearch, tuplePath, searchResultSettings, property);

I need some help on how create the first parameter: tupleSearch


My requirement is prevent a person from modifying some lines of a MultiTupleValue field.

For example, only lines (tuples) where the field code starts with a prefix "Z".

So in this case i know that other parameters are:

searchResultSettings: SearchResultsProperty.MODIFY_SEARCH_RESULTS

property: Boolean.False

Can someone give me an example or piece of code?

Thanks in advance!

Reinert.

Accepted Solutions (1)

Accepted Solutions (1)

roberto_reinert
Discoverer
0 Kudos

Hello,

The following code snippet can help, if somebody need in the future...:

public void runTupleSearchHideResults( )  {

//getting session context and repository schema:

UserSessionContext context = this._repositoryBean.getUserSessionContext();

      RepositorySchemaEx repositorySchema = MetadataManager.getInstance().getRepositorySchema(context);

     

      //get the table id the result set is working on

      TableId mainTableId  = repositorySchema.getTableId("Products");

      //get from the schema the field id (in this case it’s a tuple) in the main table – (See img_1.png)

      FieldId fieldId = repositorySchema.getFieldId("Products", "Address_old_code");

//get the Tuple member field (Address\ ADD_TY) Id you want to have the search run on (See img_2.png)

      FieldId tupleFieldId = repositorySchema.getTupleMemberField("Address", "ADD_TY").getId();

//get the record id in the record set which its tuple you want to limit (See img_3.png)

      RecordId recordId = new RecordId(1364);

   

      //build your search – no need to run it – the user exit will run the search and will act on the search results

      //in this case – building the search to get all the records where the address type (ADD_TY) starts with t.

      TupleSearch search = new TupleSearch(mainTableId, fieldId, recordId);

      SearchDimension dim = new FieldSearchDimension(tupleFieldId);

      SearchConstraint cons = new TextSearchConstraint("t", TextSearchConstraint.STARTS_WITH);

      search.addSearchItem(dim, cons);

     

//build the path to the tuple (in this case, first lvl tuple, so only the tuple name needs to be here)

      String[] tupleMemberPaths = new String[1];

      tupleMemberPaths[0] = new String("Address_old_code");

     

      //create a new instance of FilterTupleValues, providng the constructor 3 objects:

      //1. The search object constructed earlier

      //2. The tuple path (string array)

      //3. The action type to apply on the search results (this will happen inside the user exit)

      //    THIS CAN BE ONE OF the following 2:

  1. 1.  SearchResultsProperty.VIEW_SEARCH_RESULTS    - to hide from the tuple the results of the search
  2. 2.  SearchResultsProperty.MODIFY_SEARCH_RESULTS – to disable the option of editing the search results

FilterTupleValues filterTupleValues = new FilterTupleValues(search, tupleMemberPaths, SearchResultsLayoutProperties.SearchResultsProperty. MODIFY_SEARCH_RESULTS, false);

      //call the user exit providing it the FilterTupleValues instance

      wdThis.wdGetItemDetailsInterface().setFilterTupleValues(filterTupleValues);

      //refresh the itemdetails

      wdThis.wdGetItemDetailsInterface().refreshComponent();

  }

Answers (0)