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 get Subtotal text in ALV using OOPS

Former Member
0 Kudos

hi,

Can any one pls help me out getting <b>subtotals text</b> in ALV using OOPS concepts....Pls provide me if any of u have sample code for that......

my code:

data:gr_grid_d0100 type ref to cl_gui_alv_grid.

data : gr_events_d0100 type ref to lcl_events_d0100.

classes**********

class lcl_events_d0100 definition.

public section.

methods:

subtotal_text for event subtotal_text

of cl_gui_alv_grid

importing es_subtottxt_info

ep_subtot_line

e_event_data.

endclass.

*****************************

class lcl_events_d0100 implementation.

method subtotal_text.

perform d0100_event_subtotal_text using es_subtottxt_info

ep_subtot_line

e_event_data.

endmethod. "subtotal_text

endclass.

data : gr_event_handler type ref to lcl_events_d0100.

SET HANDLER gr_event_handler->subtotal_text FOR wcl_alv_grid_request

****************

FORM d0100_event_subtotal_text USING

es_subtottxt_info TYPE LVC_S_STXT

ep_subtot_line TYPE REF TO data

e_event_data TYPE REF TO cl_alv_event_data.

DATA: l_text TYPE string.

l_text = es_subtottxt_info.

FIELD-SYMBOLS: <fs> TYPE ANY.

ASSIGN e_event_data->m_data->* TO <fs>.

<fs> = text-007.

3 REPLIES 3

Former Member
0 Kudos

Vijay,

Take a look at this sample code.

Define and implement an event handler method for event subtotal_text. Register this event with SET HANDLER.

2. Call a subroutine within this method and pass the event parameters to that subroutine.

3. Event parameters ep_subtot_line and e_event_data contain reference variables to generic data type DATA. This is why you must use field symbols in the subroutine:

FORM method_subtotal_text USING es_subtottxt_info TYPE lvc_s_stxt ep_subtot_line TYPE REF TO data e_event_data TYPE REF TO cl_alv_event_data.

DATA ls_sflight LIKE sflight.

FIELD-SYMBOLS: <fs1> STRUCTURE sflight DEFAULT ls_sflight, <fs2>.

IF es_subtottxt_info-criteria = 'PLANETYPE'.

ASSIGN ep_subtot_line->* TO <fs1>.

ASSIGN e_event_data->m_data->* TO <fs2>.

CONCATENATE es_subtottxt_info-keyword ': ' <fs1>-planetype INTO <fs2>.

ENDIF.

Regards,

Ravi

Note : Please mark the helpful answers

Former Member
0 Kudos

Hi,

This option is available in ALV Report

it subtotals based on the keys; when you select the option or sort the ALV report. No need to write extra code for it.

Just Try sorting the ALV report with option available

Regards

Manoj B gupta

Former Member
0 Kudos

hi vijay

check this code

if you want to use field symbols.

data: total type ref to data,

subtotal1 type ref to data.

field-symbols <total> like gt_sflight.

field-symbols <subtotal1> like gt_sflight.

call method grid1->get_subtotals

importing

ep_collect00 = total

ep_collect01 = subtotal1.

assign total->* to <total>.

assign subtotal1->* to <subtotal1>.

or u can use

U have to do the subtotal column wise.In the field catalog specify the following in addition to the corresponding field name(i.e. Column)

DATA ls_fcat TYPE lvc_s_fcat.

ls_fcat-do_sum = 'X'.

Hope this helps u out.

Thanks & Regards,

naveen