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: 

grouping problem in ALV

aris_hidalgo
Contributor
0 Kudos

Hello experts,

I am currently having a problem in my ALV display of my report. I grouped the display by 3 fields by its date, ship to party name and region. Now, I added in the grouping that it would do a subtotal for every group. Here is the code below:

DATA: gs_sort2 TYPE slis_sortinfo_alv.

CLEAR gs_sort2.

gs_sort2-fieldname = 'BUDAT_WADAT'.

gs_sort2-group = 'UL'.

APPEND gs_sort2 TO %sort.

CLEAR gs_sort2.

gs_sort2-fieldname = 'LGORT_KUNNR'.

gs_sort2-group = 'UL'.

APPEND gs_sort2 TO %sort.

CLEAR gs_sort2.

gs_sort2-fieldname = 'REGION'.

gs_sort2-subtot = 'X'.

gs_sort2-group = 'UL'.

APPEND gs_sort2 TO %sort.

for example, there is a group like below in the display:

ISSUE DATE |SHIP TO PARTY |REGION |COST |

04/07/2006 |DL0001 |MIN |10 |

04/07/2006 |DL0001 |MIN |20 |

-


"underline

09/28/2004 |DL0001 |MIN |20 |

-


09/21/2004 |DL0001 |MIN |50 |

*Total 100

-


As you can see in the sample display I made, there is only one subtotal display which is wrong since they are 3 different groups since the 1st group has a different date and the same goes with groups 2 and 3. here is what I want to be displayed:

ISSUE DATE |SHIP TO PARTY |REGION |COST |

04/07/2006 |DL0001 |MIN |10 |

04/07/2006 |DL0001 |MIN |20 |

*Total 30

-


"underline

09/28/2004 |DL0001 |MIN |20 |

*Total 20

-


09/21/2004 |DL0001 |MIN |50 |

*Total 50

-


So if you notice, it adds the costs even though they are in different groups which is wrong. What I want is that for every group the subtotal will be displayed. I used the statement:

gs_sort2-subtot = 'X'.

to display the subtotal for every grouping but I am getting the wrong output as I have explained earlier. Again, Thanks for all your help and take care!

1 ACCEPTED SOLUTION

former_member188685
Active Contributor
0 Kudos

Hi VIray,

do this ...add bold code...

DATA: gs_sort2 TYPE slis_sortinfo_alv.
CLEAR gs_sort2.
gs_sort2-fieldname = 'BUDAT_WADAT'.
gs_sort2-group = 'UL'.
<b>gs_sort2-subtot = 'X'.</b>
APPEND gs_sort2 TO %sort.

CLEAR gs_sort2.
gs_sort2-fieldname = 'LGORT_KUNNR'.
gs_sort2-group = 'UL'.
<b>gs_sort2-subtot = 'X'.</b>
APPEND gs_sort2 TO %sort.

CLEAR gs_sort2.
gs_sort2-fieldname = 'REGION'.
gs_sort2-subtot = 'X'.
gs_sort2-group = 'UL'.
APPEND gs_sort2 TO %sort.

Regards

vijay

4 REPLIES 4

former_member188685
Active Contributor
0 Kudos

Hi VIray,

do this ...add bold code...

DATA: gs_sort2 TYPE slis_sortinfo_alv.
CLEAR gs_sort2.
gs_sort2-fieldname = 'BUDAT_WADAT'.
gs_sort2-group = 'UL'.
<b>gs_sort2-subtot = 'X'.</b>
APPEND gs_sort2 TO %sort.

CLEAR gs_sort2.
gs_sort2-fieldname = 'LGORT_KUNNR'.
gs_sort2-group = 'UL'.
<b>gs_sort2-subtot = 'X'.</b>
APPEND gs_sort2 TO %sort.

CLEAR gs_sort2.
gs_sort2-fieldname = 'REGION'.
gs_sort2-subtot = 'X'.
gs_sort2-group = 'UL'.
APPEND gs_sort2 TO %sort.

Regards

vijay

0 Kudos

Hi Vijay,

I tried adding the subtot(the ones in bold) but it nows shows the total 3 times for everu group.

0 Kudos

Hi Viray,

yes it will give, since you want the total, even a change in any one them , or else you do one thing do sub total only on date filed. then it will give the total for each change in date.

Regards

vijay

0 Kudos
DATA: gs_sort2 TYPE slis_sortinfo_alv.
CLEAR gs_sort2.
gs_sort2-fieldname = 'BUDAT_WADAT'.
gs_sort2-group = 'UL'.
<b>gs_sort2-subtot = 'X'.</b>
APPEND gs_sort2 TO %sort.
 
CLEAR gs_sort2.
gs_sort2-fieldname = 'LGORT_KUNNR'.
gs_sort2-group = 'UL'.
APPEND gs_sort2 TO %sort.
 
CLEAR gs_sort2.
gs_sort2-fieldname = 'REGION'.
<b>*gs_sort2-subtot = 'X'.</b>
gs_sort2-group = 'UL'.
APPEND gs_sort2 TO %sort.