Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How To Maintain Sub Total texts in the ALV grid display.

Former Member
0 Kudos
252

Hi Experts,

Can anyone explain me how  to maintain texts in the alv grid display with a demo program.

How To Maintain Sub Total texts in the ALV grid display.

Thanks,

Narendra Reddy.

3 REPLIES 3

jogeswararao_kavala
Active Contributor
0 Kudos
139

Hello Narendra,

In ALV grid display, when we hide a column on which subtotals are computed, then the hidden column name and its value appear in the subtotal line. In the following picture Equipment column on which subtotals of Dly(Mn) column was computed, was hidden. So the Equipment number is appearing in the sub total line.

Is this your requirement?

KJogeswaraRao

Former Member
0 Kudos
139

Hi,

You want change subtotal text by your abap code?

Then you need register a form(subtotal_text) in alv event, as below code:

* Subtotal

  READ TABLE i_event  INTO l_s_event

                    WITH KEY name = slis_ev_subtotal_text.

  IF sy-subrc = 0.

    MOVE c_formname_subtotal_text TO l_s_event-form.

    MODIFY i_event FROM l_s_event INDEX sy-tabix.

  ENDIF.

FORM subtotal_text CHANGING

               p_total TYPE any

               p_subtot_text TYPE slis_subtot_text.

* Material level sub total

  IF p_subtot_text-criteria = 'MATNR'.

    p_subtot_text-display_text_for_subtotal

    = 'Material level total'(009).

  ENDIF.

* Plant level sub total

  IF p_subtot_text-criteria = 'WERKS'.

    p_subtot_text-display_text_for_subtotal = 'Plant level total'(010).

  ENDIF.

ENDFORM.                    "subtotal_text

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

       it_events                = i_event...

regards,

Archer

rajkumarnarasimman
Active Contributor
0 Kudos
139

Hi Narendra,

For maintaining the subtotal text, we need to do the following steps.

  • Mention the field name based on which we are going to sort

* Sort on material

  wa_sort-spos = '01' .

  wa_sort-fieldname = 'MATNR'.

  wa_sort-tabname = 'I_EKPO'.

  wa_sort-up = 'X'.

  wa_sort-subtot = 'X'.

  APPEND wa_sort TO i_sort .

  CLEAR wa_sort.

  • Create the event for subtotal and mention the subroutine name.

  * Subtotal

  READ TABLE i_event  INTO l_s_event

                    WITH KEY name = slis_ev_subtotal_text.

  IF sy-subrc = 0.

    MOVE c_formname_subtotal_text TO l_s_event-form.

    MODIFY i_event FROM l_s_event INDEX sy-tabix.

  ENDIF.

  • Inside the subtotal subroutine, Assign the subtotal text name like
    • p_subtot_text-display_text_for_subtotal = 'Plant level total'
  • Call the event from Function REUSE_ALV_GRID_DISPLAY

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

      i_callback_program       = sy-repid

      i_callback_top_of_page   = 'SUB_ALV_TOP_OF_PAGE'

      it_fieldcat              = it_fieldcat

      it_sort       = i_sort

      it_events                = i_event

      i_default                = 'X'

      i_save                   = 'A'

    TABLES

      t_outtab                 = it_final.

Please find the link below

Display subtotal text in ALV grid - Code Gallery - SCN Wiki

Regards

Rajkumar Narasimman