Monday, February 11, 2008

Sort mechanism respecting field type

It is often not enough to sort an internal table by text or binary value
but respecting the field type, e.g. a date field. In this case you have to
create a sort table with the sort fields as seperate rows. This small
example illustrates this:

date otab TYPE abap_sortorder_tab.
date oline TYPE abap_sortorder.

oline-descending = 'X'.
oline-name = 'CREATE_DATE'. APPEND oline to otab.
oline-name = 'CREATE_TIME'. APPEND oline to otab.
oline-name = 'CUSTOMER'. APPEND oline to otab.

SORT table_to_sort BY (otab).

No comments: