May 24

Attribute Filter GUIBB

Let’s explore Attribute Filter GUIBB in this blog. (Blog is based on SAP_UI 7.40 SP11 (SAPK-74011INSAPUI).

Refer to below blog to know more about Attribute Filter GUIBB

** TEAM FPM ** – A New Filter UIBB

Create OVP application using transaction FPM_WB:

2017-05-24 18_10_23-183.82.114.111_3333 - Remote Desktop Connection

Attribute Filter configuration is configured as shown below:

2017-05-24 18_11_01-183.82.114.111_3333 - Remote Desktop Connection

Assigned class ZCL_FPM_GUIBB_ATTRIBUTE_FILTER as feeder for Attribute Filter UIBB:

2017-05-24 18_11_49-183.82.114.111_3333 - Remote Desktop Connection

2017-05-24 18_13_24-183.82.114.111_3333 - Remote Desktop Connection

Assigned class ZCL_FPM_GUIBB_LIST as feeder for List UIBB:

2017-05-24 18_14_27-183.82.114.111_3333 - Remote Desktop Connection

I have created wiring configuration between Attribute filter UIBB and List UIBB to transfer the data: (Note: I haven’t discussed how wiring has been done as it is available in many blogs)

2017-05-24 18_15_27-183.82.114.111_3333 - Remote Desktop Connection

Below highlighted methods are very important: 

2017-05-24 18_16_05-183.82.114.111_3333 - Remote Desktop Connection

 Below is the code for GET_DEFINITION

 DATA : lt_component_tab TYPE abap_component_tab.

 APPEND INITIAL LINE TO lt_component_tab ASSIGNING FIELD-SYMBOL(<fs_comp_tab>).
 <fs_comp_tab>-name = 'CARRID'.
 <fs_comp_tab>-type ?= cl_abap_datadescr=>describe_by_name( 'S_CARR_ID' ).

 APPEND INITIAL LINE TO lt_component_tab ASSIGNING <fs_comp_tab>.
 <fs_comp_tab>-name = 'FLDATE'.
 <fs_comp_tab>-type ?= cl_abap_datadescr=>describe_by_name( 'S_DATE' ).

 APPEND INITIAL LINE TO lt_component_tab ASSIGNING <fs_comp_tab>.
 <fs_comp_tab>-name = 'CUSTTYPE'.
 <fs_comp_tab>-type ?= cl_abap_datadescr=>describe_by_name( 'S_CUSTTYPE' ).

 APPEND INITIAL LINE TO lt_component_tab ASSIGNING <fs_comp_tab>.
 <fs_comp_tab>-name = 'CLASS'.
 <fs_comp_tab>-type ?= cl_abap_datadescr=>describe_by_name( 'S_CLASS' ).


 eo_field_catalog = cl_abap_structdescr=>create(
 p_components = lt_component_tab
 p_strict = abap_false ).

 APPEND INITIAL LINE TO et_field_description ASSIGNING FIELD-SYMBOL(<fs_field_description>).
 <fs_field_description>-name = 'CARRID'.
 <fs_field_description>-value_sort_allowed = abap_true.
 <fs_field_description>-count_sort_allowed = abap_true.
 <fs_field_description>-value_filter_allowed = abap_true.

 APPEND INITIAL LINE TO et_field_description ASSIGNING <fs_field_description>.
 <fs_field_description>-name = 'FLDATE'.
 <fs_field_description>-value_sort_allowed = abap_true.
 <fs_field_description>-count_sort_allowed = abap_true.
 <fs_field_description>-value_filter_allowed = abap_true.

 APPEND INITIAL LINE TO et_field_description ASSIGNING <fs_field_description>.
 <fs_field_description>-name = 'CUSTTYPE'.
 <fs_field_description>-value_sort_allowed = abap_true.
 <fs_field_description>-count_sort_allowed = abap_true.
 <fs_field_description>-value_filter_allowed = abap_true.

 APPEND INITIAL LINE TO et_field_description ASSIGNING <fs_field_description>.
 <fs_field_description>-name = 'CLASS'.
 <fs_field_description>-value_sort_allowed = abap_true.
 <fs_field_description>-count_sort_allowed = abap_true.
 <fs_field_description>-value_filter_allowed = abap_true.

 es_options-count_attribute_name = 'MY_COUNT'.

 

 Below is the code for PROCESS_EVENT:

 IF io_event->mv_event_id EQ 'FPM_ATTR_FILTER_VAL_SELECTION'.
   me->go_container_class->it_selection_condition = it_selection_condition.
 ENDIF.

 

Below is the code for GET_VALUES:

 DATA : l_order_by TYPE string.

 DATA(l_where) = create_where_clause( it_selection_condition ).

 IF iv_sort_state_values EQ if_wd_attribute_filter=>e_sort_state-ascending.
 CONCATENATE iv_name 'ascending' INTO l_order_by SEPARATED BY space.
 ELSEIF iv_sort_state_values EQ if_wd_attribute_filter=>e_sort_state-descending.
 CONCATENATE iv_name 'descending' INTO l_order_by SEPARATED BY space.
 ENDIF.

 IF iv_sort_state_count EQ if_wd_attribute_filter=>e_sort_state-ascending.
 CONCATENATE iv_count_attribute_name 'ascending' INTO l_order_by SEPARATED BY space.
 ELSEIF iv_sort_state_count EQ if_wd_attribute_filter=>e_sort_state-descending.
 CONCATENATE iv_count_attribute_name 'ascending' INTO l_order_by SEPARATED BY space.
 ENDIF.


 CASE iv_name.
 WHEN 'CARRID'.
 SELECT carrid COUNT( * ) AS my_count
 FROM sbook
 INTO CORRESPONDING FIELDS OF TABLE et_value
 UP TO iv_max_number_of_hits ROWS GROUP BY carrid
 ORDER BY (l_order_by).

 WHEN 'FLDATE'.
 SELECT fldate COUNT( * ) AS my_count
 FROM sbook
 INTO CORRESPONDING FIELDS OF TABLE et_value
 UP TO iv_max_number_of_hits ROWS GROUP BY fldate
 ORDER BY (l_order_by).

 WHEN 'CUSTTYPE'.
 SELECT custtype COUNT( * ) AS my_count
 FROM sbook
 INTO CORRESPONDING FIELDS OF TABLE et_value
 UP TO iv_max_number_of_hits ROWS GROUP BY custtype
 ORDER BY (l_order_by).

 WHEN 'CLASS'.
 SELECT class COUNT( * ) AS my_count
 FROM sbook
 INTO CORRESPONDING FIELDS OF TABLE et_value
 UP TO iv_max_number_of_hits ROWS GROUP BY class
 ORDER BY (l_order_by).
 WHEN OTHERS.
 ENDCASE.

 SELECT COUNT( * ) FROM sbook INTO ev_total_records_count WHERE (l_where).

 CASE iv_name.
 WHEN 'CARRID'.
 SELECT COUNT( DISTINCT carrid ) FROM sbook INTO ev_total_values_count WHERE (l_where).
 WHEN 'FLDATE'.
 SELECT COUNT( DISTINCT fldate ) FROM sbook INTO ev_total_values_count WHERE (l_where).
 WHEN 'CUSTTYPE'.
 SELECT COUNT( DISTINCT custtype ) FROM sbook INTO ev_total_values_count WHERE (l_where).
 WHEN 'CLASS'.
 SELECT COUNT( DISTINCT class ) FROM sbook INTO ev_total_values_count WHERE (l_where).
 WHEN OTHERS.
 ENDCASE.

 

2017-05-24 18_17_11-183.82.114.111_3333 - Remote Desktop Connection

Below is the code for GET_DATA:
 DATA : lt_sbook TYPE ty_bookings,
 l_where TYPE string.

 IF iv_eventid->mv_event_id EQ 'FPM_START'.
 SELECT *
   FROM sbook
   INTO TABLE gt_sbook.
   ct_data = gt_sbook.

 ELSEIF iv_eventid->mv_event_id EQ 'FPM_ATTR_FILTER_ATTR_SELECTION'.
 ELSEIF iv_eventid->mv_event_id EQ 'FPM_ATTR_FILTER_VAL_SELECTION'.

 DATA(lt_selection_condition) = go_connector_class->go_container_class->it_selection_condition.
 l_where = me->create_where_clause( lt_selection_condition ).

 SELECT *
   FROM sbook
   INTO TABLE lt_sbook
   WHERE (l_where).

 ct_data = lt_sbook.
 ev_data_changed = abap_true.
 ENDIF.

 

Once the application is launched:

On the right hand side, we can see the filter attributes: [which come from GET_DEFINITION method]

2017-05-24 18_19_56-183.82.114.111_3333 - Remote Desktop Connection

Select ‘Airline’ attribute, its distinct values are displayed along with their count:

2017-05-24 18_20_40-183.82.114.111_3333 - Remote Desktop Connection

Choose airline value ‘JL’ to filter the list ouput (9010 records are displayed after airline selection). Click Class now..

2017-05-24 18_21_32-183.82.114.111_3333 - Remote Desktop Connection

and select ‘First Class’ to further filter down the list output:

2017-05-24 18_22_11-183.82.114.111_3333 - Remote Desktop Connection

After applying Airline and Class, list got filtered to 405 records:

2017-05-24 18_22_37-183.82.114.111_3333 - Remote Desktop Connection

Choose ‘Customer type’ to filter the list output further:

2017-05-24 18_23_15-183.82.114.111_3333 - Remote Desktop Connection