04-07-2006 7:47 AM
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!
04-07-2006 7:54 AM
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
04-07-2006 7:54 AM
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
04-07-2006 8:02 AM
Hi Vijay,
I tried adding the subtot(the ones in bold) but it nows shows the total 3 times for everu group.
04-07-2006 8:14 AM
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
04-07-2006 8:15 AM
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.