09-01-2011 6:24 AM
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.
09-01-2011 7: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
09-01-2011 7: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
09-01-2011 8:59 AM
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
09-01-2011 10:14 AM
Dear Suhas,
Thanks for the Blog reference & interesting comments !!.
Regards, Vinod
09-01-2011 1:12 PM
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
09-01-2011 9: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.
09-01-2011 12:59 PM
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.
09-01-2011 10: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
09-01-2011 12:24 PM
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.
09-01-2011 3:24 PM
hi, when you use the "for all entries in",you must sepcify all the key fields of the table konv.
thanks.
02-22-2013 11:56 AM