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: 

Data records not being fetched completely

Sijin_Chandran
Active Contributor
0 Kudos

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.

1 ACCEPTED SOLUTION

raymond_giuseppi
Active Contributor
0 Kudos

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

10 REPLIES 10

raymond_giuseppi
Active Contributor
0 Kudos

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

0 Kudos

Hello Raymond,

A few weeks back i had an interesting discussion with Lars in this blog [/people/lars.breddemann/blog/2011/08/13/sap-support-case-for-all-entries-disaster]. Was an eye opener for me!

Hope you'll like it too

Cheers,

Suhas

0 Kudos

Dear Suhas,

Thanks for the Blog reference & interesting comments !!.

Regards, Vinod

0 Kudos

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

madhu_vadlamani
Active Contributor
0 Kudos

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.

0 Kudos

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.

Former Member
0 Kudos

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

Sijin_Chandran
Active Contributor
0 Kudos

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.

Former Member
0 Kudos

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

thanks.

Former Member
0 Kudos

This was really helpful for me.