Hi
I have one internal table its structure
BEGIN OF wa_data OCCURS 0,
ename LIKE pa0001-ename, 'Sales Id
mmyyyy(8) TYPE c, " Month Year
bezei LIKE tvaut-bezei, " REason
netwr LIKE vbak-netwr, "Net Value of SO inDoc Currency
pernr TYPE pa0001-pernr, "Sales ID
lcamt LIKE vbak-netwr, "Net Value of SO Local Currency
nos TYPE i,
audat LIKE vbak-audat, "Document date
vkbur LIKE vbak-vkbur,
vkorg LIKE vbak-vkorg,
END OF wa_data.
I needed to make a internal table with sum of amount for each employee for each month for each reason.
emp id Reason monthyear amount
1 aaa JAN09 1100.00
2 aaa JAN09 1200.00
3 aaa JAN09 1400.00
4 BBB JAN09 1300.00
How to get a sum from the a details table. detail table having so many records for each employee for for each reason for each month
Regards
Sebastian JOhn
Request clarification before answering.
Hi ,
You can use the COLLECT statement .
Or you can use the if condition inside the loop of the 1st table and there you can add
and and append in the second table. Following code might help you - -
DATA : t_sflight LIKE TABLE OF sflight,
fs TYPE sflight,
BEGIN OF fs_final,
carrid TYPE spfli-carrid,
price TYPE sflight-price,
END OF fs_final,
t_final LIKE TABLE OF fs_final.
DATA : w_carrid TYPE s_carrid,
w_price TYPE sflight-price.
SELECT * FROM sflight INTO TABLE t_sflight.
SORT t_sflight.
LOOP AT t_sflight INTO fs.
IF fs-carrid EQ w_carrid or sy-tabix eq 1. " IF condition
w_price = fs-price + w_price. " Adding
ELSE.
fs_final-carrid = w_carrid.
fs_final-price = w_price.
APPEND fs_final TO t_final. " Appending to final table
CLEAR w_price.
ENDIF.
w_carrid = fs-carrid.
ENDLOOP.
fs_final-carrid = fs-carrid.
fs_final-price = w_price.
APPEND fs_final TO t_final.
Regards
Pinaki
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 5 | |
| 5 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.