ALV with IDA(ALV on HANA)-9

alv-ida

Default Sorting, Total and Subtotal 

 

 

Interface IF_SALV_GUI_LAYOUT_IDA can be used to apply default sorting & performing aggregation function such as SUM, MAX, MIN etc.

1

Code:


DATAlr_salv TYPE REF TO if_salv_gui_table_ida,
              lr_layout TYPE REF TO if_salv_gui_layout_ida,
              lt_sort TYPE if_salv_gui_types_ida=>yt_sort_rule,
               lt_aggr TYPE if_salv_gui_types_ida=>yt_aggregation_rule.
cl_salv_gui_table_ida=>create(
  EXPORTING
    iv_table_name       =  ‘SFLIGHT’
  RECEIVING
    ro_alv_gui_table_ida lr_salv ).
* Get the layout reference
lr_layout lr_salv->default_layout).

* Set descending sort
APPEND INITIAL LINE TO lt_sort ASSIGNING FIELDSYMBOL(<fs_sort>).
<fs_sort>field_name ‘CARRID’.
<fs_sort>descending abap_true.
lr_layout->set_sort_orderit_sort_order lt_sort ).

* Set aggregation SUM
APPEND INITIAL LINE TO lt_aggr ASSIGNING FIELDSYMBOL(<fs_aggr>).
<fs_aggr>field_name ‘SEATSOCC’.
<fs_aggr>function ‘SUM’.
lr_layout->set_aggregationsit_aggregations =  lt_aggr ).

* Display ALV
lr_salv->fullscreen)->display).



2

Outut: 

3


Code- Total & Subtotal


DATAlr_salv TYPE REF TO if_salv_gui_table_ida,
              lr_layout TYPE REF TO if_salv_gui_layout_ida,
              lt_sort TYPE if_salv_gui_types_ida=>yt_sort_rule,
              lt_aggr TYPE if_salv_gui_types_ida=>yt_aggregation_rule.
cl_salv_gui_table_ida=>create(
  EXPORTING
    iv_table_name       =  ‘SFLIGHT’
  RECEIVING
    ro_alv_gui_table_ida lr_salv ).

* Get the layout reference
lr_layout lr_salv->default_layout).

* Set descending sort
APPEND INITIAL LINE TO lt_sort ASSIGNING FIELDSYMBOL(<fs_sort>).
<fs_sort>field_name ‘CARRID’.
<fs_sort>descending abap_false.
<fs_sort>is_grouped abap_true.
lr_layout->set_sort_orderit_sort_order lt_sort ).

* Set aggregation SUM
APPEND INITIAL LINE TO lt_aggr ASSIGNING FIELDSYMBOL(<fs_aggr>).
<fs_aggr>field_name ‘SEATSOCC’.
<fs_aggr>function ‘SUM’.
lr_layout->set_aggregationsit_aggregations =  lt_aggr ).

* Display ALV
lr_salv->fullscreen)->display).


4

Output with total and subtotal based on CARRID group.

56


 

Advertisements

One comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s