‎2008 Jul 04 5:15 PM
Hi,
I have a data in my Itab like this: -
ebeln ebelp Quantity
1000005 10 100
1000005 10 20
1000005 10 80
1000005 20 10
1000005 20 15
1000006 10 240
1000006 20 60
1000006 20 60
I need my output in my Itab like this: -
How could I do it?
ebeln ebelp Quantity
1000005 10 200
1000005 20 25
1000006 10 240
1000006 20 120
Let me know how can this be achieved?
‎2008 Jul 04 5:19 PM
make a second table with keys ebeln and ebelp.
Loop at the first table and use collect statement to add all the entries to the second table and you'll get what you want
‎2008 Jul 04 5:19 PM
make a second table with keys ebeln and ebelp.
Loop at the first table and use collect statement to add all the entries to the second table and you'll get what you want
‎2008 Jul 04 5:21 PM
Hi
U can use a new internal table for output structurated just as ITAB, where u collect the record of ITAB to T_OUTPUT.
LOOP AT ITAB INTO T_OUTPUT.
COLLECT T_OUTPUT.
ENDLOOP.Max
‎2008 Jul 04 5:51 PM
Hi Max,
Could you please tell How it works using SUM key word?
I m doing something like this: -
LOOP AT i_ekbe.
ON CHANGE OF EBELN OR
EBELP.
SUM ( MENGE ).
ENDON.
ENDLOOP.
‎2008 Jul 04 5:22 PM
Hi,
Use control break statement,
AT NEW
SUM,
END AT.Regards
Adil
Edited by: Syed Abdul Adil on Jul 4, 2008 7:04 PM
Edited by: Syed Abdul Adil on Jul 4, 2008 7:12 PM
‎2008 Jul 04 5:57 PM
Hi,
I think the COLLECT statement is the best, very performing too.
Regards
AP
‎2008 Jul 04 6:13 PM
Hi,
Hope this will help you.
DATA:
BEGIN OF w_test,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
quantity TYPE ekpo-MENGE,
END OF w_test,
t_test LIKE TABLE OF w_test.
w_test-ebeln = '1000005'.
w_test-ebelp = '10'.
w_test-quantity = '100'.
APPEND w_test TO t_test.
w_test-ebeln = '1000005'.
w_test-ebelp = '10'.
w_test-quantity = '20'.
APPEND w_test TO t_test.
w_test-ebeln = '1000005'.
w_test-ebelp = '10'.
w_test-quantity = '80'.
APPEND w_test TO t_test.
w_test-ebeln = '1000005'.
w_test-ebelp = '20'.
w_test-quantity = '10'.
APPEND w_test TO t_test.
w_test-ebeln = '1000005'.
w_test-ebelp = '20'.
w_test-quantity = '15'.
APPEND w_test TO t_test.
w_test-ebeln = '1000006'.
w_test-ebelp = '10'.
w_test-quantity = '240'.
APPEND w_test TO t_test.
w_test-ebeln = '1000006'.
w_test-ebelp = '20'.
w_test-quantity = '60'.
APPEND w_test TO t_test.
w_test-ebeln = '1000006'.
w_test-ebelp = '20'.
w_test-quantity = '60'.
APPEND w_test TO t_test.
LOOP AT t_test INTO w_test.
AT NEW ebelp.
SUM.
WRITE:/
w_test-ebeln,
w_test-ebelp,
w_test-quantity.
ENDAT.
ENDLOOP.Regards
Adil