Application Development and Automation 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: 
Read only

calculating subtotal in table control

Former Member
0 Likes
926

Hi all my requrement is like this

I am using one tabbed screen .

in the last tabbed screen i have used table control in that

screen there is one requirement so that to calculate the subtotal as we can do in case of alv reporting by using the subtotal button .

can anybody help me how to do this .

Hi all my requrement is like this

I am using one tabbed screen .

in the last tabbed screen i have used table control in that

screen there is one requirement so that to calculate the subtotal as we can do in case of alv reporting by using the subtotal button .

can anybody help me how to do this .

3 REPLIES 3
Read only

Former Member
0 Likes
644

Hi Papps,

I guess there is no subtotal functionality in Table control.

Probably what you can do is to code the subtotal logic in PAI when 'Sub Total' button is clicked and

Insert the subtotal values in in the internal table which is used for the table control.

Hope this helps you.

Thanks,

Arun

Read only

Former Member
0 Likes
644

HI,

subtotal_text

Use

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.

Event parameters

Meaning

ES_SUBTOTTXT_INFO

Type LVC_S_STXT

Structure with information on the subtotal criterion

EP_SUBTOT_LINE

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.

E_EVENT_DATA

Type Ref To CL_ALV_EVENT_DATA

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

For an overview, see: Events of Class CL_GUI_ALV_GRID

Example

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

Result

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.

Read only

0 Likes
644

hi Jagdish can we do this in table control

i did not get it properly how to do it ? would you please explain it