Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Collect st used with For all entries - Giving incorrect results

ganu_k
Participant
0 Kudos

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...

1 ACCEPTED SOLUTION

0 Kudos

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
..........

2 REPLIES 2

0 Kudos

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
..........

ganu_k
Participant
0 Kudos

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