Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

grouping problem in ALV

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!

Tags:
Former Member
replied
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.
0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question