This is example of a sort using both ascending and descending order in the same table.
REPORT ZGB_SORT.
TYPES:
BEGIN OF line,
col1 TYPE c LENGTH 1,
col2 TYPE i,
END OF line.
DATA itab TYPE STANDARD TABLE OF line WITH EMPTY KEY.
itab = VALUE #( ( col1 = 'A' col2 = 6 )
( col1 = 'B' col2 = 4 )
( col1 = 'B' col2 = 7 )
( col1 = 'C' col2 = 1 )
( col1 = 'C' col2 = 3 )
( col1 = 'B' col2 = 9 )
( col1 = 'A' col2 = 2 )
( col1 = 'A' col2 = 5 )
( col1 = 'C' col2 = 8 ) ).
SORT itab BY col1 ASCENDING col2 DESCENDING.
cl_demo_output=>display( itab ).
The output is like:
No comments:
Post a Comment