Totals and Subtotals in ALV Web Dynpro
Totals and Subtotals in ALV Web Dynpro
Totals and Subtotals in ALV Web Dynpro
Scenario: To create a dynamic ALV based on a SFLIGHT context node in Web Dynpro for
ABAP and display the TOTALS and SUBTOTALS in it.
First, create a web dynpro application and include the ALV component in the Used Web Dynpro
Components.
Do the mapping of the node to the Data. Take Care for the Cardinality. If the Cardinality is not
proper, it gives a runtime error for cardinality.
Now in the Layout, create the View Container in Which the ALV will be displayed.
Now in the Methods tab in the DOINIT, enter the following code for the ALV.
First bind the data to the ALV, instantiate the ALV and then code to display the Totals in ALV.
if lr_comp_alv->has_active_component( ) is initial.
lr_comp_alv->create_component( ).
endif.
lr_comp_if_alv = wd_this->wd_cpifc_alv_test2( ).
if lr_comp_alv->has_active_component( ) is initial.
lr_comp_alv->create_component( ).
endif.
lr_comp_if_alv = wd_this->wd_cpifc_alv_test2( ).
lt_column = lr_column_settings->get_columns( ).
case ls_column-id.
when 'PRICE'.
* aggregate field
call method lr_config->if_salv_wd_field_settings~get_field
exporting
fieldname = 'PRICE'
receiving
value = lr_field_amnt.
endcase.
endloop.
endmethod.
Now, in the Window add the View Container and the ALV Table in it.
Create a Web dynpro Application for the Program.
Activate and test the Application.
After you click the sort, the Subtotals are shown as below.