Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Totaal in alv table

hai all,

I want to sum the value of amount in alv table and i have to assign the value ti a text view in my screen.

I have created this code inside a method called create_total.

DATA: lo_cmp_usage TYPE ref to if_wd_component_usage.

DATA: lr_salv_wd_table TYPE REF TO iwci_salv_wd_table.

DATA: lr_column_settings TYPE REF TO if_salv_wd_column_settings.

DATA: lr_column TYPE REF TO cl_salv_wd_column.

DATA: lt_column TYPE salv_wd_t_column_ref,

ls_column TYPE salv_wd_s_column_ref.

DATA: lr_function_settings TYPE REF TO CL_SALV_WD_CONFIG_TABLE.

DATA: lr_field_settings TYPE REF TO IF_SALV_WD_FIELD_SETTINGS,

lr_field_curr TYPE REF TO CL_SALV_WD_FIELD,

lr_field_amnt TYPE REF TO CL_SALV_WD_FIELD.

DATA: lv_aggr_rule TYPE REF TO CL_SALV_WD_AGGR_RULE.

DATA: lr_sort_rule TYPE REF TO CL_SALV_WD_SORT_RULE.

*create an instance of ALV component

lo_cmp_usage = wd_this->wd_cpuse_ALV( ).

  • if not initialized, then initialize

if lo_cmp_usage->has_active_component( ) is initial.

lo_cmp_usage->create_component( ).

endif.

" get ALV component

lr_salv_wd_table = wd_this->wd_cpifc_ALV( ).

lr_function_settings = lr_salv_wd_table->get_model( ).

  • get reference to column settings

lr_column_settings ?= lr_function_settings.

  • get all columns

lt_column = lr_column_settings->get_columns( ).

  • loop at columns

loop at lt_column into ls_column.

CASE ls_column-id.

when 'AMOUNT'.

  • for AMOUNT aggregate field

CALL METHOD LR_FUNCTION_SETTINGS->IF_SALV_WD_FIELD_SETTINGS~GET_FIELD

EXPORTING

FIELDNAME = 'AMOUNT'

RECEIVING

VALUE = lr_field_amnt.

  • create aggregate rule as total

CALL METHOD LR_FIELD_AMNT->IF_SALV_WD_AGGR~CREATE_AGGR_RULE

EXPORTING

AGGREGATION_TYPE = IF_SALV_WD_C_AGGREGATION=>AGGRTYPE_TOTAL

RECEIVING

VALUE = lv_aggr_rule.

*hide others when OTHERS.

"ls_column-r_column->set_visible( if_wdl_core=>visibility_none ).

endcase.

endloop.

and I have called this inside wddoinit using'

wd_this->create_total( ).

but am not getting that total row in my alv table.

Pls help me in solving this and how to assign this total value to a field n my screen.

Thanks in advance,

Nalla.B

Former Member
Not what you were looking for? View more on this topic or Ask a question