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

Sub total in ALV GRID using oops concept

Former Member
0 Likes
740

Hi,

If Plant (VBAP-WERKS) is not the same for all items on a Sales Order (VBAK-VBELN is the same for al items) then create a separate line on the report for each different plant specified in the line items. Copy all fields from the original order line except for plant and Net Value. Net Value should be the total of item Net Values for all items with the same plant in the order.

Example:

Data:

Order---- Item- Plant- Net Value---

123---- 010- 3467- 100.00---

123---- 020- 7865- 50.00---

123---- 030- 3467- 80.50---

Report:

Order- Plant- Net Value---

123- 3467- 180.50---

123- 7865- 50.00----

I need to dispaly the Report format in ALV Grid using oops concept...

no need of calling any function modules.

Regards,

Nithya

Hi,

If Plant (VBAP-WERKS) is not the same for all items on a Sales Order (VBAK-VBELN is the same for al items) then create a separate line on the report for each different plant specified in the line items. Copy all fields from the original order line except for plant and Net Value. Net Value should be the total of item Net Values for all items with the same plant in the order.

Example:

Data:

Order---- Item- Plant- Net Value---

123---- 010- 3467- 100.00---

123---- 020- 7865- 50.00---

123---- 030- 3467- 80.50---

Report:

Order- Plant- Net Value---

123- 3467- 180.50---

123- 7865- 50.00----

I need to dispaly the Report format in ALV Grid using oops concept...

no need of calling any function modules.

Regards,

Nithya

1 REPLY 1
Read only

Former Member
0 Likes
424

Hi

Here is example code

This is the method to be called:

get_subtotals


Use

Returns the current subtotals of the ALV Grid Control. Having created totals for at least one column, users can calculate at most nine subtotals. The list is sorted by the values of one or several columns (called the subtotals column). If a value is changed in the subtotals column, the subtotal is displayed (this is also referred to as control level change).

Integration

Before you access the subtotals value, you use the method get_sort_criteria to get the sort table . One row of this table describes properties of a column in the output table.

• If the field SUBTOT is set for a column in this table, the column is a subtotals column.

• The field SPOS then indicates at which level (see below) the subtotal has been calculated.

• The field FIELDNAME contains the name of the subtotals column in the output table.

Based on this information, you specifically access the values of the tables passed (using reference variables COLLECT01 to COLLECT09).

Features


CALL METHOD <ref. var. to CL_GUI_ALV_GRID>->get_subtotals
IMPORTING 
EP_COLLECT00 = <reference variable of type REF TO DATA> 
EP_COLLECT01 = <reference variable of type REF TO DATA> 
EP_COLLECT02 = <reference variable of type REF TO DATA> 
EP_COLLECT03 = <reference variable of type REF TO DATA> 
EP_COLLECT04 = <reference variable of type REF TO DATA>
 EP_COLLECT05 = <reference variable of type REF TO DATA>
 EP_COLLECT06 = <reference variable of type REF TO DATA>
 EP_COLLECT07 = <reference variable of type REF TO DATA>
 EP_COLLECT08 = <reference variable of type REF TO DATA> 
EP_COLLECT09 = <reference variable of type REF TO DATA> 
ET_GROUPLEVELS = <ínternal table of type LVC_T_GRPL>.

In order to access the values of EP_COLLECT00 to EP_COLLECT09, you use ASSIGN to dereference the relevant reference variable in a field symbol of your output table type (see below).

Parameters

Meaning

EP_COLLECT00

Points to the totals line. Since there is only one totals line which, in addition, has a unique totalling area, no further information is available for this table in table ET_GROUPLEVELS.

get_subtotals

EP_COLLECT01 to EP_COLLECT09

Point to the subtotals line. For each subtotals level, there is one reference variable. Each of these variables points to an internal table that has the type of the output table. EP_COLLECT01 points to the subtotal at the hightest level, while EP_COLLECT02 points to the subtotal at the second highest level, and so on. The levels are derived from the sort priority (field SPOS in the sort table ). The column by which the data was sorted first, is the highest subtotals level.

ET_GROUPLEVELS

Manages all indexes for the individual control levels. The fields of the table have the following meaning:

• INDEX_FROM, INDEX_TO: Rows of the output table for which the subtotal was created

• LEVEL: Subtotals level (see above)

• COUNTER: Number of rows for which the subtotal was created

• COMPRESS: For this subtotals line, the user has hidden the associated rows.

• COLLECT: Indicates the subtotals table (01-09) in which the values are stored

For an overview, see Methods of Class CL_GUI_ALV_GRID

Activities