How to Do a Sort in a Select Statement of ABAP

How to Do a Sort in a Select Statement of ABAP

ABAP (Advanced Business Application Programming) is a computer language for programming the business applications created with SAP software. The ABAP functions resemble COBOL program language statements. The SAP user databases store the ABAP program in the form of a source code or in the binary form, ready to be executed by the SAP Application server. The execution of an ABAP SELECT statement gives users the ability to sort SQL query results. You need to define ORDER BY clause of SQL query in order to sort database records using an ABAP SELECT statement.

Instructions

    1

    Click the "Start" button in Windows and select "SAP Management Console" from the "All Programs" menu to open the SAP management console.

    2

    Type in the following code in the console window:

    DATA: BEGIN OF WA,

    CARRID TYPE SFLIGHT-CARRID,

    CONNID TYPE SFLIGHT-CONNID,

    MIN TYPE I,

    END OF WA.

    SELECT CARRID CONNID MIN( SEATSOCC ) AS MIN

    INTO CORRESPONDING FIELDS OF WA

    FROM SFLIGHT

    GROUP BY CARRID CONNID

    ORDER BY CARRID MIN DESCENDING.

    WRITE: / WA-CARRID, WA-CONNID, WA-MIN.

    ENDSELECT.

    3

    Click "File," "Run" to run ABAP program using the SELECT statement for sorting database records.

Blog Archive