Grouping Attributes in Select Options

Use

In applications that use select options you can arrange attributes in groups, which you can create yourself.

Groups have the following properties:

  • Each group has a header.

  • Each attribute can only belong to one group.

  • Groups can be expanded and collapsed.

  • The link to exclude attributes from the results appears at the end of each group provided at least one attribute of the group can be excluded.

  • The panel for the search criteria overall can still be used.

Procedure

To create a group, follow the steps below:

  1. Define the component usage for WD_SELECT_OPTIONS_20 in your Web Dynpro application.

  2. Define a view container in your view and embed interface W_SELECT_OPTIONS.

  3. You can obtain an instance of the select option handler with the following code:

    lo_interfacecontroller =   wd_this->wd_cpifc_sel_opt( ).
    
    wd_comp_controller->mo_grouped_sel_opt  = lo_interfacecontroller->init_grouped_select_options(
          general_texts =   ls_general_texts             " wdso_general_texts
          general_visibility = ls_general_visibility        " wdso_general_visibility
          global_options =   ls_global_options            " wdso_global_options
          saved_searches = lt_saved_searches              " wdso_tt_value_set
          groups   = lt_groups       ). 
    
                   
  4. Add the attributes before the view is displayed:

    wd_comp_controller->mo_sel_opt->add_attributes( 
                       EXPORTING attributes = lt_attributes
                                 initial_data = lt_initial_data
                                 var_date_attributes = lt_test_var_date ).  
    
                   
  5. Register for event ON_EXECUTE and import the user input for a single attribute:

    wd_comp_controller->mo_sel_opt->get_input_per_attribute(  
                     EXPORTING attribute = ls_attributes-attribute
                               include_unvaluated_rows = lv_unvaluated_rows
                     IMPORTING values =  lt_input  ).
    
                   

    If you want to import the user input for all attributes simultaneously, change the code as follows:

    wd_comp_controller->mo_sel_opt->get_input_complete( IMPORTING values =  lt_input  ).
                   

The same interface methods are available for groups of attributes as for single attributes. In addition, there are the following methods for groups:

  • GET_INPUT_PER_GROUP: Returns the value assignments per group.

  • GET_INPUT_PER_GROUP_AS_RANGE: Returns the value assignments per group as an ABAP range.

  • GET_GROUP_STATE: Ascertains whether groups are expanded or collapsed.

  • CLEAR_INPUT_PER_GROUP: Resets the value assignments per group.

  • RESET_GROUP_DEFINITION: Changes the definition of the group (for example, its title, or expanded/collapsed status).

  • SET_GROUP_STATE: Sets the status of the group.

Constraints

The columns are arranged in groups provided the view is large enough. This group layout will be lost if the size of the window is changed or if the popups are too small. This behavior can only be avoided if the width of the UI element Container is fixed. If it is, a scroll bar is displayed in the popup. A scroll bar is also displayed if the size of the window is changed.