Skip to Content

Collect st used with For all entries - Giving incorrect results

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

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Best Answer
    Posted on Oct 24, 2016 at 12:53 AM

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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Oct 24, 2016 at 02:33 AM

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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.