Tuesday, May 12, 2026

Example of Sort in Table

 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 LENGTH 1,
    col2 TYPE i,
  END OF line.

DATA itab TYPE STANDARD TABLE OF line WITH EMPTY KEY.

itab VALUE #col1 'A' col2 )
                col1 'B' col2 )
                col1 'B' col2 )
                col1 'C' col2 )
                col1 'C' col2 )
                col1 'B' col2 )
                col1 'A' col2 )
                col1 'A' col2 )
                col1 'C' col2 ).

SORT itab BY col1 ASCENDING col2 DESCENDING.

cl_demo_output=>displayitab ).

The output is like:



No comments:

Post a Comment

Search SAPMV45A includes for Constants and Statics

 This report can find CONSTANTS and STATICS in SAPMV45A Z-includes. We know that Constants and Statics consume global variables so identifyi...