Skip to content
  • There are no suggestions because the search field is empty.

How to implement a Search BAdI in NextTables for SAP BW

The Search BAdI end to end: the two methods, why the filter excludes the table, dropdown versus search bar, and the two ways to redirect a column's value help.

📝 Availability: NextTables for SAP BW, Enterprise edition. This article documents a BAdI; BAdI support is an Enterprise feature.

You will learn

How to implement a Search BAdI: the definition and its two methods, what the filter matches on and what that means for reuse, every parameter of the Meta method, and how to point one column at a different search than its InfoObject would give it.

This article is for ABAP developers. It covers the setup and the Meta method; the search itself is The Search BAdI DO_SEARCH method in NextTables for SAP BW.

📝 Most value help needs no BAdI. A column can take its values from a Data Dictionary table or an InfoObject through configuration alone, and that covers the large majority of requirements. Reach for this BAdI when the values cannot come from either. How to give editors the right values in NextTables for SAP BW works through the configuration routes first.

Prerequisites

The definition and its two methods

The enhancement spot /NLY/EDITOR contains the BAdI definition /NLY/BADI_SEARCH, which covers every search operation. With it you can change the search style, set how many characters a user types before the search starts, and replace the search logic outright.

Your logic goes into methods of the implementing class, whose signatures come from the definition:

The implementing class of the Search BAdI with its two exit methods in the method list

MethodUse it to
/NLY/IF_SEARCH~SET_META_EXIT Change the metadata of the search: search style, minimum characters, strict mode.
/NLY/IF_SEARCH~DO_SEARCH_EXIT Implement the search itself and format the results. See the DO_SEARCH reference.

Overview chart of the two search BAdI methods and where each runs in the search sequence

The filter, and what it means for reuse

The filter carries the search type and the search name. When the search runs on an InfoObject, the search name is that InfoObject's name.

The Filter Values section of a Search BAdI implementation with the search type and search name

The table or DSO is not part of the filter, on purpose. One implementation therefore serves every table containing that InfoObject, so a value help is written once rather than once per table.

When two tables sharing an InfoObject need different searches, there are three ways out, from cheapest to most involved:

  • Set the search properties for that one column in the table's own configuration. See Table and column configuration in NextTables for SAP BW.
  • Override them in the table maintenance BAdI's Meta method, which wins over the search configuration.
  • Create a referencing InfoObject, so the master data stays shared but the searches can differ.

The Meta method

The Meta method adjusts how the search presents itself. The choice that matters most is the search style, because the two styles work in genuinely different ways:

  • DROPDOWN loads all values first and then searches locally. Fast and forgiving on a short list, and unusable on a long one.
  • SEARCH runs the search for the entered term only, and may run several times as the user types. This is the right choice for characteristics with large master data.

The practical line is around 50 values.

A NextTables value help rendered as a dropdown and as a search bar, side by side

Parameters

ParameterTypeDescriptionPossible values
I_STYPECHAR 6Search type originally usedDDIC, IOBJ, CUSTOM
I_SEARCHNAMECHAR 60Search name originally usedFor example the InfoObject name when the type is IOBJ
CH_S_SEARCH_INFO-SEARCHMODECHAR 6Search type. Should not be adjusted here.DDIC, IOBJ, CUSTOM
CH_S_SEARCH_INFO-SEARCHNAMECHAR 60Search name. Should not be adjusted here.
CH_S_SEARCH_INFO-SEARCHSTYLECHAR 30How the value help is presentedSEARCH search bar
DROPDOWN dropdown, recommended below about 50 values
CH_S_SEARCH_INFO-MIN_CHARNUMC 3Characters the user types before the search starts
CH_S_SEARCH_INFO-STRICTCHAR 1Strict searchX the user may only enter values the search returned

📝 Why not change SEARCHMODE here: the filter already selected this implementation by search type and name. Changing them inside the method does not redirect the search, it only desynchronizes the metadata from the implementation that is running. To point a column at a different search, do it from the table maintenance Meta method, as shown below.

Step-by-Step Instructions

1. Create the implementation and set the filter

Create a BAdI implementation for /NLY/BADI_SEARCH inside your project's enhancement implementation, and set the search type and search name in the filter.

