SAP Tutorials Blog


 


WITH

+connections AS (

  SELECT zdemo_abap_flsch~carrid, carrname, connid, cityfrom, cityto

    FROM zdemo_abap_flsch

    INNER JOIN zdemo_abap_carr

    ON zdemo_abap_carr~carrid = zdemo_abap_flsch~carrid

    WHERE zdemo_abap_flsch~carrid BETWEEN 'AA' AND 'JL' ),

+sum_seats AS (

  SELECT carrid, connid, SUM( seatsocc ) AS sum_seats

    FROM zdemo_abap_fli

    WHERE carrid BETWEEN 'AA' AND 'JL'

    GROUP BY carrid, connid ),

+result( name, connection, departure, arrival, occupied ) AS (

  SELECT carrname, c~connid, cityfrom, cityto, sum_seats

    FROM +connections AS c

    INNER JOIN +sum_seats AS s

    ON c~carrid = s~carrid AND c~connid = s~connid )

SELECT *

  FROM +result

  ORDER BY name, connection

  INTO TABLE @DATA(result).


Serkan AKKAVAK

Computer Engineer BSc

SAP Department Manager

Contact : serkurumsal@yandex.com