‎2009 Apr 14 10:44 AM
hi ,
i need to add the DMBTR based on ZUONR(Assignment field).
Suppose i have the values as
BELNR ZUONR DMBTR
1001 KP2345 200
1001 KP2345 300
1001 KP2345 100
1001 MT9872 500
1001 MT9872 400
the output should be as
BELNR ZUONR DMBTR
1001 KP2345 600
1001 MT9872 900
Based on BELNR and ZUONR the values of DMBTR should be added .
from above the ZUONR = KP2345 Whereas DBMTR should be added of the same ZUONR
200 + 300 + 100 = 600 SHOULD display as one line item in the output.
please see my code below
DATA: BEGIN OF GT_BSEG ,
BUKRS LIKE BSEG-BUKRS, "company code
BELNR LIKE BSEG-BELNR, "Document number
GJAHR LIKE BSEG-GJAHR, "Fiscal year
DMBTR LIKE BSEG-DMBTR, "Amount in local currency
WRBTR LIKE BSEG-WRBTR, "Amount in document currency
PSWSL LIKE BSEG-PSWSL,
ZUONR LIKE BSEG-ZUONR,
HKONT LIKE BSEG-HKONT, "General ledger account
END OF GT_BSEG.
DATA: BEGIN OF gt_output ,
zuonr LIKE bseg-zuonr,
dmbtr LIKE bseg-dmbtr,
END OF gt_output.
LOOP AT gt_bseg.
AT END OF zuonr.
gt_output-zuonr = gt_bseg-zuonr.
SUM.
gt_output-dmbtr = gt_bseg-dmbtr.
APPEND gt_output.
CLEAR gt_output.
ENDAT.
ENDLOOP.
i got all the data to gt_bseg internal table.
please help .
‎2009 Apr 14 10:46 AM
you can use COLLECT here!!!
it will some up all the values perfectly
regards
bhanu
‎2009 Apr 14 10:48 AM
use
LOOP AT gt_bseg.
collect gt_bseg into gt_output.
ENDLOOP.
Thanks
Amitava
‎2009 Apr 14 10:49 AM
Hello,
As suggested COLLECT is the best solution:
LOOP AT gt_bseg.
gt_output-zuonr = gt_bseg-zuonr.
gt_output-dmbtr = gt_bseg-dmbtr.
COLLECT gt_output.
CLEAR gt_output.
ENDLOOP.Hope this helps !!
BR,
Suhas
‎2009 Apr 14 10:52 AM
Dear ,
Its very simple goto se11 in the domain of your field
Goto output characteristices --- > Convers. routine and one routine .
Then goto se37 write one routine and attach it there .
In this routine do th processing wht all you want .
Rgds ankit
‎2009 Apr 14 10:53 AM
And if you want this in code then wht its written above posts tht using COLLECT is best way .
‎2009 Apr 14 6:45 PM
Hi!
Maybe the results is incorrect because the field ZUONR have to be index, check out your internal table and keep in ZUONR be the firts field declaraded.
I hope this helps,
Regards!
‎2009 Apr 14 6:52 PM
Write the select query as follows---
select BELNR ZUONR sum( DMBTR ) from bseg where ZUONR = ---.
hope this will solve ur problem.
‎2009 Apr 14 7:26 PM
This is incorrect because BSEG only captures positive amounts. You have to take the debit/credit indicator - BSEG-SHKZG into account when adding these amounts.
Rob