‎2014 Jul 22 7:42 AM
Hi all,
I have a requirement in which I am using Collect statement to club the numeric values.
TYPES: BEGIN OF ST_VBBE ,
MATNR TYPE VBBE-MATNR,
WERKS TYPE VBBE-WERKS,
OMENG TYPE VBBE-OMENG,
END OF ST_VBBE.
data : IT_VBBE TYPE TABLE OF ST_VBBE,
WA_VBBE TYPE ST_VBBE,
it_vbbe_f TYPE TABLE OF st_vbbe,
WA_VBBE_F TYPE ST_VBBE.
START-OF-SELECTION.
SELECT MATNR WERKS OMENG
FROM VBBE INTO TABLE IT_VBBE UP TO 500 rows.
BREAK-POINT.
LOOP AT IT_VBBE INTO WA_VBBE.
COLLECT WA_VBBE_f INTO IT_VBBE_f.
ENDLOOP.
This is my code.. But I am not getting a single value in the table in which I am collecting the data.
I am getting the data in IT_VBBE.
‎2014 Jul 22 7:47 AM
Hi
use the following code.
loop at it_vbbe into wa_vbbe.
collect wa_vbbe into it_vbbe_f.
endloop.
you will find the collected data in it_vbbe_f.
Regards
Shaik
‎2014 Jul 22 7:47 AM
Hi,
from where u are getting data into wa_vbbe_f , which you are collecting into it_vbbe_f. Check your Workarea and Table in Collect Statement
‎2014 Jul 22 7:47 AM
Hi
use the following code.
loop at it_vbbe into wa_vbbe.
collect wa_vbbe into it_vbbe_f.
endloop.
you will find the collected data in it_vbbe_f.
Regards
Shaik
‎2014 Jul 22 7:48 AM
Hello Yash
Change the collect statement to COLLECT WA_VBBE INTO IT_VBBE_f.
‎2014 Jul 22 7:49 AM
Hi Yash,
use your coding as
LOOP AT IT_VBBE INTO WA_VBBE.
COLLECT WA_VBBE INTO IT_VBBE_f.
ENDLOOP.
or
LOOP AT IT_VBBE INTO WA_VBBE.
move WA_VBBE to WA_VBBE_f.
COLLECT WA_VBBE_f INTO IT_VBBE_f.
ENDLOOP.
Thanks,
Sooraj Saini
‎2014 Jul 22 7:50 AM
Add the highlighted code.
LOOP AT IT_VBBE INTO WA_VBBE.
MOVE: WA_VBBE TO WA_VBBE_f.
COLLECT WA_VBBE_f INTO IT_VBBE_f.
ENDLOOP.
‎2014 Jul 22 7:50 AM
Hi Yash,
TYPES: BEGIN OF ST_VBBE ,
MATNR TYPE VBBE-MATNR,
WERKS TYPE VBBE-WERKS,
OMENG TYPE VBBE-OMENG,
END OF ST_VBBE.
data : IT_VBBE TYPE TABLE OF ST_VBBE,
WA_VBBE TYPE ST_VBBE,
it_vbbe_f TYPE TABLE OF st_vbbe,
WA_VBBE_F TYPE ST_VBBE.
START-OF-SELECTION.
SELECT MATNR WERKS OMENG
FROM VBBE INTO TABLE IT_VBBE UP TO 500 rows.
LOOP AT IT_VBBE INTO WA_VBBE_f.
COLLECT WA_VBBE_f INTO IT_VBBE_f.
ENDLOOP.
Regards
Ashwin.
‎2014 Jul 22 7:50 AM
You are looping int WA_VBBE, but collecting from WA_VBBE_F? Thats not going to work. Change your collect to "COLLECT WA_VBBE INTO IT_VBBE_F".
‎2014 Jul 22 7:52 AM
As per your code you doing worng,
TYPES: BEGIN OF ST_VBBE ,
MATNR TYPE VBBE-MATNR,
WERKS TYPE VBBE-WERKS,
OMENG TYPE VBBE-OMENG,
END OF ST_VBBE.
data : IT_VBBE TYPE TABLE OF ST_VBBE,
WA_VBBE TYPE ST_VBBE,
it_vbbe_f TYPE TABLE OF st_vbbe,
WA_VBBE_F TYPE ST_VBBE.
START-OF-SELECTION.
SELECT MATNR WERKS OMENG
FROM VBBE INTO TABLE IT_VBBE UP TO 500 rows.
BREAK-POINT.
LOOP AT IT_VBBE INTO WA_VBBE.
COLLECT WA_VBBE_f INTO IT_VBBE_f. " wrong here you taking data in WA_VBBE, so need to pass in WA_VBBE_F and then collect.
ENDLOOP.
"Refer this code
TYPES: BEGIN OF ST_VBBE ,
MATNR TYPE VBBE-MATNR,
WERKS TYPE VBBE-WERKS,
OMENG TYPE VBBE-OMENG,
END OF ST_VBBE.
data : IT_VBBE TYPE TABLE OF ST_VBBE,
WA_VBBE TYPE ST_VBBE,
it_vbbe_f TYPE TABLE OF st_vbbe,
WA_VBBE_F TYPE ST_VBBE.
START-OF-SELECTION.
SELECT MATNR WERKS OMENG
FROM VBBE INTO TABLE IT_VBBE UP TO 500 rows.
BREAK-POINT.
LOOP AT IT_VBBE INTO WA_VBBE.
WA_VBBE_f = WA_VBBE.
COLLECT WA_VBBE_f INTO IT_VBBE_f.
ENDLOOP.
Regards,
Sandeep
‎2014 Jul 22 7:52 AM
Hello ,
Try the below code. Only chnage required is the collect statement will use the same looping table. Inorder to see the other entries in your it_vbbe_f table you need to use append statement also as well.
TYPES: BEGIN OF ST_VBBE ,
MATNR TYPE VBBE-MATNR,
WERKS TYPE VBBE-WERKS,
OMENG TYPE VBBE-OMENG,
END OF ST_VBBE.
data : IT_VBBE TYPE TABLE OF ST_VBBE,
WA_VBBE TYPE ST_VBBE.
START-OF-SELECTION.
SELECT MATNR WERKS OMENGE
FROM VBBE INTO TABLE IT_VBBE.
LOOP AT IT_VBBE INTO WA_VBBE.
COLLECT WA_VBBE INTO IT_VBBE.
ENDLOOP.
COLLECT allows you to create unique or summarized datasets.
The system first tries to find a table entry corresponding to
the table key (see Key definition for internal tables). The
key values are taken either from the header line of the
internal table itab, or from the explicitly-specified work
area wa. itab must have a flat structure, that is, it may not
contain other internal tables. All components that are not
part of the key must be have numeric types (see ABAP numeric
types).
If the system finds an entry, the numeric fields that are not
part of the table key (see ABAP number types) are added to the
sum total of the existing entries. If it does not find an
entry, the system creates a new entry instead.
The way in which the system finds the entries depends on the
type of the internal table:
Thanks,
SK
‎2014 Jul 22 10:28 AM
Siva,
WA_VBBE_f doesn't have any values. You can check the following loop:
LOOP AT IT_VBBE INTO WA_VBBE.
wa_vbbe_f-matnr = wa_vbbe-matnr.
wa_vbbe_f-werks = wa_vbbe-werks.
wa_vbbe_f-omeng = wa_vbbe-omeng.
COLLECT WA_VBBE_f INTO IT_VBBE_f.
ENDLOOP.
Regards
Purnand
‎2014 Jul 31 3:46 PM
Is your issue resolved? Did any of the replies help or answer your question? Please mark accordingly and close.
‎2014 Aug 01 6:41 AM
hi, yash you have made a slight mistake in my sense, which is why you are unable to get the data through collect statemant.
Here is the recorrect code, kindly like if you are satisfied.
TYPES: BEGIN OF ST_VBBE ,
MATNR TYPE VBBE-MATNR,
WERKS TYPE VBBE-WERKS,
OMENG TYPE VBBE-OMENG,
END OF ST_VBBE.
data : IT_VBBE TYPE TABLE OF ST_VBBE,
WA_VBBE TYPE ST_VBBE,
it_vbbe_f TYPE TABLE OF st_vbbe,
WA_VBBE_F TYPE ST_VBBE.
START-OF-SELECTION.
SELECT MATNR WERKS OMENG
FROM VBBE INTO TABLE IT_VBBE UP TO 500 rows.
BREAK-POINT.
LOOP AT IT_VBBE INTO WA_VBBE.
COLLECT WA_VBBE INTO IT_VBBE_f.
ENDLOOP.
i hope this solves your query.
thanks.