2. Set the search metadata

A complete Meta method is usually a handful of assignments:

METHOD /nly/if_search~set_meta_exit.

  ch_s_search_info-min_char    = '3'.
  ch_s_search_info-searchmode  = i_stype.
  ch_s_search_info-searchname  = i_searchname.
  ch_s_search_info-strict      = 'X'.
  ch_s_search_info-searchstyle = 'SEARCH'.

ENDMETHOD.

This one waits for three characters, shows a search bar, and refuses values the search did not return.

3. Implement the search

Fill /NLY/IF_SEARCH~DO_SEARCH_EXIT and remember E_IS_IMPLEMENTED. Details and a full example: The Search BAdI DO_SEARCH method in NextTables for SAP BW.

A NextTables search result list produced by a custom Do Search implementation

4. Point one column at a different search

To give a column the search of a different InfoObject, change SEARCHMODE and SEARCHNAME for that field in the table maintenance Meta method. Here the column CALYEAR is given the search of 0FISCYEAR:

METHOD /nly/if_editor~set_meta_exit.

  FIELD-SYMBOLS:
    <l_s_fields_info> TYPE /nly/ts_fields_info,
    <l_s_f4help>      TYPE /nly/ts_search_info.

  LOOP AT ch_t_fields_info ASSIGNING <l_s_fields_info>.

    CASE <l_s_fields_info>-fname.
      WHEN 'CALYEAR'.
        LOOP AT <l_s_fields_info>-f4help ASSIGNING <l_s_f4help>.
          <l_s_f4help>-searchmode = 'IOBJ'.
          <l_s_f4help>-searchname = '0FISCYEAR'.
        ENDLOOP.
    ENDCASE.

  ENDLOOP.

ENDMETHOD.

The Search BAdI you want to trigger has to carry the matching filter.

The filter of the Search BAdI implementation that the redirected column triggers

5. Replace the search independently of any InfoObject

Search type CUSTOM decouples the search from master data entirely. Name the logic yourself and use that name in both places:

METHOD /nly/if_editor~set_meta_exit.

  FIELD-SYMBOLS:
    <l_s_fields_info> TYPE /nly/ts_fields_info,
    <l_s_f4help>      TYPE /nly/ts_search_info.

  LOOP AT ch_t_fields_info ASSIGNING <l_s_fields_info>.

    CASE <l_s_fields_info>-fname.
      WHEN 'CALYEAR'.
        LOOP AT <l_s_fields_info>-f4help ASSIGNING <l_s_f4help>.
          <l_s_f4help>-searchmode = 'CUSTOM'.
          <l_s_f4help>-searchname = 'ZCUST'.
        ENDLOOP.
    ENDCASE.

  ENDLOOP.

ENDMETHOD.

Then set the Do Search BAdI's filter to search type CUSTOM and search name ZCUST.

The Search BAdI filter set to search type CUSTOM with a custom search name

6. Activate everything

The implementing class with its methods, the BAdI implementation and the enhancement implementation. Missing one is the usual reason a search behaves as though the BAdI were not there.

Troubleshooting / FAQs

1. My search runs on a table it should not.

Expected. The filter matches the search type and name, not the table, so every table using that InfoObject gets it. Set the column's search properties in that table's configuration, or override them in the table maintenance Meta method.

2. I changed SEARCHMODE in the search Meta method and nothing happened.

That is not where a redirect belongs. The filter has already chosen this implementation. Change SEARCHMODE and SEARCHNAME per field in the table maintenance Meta method instead, and give the target Search BAdI a matching filter.

3. The dropdown is slow or incomplete.

A dropdown loads every value before it searches. Above roughly 50 values, switch SEARCHSTYLE to SEARCH and set MIN_CHAR so the query only runs once the user has typed something selective.

4. Users enter values that do not exist.

Set STRICT = 'X'. The user can then only pick from what the search returned. Leave it unset when free text is genuinely allowed.

5. Nothing happens at all.

Check the three activations, then the filter values. In the custom case, check that the search name in the table maintenance Meta method and the one in the Search BAdI filter are spelled identically.