Skip to Content
0

Collect st used with For all entries - Giving incorrect results

Oct 23, 2016 at 11:22 PM

94

avatar image
Former Member

lt_mat is sorted table with Matnr as unique Key.

Using Collect st as below with For all entries itab

SELECT matnr labst FROM mard
INTO wa_mat
FOR ALL ENTRIES IN lt_sub
WHERE matnr EQ lt_sub-submt.

COLLECT wa_mat INTO lt_mat.

ENDSELECT.

There are 6 entries in MARD for the material 1000344, but it is fetching only 3 values from them and adding it together....

However if you the same statement without For all entries - using hard coding it is properly fetching all the 6 values...

SELECT matnr labst FROM mard
INTO wa_mat
* FOR ALL ENTRIES IN pt_sub "Commented
WHERE matnr EQ '00000000001000344'.

COLLECT wa_mat INTO lt_mat.
ENDSELECT.

The values in MARD for LABST are as follows - The last 3 values of 100 is missed out every time....

100.000

1,101.000

43.000

100.000

100.000

100.000

Is the value 100 repeated at 1, 4, 5 and 6 - and is that the reasons it is fetched at position 1 and omitted at other places???

I even tried with having only entry in for all entries tab and still the same results...Please clarify...

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
avatar image
Former Member Oct 24, 2016 at 12:53 AM
0

Hi Ganu: Please try it:

wa_mat must contains the key field of table mard,

1. wa_mat structure add two field: lgort, werks,

2. Sql syntax change to:

SELECT matnr werks lgort labst FROM mard
INTO wa_mat
..........

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Oct 24, 2016 at 02:33 AM
0

thanks ...yes once i include all the key fields from the table, even with for all entries it working..thanks

Share
10 |10000 characters needed characters left characters exceeded