Skip to Content

Data records not being fetched completely

Dear All,

I have got myself stuck with a really strange situation.

The below code is not fully fetching the records which are satisfying the conditions in where clause of the following select query.

SELECT KNUMV

KPOSN

KSCHL

KBETR

KWERT

KINAK

FROM KONV

INTO CORRESPONDING FIELDS OF TABLE IT_KONV

FOR ALL ENTRIES IN IT_VBRK

WHERE KNUMV = IT_VBRK-KNUMV.

The record which it is skipping has the same KNUMV as that in IT_VBRK.

That record has KSCHL value ZF04 and already there is a record with the same KSCHL and it is being fetched.

Kindly help.

Thanks n Reagrds,

Sij.

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

6 Answers

  • Best Answer
    Sep 01, 2011 at 06:53 AM

    Read [FOR ALL ENTRIES WHERE|http://help.sap.com/abapdocu_70/en/ABENWHERE_LOGEXP_ITAB.htm] documentation.

    Duplicate lines are automatically removed from the resulting set.

    So add the full primary key of the database table to the set of fields extracted if you want to check number of records.

    SELECT KNUMV KPOSN KSCHL STUNR
           ZAEHK KBETR KWERT KINAK 
      FROM KONV
      INTO CORRESPONDING FIELDS OF TABLE IT_KONV
      FOR ALL ENTRIES IN IT_VBRK
        WHERE KNUMV = IT_VBRK-KNUMV.

    Regards,

    Raymond

    Add comment
    10|10000 characters needed characters exceeded

    • Hey Suhas,

      Thanks for the link to this interesting topic, it remembered me of some time ago, the first time when i sum an amount after a FAE (i had no choice as data came from BSEG which does not allow JOIN, cause cluster) I took some times to understand why the total amount was "sometimes" different from the expected one..

      We learn from our mistakes and simply celebrate our successes.

      Now, as a rule, I add the whole primary key as soon as i need to count records, or sum any value.

      Regards,

      Raymond

  • avatar image
    Former Member
    Sep 01, 2011 at 08:10 AM

    Hi Sij,

    Even i too faced the same problem when i am developed a sales register report.So i did the same coding as Raymond suggested then it is fetched all the records.Before i did not used this statement INTO CORRESPONDING FIELDS OF TABLE IT_KONV then i got all the records into my internal table with the satisfied condition.I used for all entries that is failed.Then after debug i found that.

    HI Raymond and Suhas,

    Can you give me some idea actually what is the issue. As Suhas suggested i will see the blog. It is helpful to all if we understood the issue.

    INTO CORRESPONDING FIELDS OF TABLE IT_KONV

    FOR ALL ENTRIES IN IT_VBRK

    WHERE KNUMV = IT_VBRK-KNUMV.

    Regards,

    Madhu.

    Add comment
    10|10000 characters needed characters exceeded

    • Dear Madhu Sir,

      The issue is that FAE removes duplicate entries from the set of records fetched having the same primary key field combinations.

      Therefore we need to select all the fields which together makes the PRIMARY KEY combination so that its distinct always and doesn't get deleted by the FAE statement .

      Hope I was able to make you know the issue.

      Problem solved thanks all.

      Thanks n Regards,

      Sij.

  • avatar image
    Former Member
    Sep 01, 2011 at 09:56 AM

    Hi,

    This is because of the limitation of the FOR ALL ENTRIES statement.

    When you are using this statement you need to fetch all the primary key fields alongwith the fields you require.

    I have faced this situation many a times and implementing this solution helped.

    You query should be like this:

    SELECT

    KNUMV

    KPOSN

    STUNR

    ZAEHK

    KSCHL

    KBETR

    KWERT

    KINAK

    FROM KONV

    INTO CORRESPONDING FIELDS OF TABLE IT_KONV

    FOR ALL ENTRIES IN IT_VBRK

    WHERE KNUMV = IT_VBRK-KNUMV.

    This will solve your problem, pls close the thread after that.

    Thanks,

    Manish

    Thanks,

    Manish

    Add comment
    10|10000 characters needed characters exceeded

  • Sep 01, 2011 at 11:24 AM

    Thank you Raymond Sir and all others for your replies . I will do the changes as suggested by you and will revert you soon.

    Yes Madhu Sir , even i am facing this situation in my Daily Sales Register report.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 01, 2011 at 02:24 PM

    hi, when you use the "for all entries in",you must sepcify all the key fields of the table konv.

    thanks.

    Add comment
    10|10000 characters needed characters exceeded

  • Feb 22, 2013 at 11:56 AM

    This was really helpful for me.

    Add comment
    10|10000 characters needed characters exceeded