2009 Feb 26 7:04 AM
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
2009 Feb 26 7:13 AM
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.
2009 Feb 26 7:16 AM
Hello,
goto tcode abapdocu and give For all entries u read that....u will knowing ..
Thank u,
santhosh
2009 Feb 26 7:19 AM
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
2009 Feb 26 7:20 AM
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
2009 Feb 26 7:20 AM
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!
2009 Feb 26 7:26 AM
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
2009 Feb 26 9:57 AM
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.