10-30-2007 2:08 PM
Hello everybody,
can somebody tell me how the SORT statement is working? Or show me a chapter in the documentation where its described.
And what is different to SORT stable.
Best regards,
Christian
10-30-2007 2:21 PM
hi
good
You can sort a standard or hashed table in a program. To sort a table by its key, use the statement
SORT <itab> [ASCENDING|DESCENDING] [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.
<b><REMOVED BY MODERATOR></b>
thanks
mrutyun^
Message was edited by:
Alvaro Tejada Galindo
10-30-2007 2:14 PM
Well, if you do not specify STABLE, then when you sort by a particular field, the other fields that you are not sorting by may be in a different order than they were before the sort statement.
Rob
10-30-2007 2:17 PM
10-30-2007 2:21 PM
hi
good
You can sort a standard or hashed table in a program. To sort a table by its key, use the statement
SORT <itab> [ASCENDING|DESCENDING] [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.
<b><REMOVED BY MODERATOR></b>
thanks
mrutyun^
Message was edited by:
Alvaro Tejada Galindo
10-30-2007 2:47 PM
Hi all,
thanks for your reply. One Question is left. What algorithm is used e.g. Bubble Sort or Quick Sort or whatever! Or is that one of walldorf secrets!?
Best regards,
Christian
10-30-2007 2:55 PM
Don't know if it's a secret or not, but if you search for notes related to bubble sort or quicksort, you'll find some information.
Rob