SAP VIRTUAL SORT FLIGHTS ABEXA



Get Example source ABAP code based on a different SAP table
  



ABAP_ITAB - Virtual Sort of Flight Data
This example demonstrates the virtual sorting of an internal table containing flight data.

ABAP_SOURCE_CODE
DEMO CL_DEMO_VIRTUAL_SORT_FLIGHTS

ABAP_DESCRIPTION
In this example, an internal table flight_tab containing flight data is sorted virtually by the longitudes and latitudes of the departure and arrival cities. To do this, two additional tables from_city_tab and to_city_tab are constructed. The lines of these tables contain the longitudes and latitudes of the departure and arrival cities from the respective lines of flight_tab.
Virtual sorting with the method VIRTUAL_SORT of class CL_ABAP_ITAB_UTILITIES takes place at the operand position of a FOR expression for a table iteration. The virtual sorting involves all three internal tables. The temporary result of the sorting is used to construct a sorted internal table from the lines of flight_tab. This table is only temporary, and is an input parameter of the method WRITE of class CL_DEMO_OUTPUT.
It is sorted once in ascending order and once in descending order. This does not change the order of the lines in the internal tables that are involved. These remain in their original unsorted state. Virtual sorting makes it possible to generate various sorted output data without affecting the original data.