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: 

Unpredictable behavior u201CFOR ALL ENTRIES INu201D for table AFRU

Former Member
0 Kudos
150

In AFRU table there are 8 Rows

AUFPL APLZL ISMNW BUDAT STZHL

1647 1 95 27.02.2009 0

1647 1 95 27.02.2009 1

1647 1 95 27.02.2009 0

1647 1 95 27.02.2009 3

1647 1 95 27.02.2009 0

1647 1 95 27.02.2009 5

1647 1 95 27.02.2009 0

1647 1 155 12.03.2009 0

Using below Statement I am able to fetch only 5 rows. Select for all entries statement is not picking

Up other 3 rows.

SELECT aufpl aplzl ismnw budat stzhl FROM afru

INTO TABLE gt_afru

FOR ALL ENTRIES IN gt_afvc

WHERE aufpl = gt_afvc-aufpl

And aplzl = gt_afvc-aplzl.

Five Rows Selected

AUFPL APLZL ISMNW BUDAT STZHL

1647 1 95 27.02.2009 0

1647 1 95 27.02.2009 1

1647 1 95 27.02.2009 3

1647 1 95 27.02.2009 5

1647 1 155 12.03.2009 0

When I comment u201CFor all Entriesu201D and use statement like below, it s picking up all the 8 rows.

SELECT aufpl aplzl ismnw budat stzhl FROM afru

INTO TABLE gt_afru

WHERE aufpl = '0000001647'

AND aplzl = '00000001'.

Please Help me understand why it s behaving like this. What is the technicality behind?

1 ACCEPTED SOLUTION

Former Member
0 Kudos
107

Hi,

1647 1 95 27.02.2009 0

1647 1 95 27.02.2009 1

1647 1 95 27.02.2009 0

1647 1 95 27.02.2009 3

1647 1 95 27.02.2009 0

1647 1 95 27.02.2009 5

1647 1 95 27.02.2009 0

1647 1 155 12.03.2009 0

The Entries in Green color are same so FOR ALL ENTRIES will fetch only one entry out of four eliminating the duplicate entries. If you want all the entries then you need to add one more field in the select statemant from AFRU table which makes the entires different.

5 REPLIES 5

Former Member
0 Kudos
108

Hi,

1647 1 95 27.02.2009 0

1647 1 95 27.02.2009 1

1647 1 95 27.02.2009 0

1647 1 95 27.02.2009 3

1647 1 95 27.02.2009 0

1647 1 95 27.02.2009 5

1647 1 95 27.02.2009 0

1647 1 155 12.03.2009 0

The Entries in Green color are same so FOR ALL ENTRIES will fetch only one entry out of four eliminating the duplicate entries. If you want all the entries then you need to add one more field in the select statemant from AFRU table which makes the entires different.

Former Member
0 Kudos
107

Hi Vishal,

In your FOR ALL ENTRIES addition is fetching only 5 entries from the 8 entries because, FOR ALL ENTRIES addition automatically eliminates the duplicate entries from fetching. So, when you are using the for all entries addition select query does not fetch the duplicate entries.

Check the below link for FOR ALL ENTRIES documentation:

[http://help.sap.com/saphelp_47x200/helpdata/en/d3/2e974d35c511d1829f0000e829fbfe/frameset.htm]

Thanks

Sankar

Former Member
0 Kudos
107

SELECT ... FOR ALL ENTRIES IN <itab> or WHERE <cond> ...

If you specify a field of the internal table <itab> as an operand in a condition, you address all lines of the internal table. The comparison is then performed for each line of the internal table. For each line, the system selects the lines from the database table that satisfy the condition. The result set of the SELECT statement is the union of the individual selections for each line of the internal table. Duplicate lines are automatically eliminated from the result set. If <itab> is empty, the addition FOR ALL ENTRIES is disregarded, and all entries are read.

the bold italic part of the above post is the reason for having 5 rows instead of 8 rows.When "For all entries " statement encountered the union selection occurred.And that is why you get only 5 rows.For further help on "For all entries" go through this documentation.[For all Entries|http://help.sap.com/abapdocu/en/ABENWHERE_LOGEXP_ITAB.htm]

Thanking you,

Pulak

Edited by: Pulak Mandal on Mar 16, 2009 3:29 PM

Former Member
0 Kudos
107

Please select field RUECK and RMZHL along with your required fields to get all the records you wanted. FOR ALL ENTRIES removes duplicate records.

Regards

Sunil

Former Member
0 Kudos
107

Hi Vishal,

I too faced this problem long before for some other table..

u need to select RUECK and RMZHL from AFRU to get the missing records.

Guru

Edited by: Guru Ram on Mar 18, 2009 5:43 AM