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: 

Problem in FOR ALL ENTRIES IN statement

Former Member
0 Kudos

Hi Abaper,

I have a problem in FOR ALL ENTRIES IN statement.

I have a table /ccsht/na_estadi in this table for the particulat date there are 14 records, but my internal table read only 5 record.

Below is my code:

SELECT sociedad

xhotel_id

FROM /ccsht/mt_photel

INTO TABLE it_comp_hotel

WHERE sociedad IN p_comp

AND xhotel_id IN p_hotid.

BREAK-POINT.

SORT it_comp_hotel BY sociedad.

SELECT xhotel_id

xfecha_id

xocupacion

tot_habs_hotel

xnum_pax1

FROM /ccsht/na_estadi

INTO TABLE it_estadi "CORRESPONDING FIELDS OF TABLE it_estadi

FOR ALL ENTRIES IN it_comp_hotel

WHERE xhotel_id EQ it_comp_hotel-xhotel_id

AND xfecha_id IN p_date.

Can any one help me this issue.

Thanks in advance.

Thanks & Regards,

Amit

7 REPLIES 7

former_member181995
Active Contributor
0 Kudos

Most possible reason may be :

With duplicated rows in the resulting set, the addition FOR ALL ENTRIES has the same effect as if addition DISTINCT were specified in the definition of the selection quantity. Unlike DISTINCT, the rows are not deleted from the database system but are deleted on the application server from the resulting set.

This information is from F1 help of FOR ALL ENTRIES.

Cheers,

Amit.

Former Member
0 Kudos

Hello,

goto tcode abapdocu and give For all entries u read that....u will knowing ..

Thank u,

santhosh

former_member222860
Active Contributor
0 Kudos

Hi,

Ur checking for two conditions in ur where_cluase.

Are u sure that, 14 records are existing for the particular hotel_id on the p_date.

WHERE xhotel_id EQ it_comp_hotel-xhotel_id
AND xfecha_id IN p_date.

Pl. check the above

thanks\

Mahesh

Former Member
0 Kudos

Hi Amit,

The records fetched by your second select into internal table it_estadi

are restricted by the data fetched into internal table it_comp_hotel based on the for all entries clause.

So rather than getting all the records, you are getting the records for which there is a match for xhotel_id.

Also try to use sy-subrc check before using "for all entries".

Let me know if it solves your problem.

Regards

Former Member
0 Kudos

Hi Amit,

Try below

SELECT sociedad
xhotel_id
FROM /ccsht/mt_photel
INTO TABLE it_comp_hotel
WHERE sociedad IN p_comp
AND xhotel_id IN p_hotid.

BREAK-POINT.

* SORT it_comp_hotel BY sociedad.  "Remove this SORT statement.

SELECT xhotel_id
xfecha_id
xocupacion
tot_habs_hotel
xnum_pax1
FROM /ccsht/na_estadi
INTO TABLE it_estadi 
FOR ALL ENTRIES IN it_comp_hotel
WHERE xhotel_id EQ it_comp_hotel-xhotel_id
AND xfecha_id IN p_date.

Note: 1) i didn't find the these tables in my SAP system

2) If your table is still not fetching the data, tell me is it the Cluster table,. if yes,.. you need to

maintain the all the primary keys other wise you wont get the data in internal able.

hope this will help you out.

Regards!

Former Member
0 Kudos

Before using FOR ALL ENTRIES you should check the table 'it_comp_hotel[] is not initial.

You debug your code and check the data in it_comp_hotel & it_estadi tables.

Regards,

Joan

Former Member
0 Kudos

Use the statement for all entries on the basis of key field.

e.g.

select field1 field2 from mara

into itab2

for all entries of itab1

where keyfield of itab2 = keyfield of itab1.