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: 

Sub totals & Totals in oops alv

Former Member
0 Kudos

Hi Friends,

Can you pls help me how to calculate sub totals & totals in oops alv report?

Moderator message: please search for available information.

Message was edited by: Thomas Zloch

3 REPLIES 3

reachdebopriya
Active Participant
0 Kudos

Hi Sreenivasulu,

Try this sample code as below:

DATA:   gt_sort     TYPE lvc_t_sort,

             gs_sort    TYPE lvc_s_sort.

CONSTANTS: lc_lifnr TYPE lvc_fname  VALUE 'LIFNR'.

  CLEAR :gs_sort.
  REFRESH: gt_sort.
  gs_sort-spos = 1.
  gs_sort-fieldname = lc_lifnr.
  gs_sort-up = gc_x.
  gs_sort-subtot = gc_x.
  APPEND gs_sort TO gt_sort.
  CLEAR gs_sort.

*--- Pass the sort internal table in the method

      CALL METHOD gr_grid->set_table_for_first_display
      EXPORTING
        is_variant           = gs_variant
        i_save               = lc_a
        is_layout            = gs_layout
*       it_toolbar_excluding = gt_exclude
      CHANGING
        it_outtab            = gt_final[]
        it_fieldcatalog      = gt_fieldcat[]
        it_sort              = gt_sort[].

Regards,

Debopriya Ghosh

0 Kudos

Thank you. i understood the logic.. it really helped me.

vinoth_aruldass
Contributor
0 Kudos

1) Declare event table i_event TYPE slis_t_event

2) Declare a subrouting like *PERFORM get_event.

2) In the subroutine, Declare a variable of type l_s_event TYPE slis_alv_event  & a constant as  CONSTANTS :     

     c_formname_subtotal_text TYPE slis_formname VALUE 'SUBTOTAL_TEXT'.

3) call function 'REUSE_ALV_EVENTS_GET.

4) Then Read the table I_event as below :-

     
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.

 

5) Declare a subroutine as Perform subtot_text

    In the subroutine subtot_text write code as below :-


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.

hope it helps,

Vinoth