cancel
Showing results for 
Search instead for 
Did you mean: 

Event SUBTOTAL_TEXT in ALV

Former Member
0 Kudos

Hi,

When does the event SUBTOTAL_TEXT get triggered in an ALV List display ?

In the parameter is_layout in REUSE_ALV_LIST_DISPLAY there we can passthe subtotal text. But if passed the same subtotal text appears everywhere. Can I use the event SUBTOTAL_TEXT for giving different subtotal texts?

Any pointers will be of great help.

Regards

Rajesh

Accepted Solutions (0)

Answers (2)

Answers (2)

ssimsekler
Active Contributor
0 Kudos

Hi Rajesh

Here is the definition for the event "SUBTOTAL_TEXT" of OO version of ALV Grid Control. I think it should be similar for "REUSE_ALV" or you may select to convert yours to OO version:

Output text for subtotals in the grid control if the subtotal criterion (column used by the user for calculating the subtotal) is hidden. In the default setting, the ALV Grid Control outputs the column header of the subtotal criterion and the value to which the subtotal calculated refers.

<b>Event parameters:</b>

<u>ES_SUBTOTTXT_INFO</u> Type LVC_S_STXT

Structure with information on the subtotal criterion

<u>EP_SUBTOT_LINE</u> Type Ref To DATA

Reference variable to the inserted subtotal line in the grid control. Columns for which no total was calculated remain set to their initial value.

<u>E_EVENT_DATA</u> Type Ref To CL_ALV_EVENT_DATA

Attribute M_DATA of this object is a reference to the subtotal text.

<b>Example</b>

You display a table with data of structure SFLIGHT in an ALV Grid Control. We now change the pre-set subtotal text for subtotal criterion plane type of table SFLIGHT :

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

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

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.

ENDFORM. " METHOD_SUBTOTAL_TEXT

<b>Result</b>

Check your result as follows:

Calculate the total for a column.

Calculate subtotals for column plane type .

Hide column plane type . To do this, use either the standard context menu or a new layout.

The new text defined is displayed at the beginning of a subtotal line.

P.S.: This info is from SAP Library

*--Serdar

Former Member
0 Kudos

IS_LAYOUT is a structure, so SUBTOTAL_TEXT can be filled only once.

VXLozano
Active Contributor
0 Kudos

If you have not high-speed requirements, try to work with class cl_gui_alv_grid. I did not work a lot with it, but being an object, I'm sure you can modify (or make an inherited class) it to catch that event and change the method.

I'm sorry I cannot give you more details. Good luck,

Vicenç