Skip to Content
0
Former Member
Dec 07, 2009 at 02:40 PM

I need the grand total for particular coulumn for ALV grid report(OOPs).

26 Views

Hello,

I have used the following code,

But i m not getting the grand total by default.No error but not getting the desired result.

Could you please help me in this regard.

FORM display_simple_alv.

DATA : lr_msg TYPE REF TO cx_salv_msg.

DATA : lv_header TYPE REF TO cl_salv_form_layout_grid,

lv_h_label TYPE REF TO cl_salv_form_label,

lv_h_flow TYPE REF TO cl_salv_form_layout_flow.

DATA: gr_sorts TYPE REF TO cl_salv_sorts.

DATA: gr_agg TYPE REF TO cl_salv_aggregations.

TRY .

cl_salv_table=>factory( IMPORTING r_salv_table = gr_salv_table

CHANGING t_table = gt_invdetails4 ).

CATCH cx_salv_msg INTO lr_msg.

ENDTRY .

  • Display Basic Toolbar

gr_functions = gr_salv_table->get_functions( ).

gr_functions->set_all( abap_true ).

TRY .

gr_columns = gr_salv_table->get_columns( ).

gr_columns->set_optimize( ).

CATCH cx_salv_not_found.

ENDTRY .

*

TRY .

gr_column ?= gr_columns->get_column( 'KUNNR' ).

gr_column->set_long_text( text-009 ).

gr_column->set_medium_text( text-009 ).

gr_column->set_short_text( text-009 ).

gr_column ?= gr_columns->get_column( 'NAME1' ).

gr_column->set_long_text( text-010 ).

gr_column->set_medium_text( text-010 ).

gr_column->set_short_text( text-011 ).

gr_column ?= gr_columns->get_column( 'AMOUNT' ).

gr_column->set_long_text( text-012 ).

gr_column->set_medium_text( text-012 ).

gr_column->set_short_text( text-012 ).

gr_column ?= gr_columns->get_column( 'TAX' ).

gr_column->set_long_text( text-013 ).

gr_column->set_medium_text( text-013 ).

gr_column->set_short_text( text-013 ).

gr_column ?= gr_columns->get_column( 'IVA' ).

gr_column->set_long_text( text-014 ).

gr_column->set_medium_text( text-014 ).

gr_column->set_short_text( text-015 ).

gr_column ?= gr_columns->get_column( 'TOTAL_AMOUNT' ).

gr_column->set_long_text( text-016 ).

gr_column->set_medium_text( text-016 ).

gr_column->set_short_text( text-017 ).

gr_column ?= gr_columns->get_column( 'CURRENCY' ).

gr_column->set_long_text( text-018 ).

gr_column->set_medium_text( text-018 ).

gr_column->set_short_text( text-018 ).

gr_column ?= gr_columns->get_column( 'ZINTERNAL_REFNO' ).

gr_column->set_long_text( text-019 ).

gr_column->set_medium_text( text-019 ).

gr_column->set_short_text( text-019 ).

gr_column ?= gr_columns->get_column( 'MATERIAL_AMOUNT' ).

gr_column->set_long_text( text-020 ).

gr_column->set_medium_text( text-020 ).

gr_column->set_short_text( text-021 ).

gr_column ?= gr_columns->get_column( 'LABOUR_VALUE' ).

gr_column->set_long_text( text-022 ).

gr_column->set_medium_text( text-022 ).

gr_column->set_short_text( text-023 ).

gr_column ?= gr_columns->get_column( 'FAILURE_COST' ).

gr_column->set_long_text( text-024 ).

gr_column->set_medium_text( text-024 ).

gr_column->set_short_text( text-021 ).

gr_sorts = gr_salv_table->get_sorts( ).

gr_sorts->add_sort( columnname = 'AMOUNT' subtotal = abap_true ). "for subtotal

gr_agg = gr_salv_table->get_aggregations( ).

gr_agg->add_aggregation( 'AMOUNT' ).

CATCH cx_salv_not_found cx_salv_data_error cx_salv_existing.

ENDTRY .

  • Set top of page

CREATE OBJECT lv_header.

lv_h_label = lv_header->create_label( row = 1 column = 1 ).

lv_h_label->set_text( text-001 ).

lv_h_label = lv_header->create_label( row = 1 column = 5 ).

lv_h_label->set_text( text-002 ).

lv_h_label = lv_header->create_label( row = 1 column = 14 ).

lv_h_label->set_text( text-003 ).

lv_h_flow = lv_header->create_flow( row = 3 column = 04 ).

lv_h_flow->create_text( text = text-004 ).

lv_h_flow = lv_header->create_flow( row = 3 column = 05 ).

lv_h_flow->create_text( text = text-005 ).

lv_h_flow = lv_header->create_flow( row = 3 column = 06 ).

lv_h_flow->create_text( text = name ).

  • set the top of list using the header for Online.

gr_salv_table->set_top_of_list( lv_header ).

  • ALV Display

gr_salv_table->display( ).

ENDFORM . " DISPLAY_SIMPLE_ALV