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: 

Adding row after subtotal in ALV

Former Member
0 Kudos
219

Hi Guys,

can we add one row after the subtotal in ALV.

Like the below...

field1 field2 field3 field4

Sub total. 120 121 125 130

Test 150

can you help me about the above...

Thanks,

Lingesh

1 ACCEPTED SOLUTION

Former Member
0 Kudos
59

Hi

You can try to use the event GROUPLEVEL_CHANGE or SUBTOTAL_TEST, but I know they work for REUSE_ALV_LIST_DISPLAY.

Max

4 REPLIES 4

Former Member
0 Kudos
60

Hi

You can try to use the event GROUPLEVEL_CHANGE or SUBTOTAL_TEST, but I know they work for REUSE_ALV_LIST_DISPLAY.

Max

Former Member
0 Kudos
59

Can any one send some sample code for the same...

0 Kudos
59

Hi

If you use GROUPLEVEL_CHANGE you have to creare a form like this:

FORM GROUPLEVEL_CHANGE

USING P_LINEINFO TYPE SLIS_LINEINFO

LS_GROUPS TYPE KKBLO_GROUPLEVELS.

ENDFORM. "GROUPLEVEL_CHANGE

In the P_LINEINFO you have details of row and in the LS_GROUPS details of level of sorting.

For example I used it to re-write subtotal:

FORM GROUPLEVEL_CHANGE USING P_LINEINFO TYPE SLIS_LINEINFO

LS_GROUPS TYPE KKBLO_GROUPLEVELS.

PERFORM WRITE_SUB_TOTAL USING LS_GROUPS.

ENDFORM. "GROUPLEVEL_CHANGE

FORM WRITE_SUB_TOTAL USING P_GROUPS TYPE KKBLO_GROUPLEVELS.

DATA: TOT_SALDO_A LIKE BSID-DMBTR,

TOT_FATTURATO_A LIKE BSID-DMBTR,

TOT_DSO_A LIKE BSID-DMBTR.

DATA: WA_GROUP TYPE KKBLO_GROUPLEVELS.

DATA: RUN_LEVEL TYPE I.

DATA: BEGIN OF T_LEVEL OCCURS 1,

LEVEL TYPE I,

INDEX_FROM TYPE I,

INDEX_TO TYPE I,

END OF T_LEVEL.

T_LEVEL-LEVEL = P_GROUPS-LEVEL.

T_LEVEL-INDEX_FROM = P_GROUPS-INDEX_FROM.

T_LEVEL-INDEX_TO = P_GROUPS-INDEX_TO.

APPEND T_LEVEL.

  • Check livel:

CALL FUNCTION 'ALV_GROUPLEVELS_GET'

IMPORTING

ET_GROUPS = GT_GROUP

TABLES

T_OUTTAB = <FS_OUTPUT>.

RUN_LEVEL = P_GROUPS-LEVEL + 1.

IF RUN_LEVEL <= LEVEL.

DO.

LOOP AT GT_GROUP INTO WA_GROUP

WHERE INDEX_FROM => P_GROUPS-INDEX_FROM

AND INDEX_TO <= P_GROUPS-INDEX_TO

AND LEVEL = RUN_LEVEL.

T_LEVEL-LEVEL = RUN_LEVEL.

T_LEVEL-INDEX_FROM = WA_GROUP-INDEX_FROM.

T_LEVEL-INDEX_TO = WA_GROUP-INDEX_TO.

ENDLOOP.

IF SY-SUBRC = 0.

APPEND T_LEVEL.

ENDIF.

RUN_LEVEL = RUN_LEVEL + 1.

IF RUN_LEVEL > LEVEL. EXIT. ENDIF.

ENDDO.

ENDIF.

SORT T_LEVEL BY LEVEL DESCENDING.

LOOP AT T_LEVEL.

TOT_SALDO_A = TOT_FATTURATO_A = 0.

LOOP AT <FS_OUTPUT> INTO <FS_WA_OUT>

FROM T_LEVEL-INDEX_FROM

TO T_LEVEL-INDEX_TO.

ASSIGN COMPONENT 'ZSALDO'

OF STRUCTURE <FS_WA_OUT> TO <FS_SALDO>.

ASSIGN COMPONENT 'ZFATTURATO'

OF STRUCTURE <FS_WA_OUT> TO <FS_FATTURATO>.

TOT_SALDO_A = TOT_SALDO_A + <FS_SALDO>.

TOT_FATTURATO_A = TOT_FATTURATO_A + <FS_FATTURATO>.

ENDLOOP.

TOT_SALDO = TOT_SALDO + TOT_SALDO_A .

TOT_FATTURATO = TOT_FATTURATO + TOT_FATTURATO_A.

PERFORM CALCULATE_DSO USING TOT_FATTURATO_A

TOT_SALDO_A TOT_DSO_A.

PERFORM WRITE_TOT_DSO

USING TOT_SALDO_A

TOT_FATTURATO_A TOT_DSO_A

T_LEVEL-LEVEL T_LEVEL-INDEX_FROM.

ENDLOOP.

ENDFORM. " WRITE_SUB_TOTAL

Max

Former Member
0 Kudos
59

Max,

Can you please tell how did you find out the parameters for the subroutine GROUPLEVEL_CHANGE