05-23-2006 6:25 AM
Hello experts,
I am using FOR ALL ENTRIES in my select statement. Now, how can I check if the field that I am comparing to has
any records? So if does not have any, it would not do my select. Below is my select statement. Again, thank you guys and have a nice day!
SELECT equnr anlnr shtxt FROM itob
INTO TABLE it_itob2
FOR ALL ENTRIES IN it_equz
WHERE equnr = it_equz-hequi.
**I need to know if it_equz-hequi has any records so if it does, it will do the select statement above else, don't.
05-23-2006 6:28 AM
Hi,
Usually the field the WHERE clause will be a primary key and cannot have a null value. In case you are expecint a null value, then it is going to fetch the records that satisfy the condition.
I don't think you can restrict the select to fire only if the field has a value. Else you will have to for a SELECT inside the loop.
However, you will have to check if the table has any entries before firing the SELECT for ALL ENTRIES.
Regards,
Ravi
05-23-2006 6:30 AM
Check for NULL value of a field and use in WHERE clause as Primary Key and check for precondition
Regards
Prabhu
05-23-2006 6:29 AM
<b>if not it_equz[] is initial.
SELECT equnr anlnr shtxt FROM itob
INTO TABLE it_itob2
FOR ALL ENTRIES IN it_equz
WHERE equnr = it_equz-hequi.
endif.</b>
05-23-2006 6:35 AM
HI,
Before going to use for all entries in select statement we should sort our internal table which is using in for all entries of that select statement based on which fields that we used in WHERE condition.Then delete duplicate entries from that itab.Do like this
if not i_equz is initial.
sort i_equz by hequi.
delete adjacent duplicates from i_equz comparing all.
select....
endif.
Note:But in your case this ITOB is an view please check whether this option(FOR ALL ENTRIES) available for views or only for database tables.
Cheers,
Bujji.
05-23-2006 6:38 AM
hi
before passing it in for all entries ....why dont u delete the irrelevant record from the internal table...and then check if not it_equz[]is intial.
and write the select query..
reward point if it helps
gunjan
05-23-2006 6:37 AM
Hai
if not it_equz[] is initial.
SELECT equnr anlnr shtxt FROM itob
INTO TABLE it_itob2
FOR ALL ENTRIES IN it_equz
WHERE equnr = it_equz-hequi.
endif.
For all entries
The for all entries creates a where clause, where all the entries in the driver table are combined with OR. If the number of entries in the driver table is larger than rsdb/max_blocking_factor, several similar SQL statements are executed to limit the length of the WHERE clause.
The plus
Large amount of data
Mixing processing and reading of data
Fast internal reprocessing of data
Fast
The Minus
Difficult to program/understand
Memory could be critical (use FREE or PACKAGE size)
Some steps that might make FOR ALL ENTRIES more efficient:
Removing duplicates from the driver table
Sorting the driver table
If possible, convert the data in the driver table to ranges so a BETWEEN statement is used instead of and OR statement:
FOR ALL ENTRIES IN i_tab
WHERE mykey >= i_tab-low and
mykey <= i_tab-high.
Thanks & regards
Sreenivasulu P