01-30-2008 9:21 AM
hi
tell me why we use sort statement in itab and how it work.
what is binary search it is compulsory to link with key exp.
what is ment by select up to 5 rows
and select single * from .
plz tell me clearly.
01-30-2008 9:25 AM
select single -- select only one record
select upto 5 rows -- selects 5 records
01-30-2008 9:25 AM
select single -- select only one record
select upto 5 rows -- selects 5 records
01-30-2008 9:29 AM
Hi,
SORT statement is used to sort the internal table data based on some fileds of the table's line type.
BINARY SEARCH works only on a sorted internal table. So generally you will see code where SORT is done first and then READ TABLE along with BINARY SEARCH.
SELECT UPTO 5 rows will fetch the first 5 rows from the database even though there are more records to be returned or that match the where clause.
SELECT SINGLE is always one record and you should use primary key fileds in the WHERE clause to get the correct record.
Regards,
Sesh
01-30-2008 9:31 AM
Hi,
select * will be translated by database interface into a fieldlist of all fields of the databse table fetched from. It is the easiest for coding and does not need any change when database structure changes. But it is quite time and space-consuming because always many non-necessary fields are retrieved and transported.
The destination area may be a work area or an internal table; for table you need addition INTO TABLE.
Use select up to 1 rows if you can not specify the full primary key in WHERE condition but want only one record.
You can sort a standard or hashed table in a program. To sort a table by its key, use the statement
SORT <itab> ASCENDING AS TEXT STABLE.
The statement sorts the internal table <itab> in ascending order by its key. The statement always applies to the table itself, not to the header line. The sort order depends on the sequence of the standard key fields in the internal table. The default key is made up of the non-numeric fields of the table line in the order in which they occur.
You can specify the direction of the sort using the additions ASCENDING and DESCENDING. The default is ascending.
The larger the sort key, the more time the system needs to sort the table. If the sort key contains an internal table, the sorting process may be slowed down considerably.
You cannot sort a sorted table using the SORT statement. The system always maintains these tables automatically by their sort order. If an internal table is statically recognizable as a sorted table, the SORT statement causes a syntax error. If the table is a generic sorted table, the SORT statement causes a runtime error if the sort key is not the same as an extract of the beginning of the table key, you sort in descending order, or use the AS TEXT addition. In other words, the SORT statement is only allowed for generic internal tables, if it does not violate the internal sort order.
The number of sort fields is restricted to 250.
The sorting process is not stable, i.e. if no sort is performed for a predefined sequence of fields, the sequence is not retained.
To delete all duplicate entries from a sorted internal table, you can specify DELETE ADJACENT DUPLICATES FROM itab after SORT .
The sort itself uses the Quicksort process where the key fields for all the data records are retrieved and placed in an area of main memory.
If there is not enough space in memory, the key fields are written to a temporary file and sorted by an external sort program. You can modify the directory which the SORT uses to store such auxiliary files by modifying the SAP profile parameter DIR_SORTTMP . Normally, auxiliary files are created in the SAP data directory (SAP profile parameter DIR_DATA ).
Regards,
Priyanka.
01-30-2008 9:37 AM
tell me why we use sort statement in itab and how it work.
it is useful to sort the rows of an ITAB
it sorts eithrt ascending or descending order
what is binary search it is compulsory to link with key exp.
Binary search is useful to search for some data in the ITAB rows. it is not compusary. if u use this in search it improves the performance. if u use bin search, before u must sort the ITAB
what is ment by select up to 5 rows
it selects the specified no of rows from the database
select single * from .
if u * , it fetches all the fields from the database
award points if useful
Narendra