‎2005 Nov 15 9:41 PM
Hi,
I am trying to generate subtotal of dmbtr based on txjcd. I can feel that my logic here is wrong but not able to trace the issue. Can anyone please help...
I want output like this
txjcd material qty local curr amt(dmbtr)
CA0000 1 15.50
CA0000 2 45.00
subtotal 55.50
CR0000 1 15.50
CR0000 2 30.00
subtotal 45.50
Total 101.00
My code is
loop at migo_data.
move-corresponding migo_data to migo_data_alv.
append migo_data_alv.
at end of txjcd.
sum.
migo_data_alv-dmbtr = migo_data-dmbtr.
append migo_data_alv.
endat.
at last.
sum.
migo_data_alv-dmbtr = migo_data-dmbtr.
append migo_data_alv.
endat.
endloop.
thanks
‎2005 Nov 15 10:09 PM
Hi,
The SUM Statement will never work between AT (FIRST/NEW/END/LAST) and ENDAT statements. If you want to get the sum then use a counter and increment it .
This is only way you can achieve this.
The SUM command will have effect only in between the LOOP and ENDLOOP statements.
Regards,
Vara
‎2005 Nov 15 9:50 PM
If you are using ALV,it has the variable which you can set it for totals & sub-totals.
DATA: GS_SORT TYPE SLIS_SORTINFO_ALV.
DATA: GS_SORT TYPE SLIS_SORTINFO_ALV.
CLEAR GS_SORT.
GS_SORT-FIELDNAME = 'EBELN'.
GS_SORT-SUBTOT = 'X'.
APPEND GS_SORT TO GT_SORT.
‎2005 Nov 15 10:02 PM
‎2005 Nov 15 10:09 PM
Hi,
The SUM Statement will never work between AT (FIRST/NEW/END/LAST) and ENDAT statements. If you want to get the sum then use a counter and increment it .
This is only way you can achieve this.
The SUM command will have effect only in between the LOOP and ENDLOOP statements.
Regards,
Vara
‎2005 Nov 15 11:11 PM
Thanks to all for the information.
I was able to use the slis_sortinfo_alv type and solve my problem.
regards
‎2005 Nov 16 12:09 AM
pl award points to those who helped you & close this thread..
have fun,
Suresh Datti
‎2005 Nov 16 3:25 AM
Hi,
U can do like this also
SORT migo_data BY txjcd dmbtr.
LOOP AT migo_data.
<b> AT END OF txjcd.
SUM.</b>
* migo_data_alv-txjcd = migo_data-txjcd.
migo_data_alv-dmbtr = migo_data-dmbtr.
APPEND migo_data_alv.
CLEAR migo_data_alv.
ENDAT.
ENDLOOP.The above logic will work. I have tried that in a report.
Next way is
DATA: i_sort_fcat TYPE lvc_t_sort,
struct_gridsort TYPE lvc_t_sort WITH HEADER LINE.
FORM sort_outtable CHANGING p_i_sort_fcat.
struct_gridsort-fieldname = 'TXJCD'.
struct_gridsort-up = 'X'.
APPEND struct_gridsort TO i_sort_fcat.
CLEAR struct_gridsort.
struct_gridsort-fieldname = 'DMBTR'.
struct_gridsort-up = 'X'.
struct_gridsort-subtot = 'X'.
APPEND struct_gridsort TO i_sort_fcat.
CLEAR struct_gridsort.
ENDFORM. " sort_outtableHope this helps u.
Kindly reward points and close the thread if ur problem got solved.