‎2007 Aug 07 8:54 AM
can any one explain before using for all entries if not itab[] is initial .what is the use of if not condition
thanks
venki
‎2007 Aug 07 8:56 AM
If the table is initial,then it will select all the entries from the db table.So it is necessary to check if it is not initial before using in select for all entries.
‎2007 Aug 07 8:56 AM
If the table is initial,then it will select all the entries from the db table.So it is necessary to check if it is not initial before using in select for all entries.
‎2007 Aug 07 9:01 AM
if value is not initial.
waest to select for enties
Use of FOR ALL Entries
Outer join can be created using this addition to the where clause in a select statement. It speeds up the performance tremendously, but the cons of using this variation are listed below
Duplicates are automatically removed from the resulting data set. Hence care should be taken that the unique key of the detail line items should be given in the select statement.
If the table on which the For All Entries IN clause is based is empty, all rows are selected into the destination table. Hence it is advisable to check before-hand that the first table is not empty.
If the table on which the For All Entries IN clause is based is very large, the performance will go down instead of improving. Hence attempt should be made to keep the table size to a moderate level.
Not Recommended
Loop at int_cntry.
Select single * from zfligh into int_fligh
where cntry = int_cntry-cntry.
Append int_fligh.
Endloop.
Recommended
Select * from zfligh appending table int_fligh
For all entries in int_cntry
Where cntry = int_cntry-cntry.
‎2007 Aug 07 9:01 AM
HI,
'If not' is simply a way of checking that the internal table on which 'for all enteries' clause is going to be applied is not empty. 'If not itab[] is initial' means procedd only if the internal table itab is not empty. The reason behind this is that if the internal table is empty and this check is not made then all enteries from the database will be retrieved which will not be wise from performance point of view.
‎2007 Aug 07 9:01 AM
HI,
see this
SELECT ... FOR ALL ENTRIES IN <itab> WHERE <cond> ...
<cond> may be formulated as described above. 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 internal table <itab> must have a structured line type, and each field that occurs in the condition <cond> must be compatible with the column of the database with which it is compared. Do not use the operators LIKE, BETWEEN, and IN in comparisons using internal table fields. You may not use the ORDER BY clause in the same SELECT statement.
You can use the option FOR ALL ENTRIES to replace nested select loops by operations on internal tables. This can significantly improve the performance for large sets of selected data.
rgds,
bharat.
‎2007 Aug 07 9:07 AM
Hi venki,
For good performance of the report we check like that.
Consider the below scenario:
*Select Header data
select *
from some database table1
into itab1
where some condions.
*Select Item data
select *
from some database table2
into itab2
where record contains records in itab1.
If the no header data is selected in itab1,and suppose there are lacks of records in the database table2 then unnecessarily that many times you will process the select.
But if you ckeck itself before 2nd select query,it will be minimized.
Thats why you have to put for all entries check when the scenario like above comes.
Hope this helps you.
Regards,
Rama.Pammi