Quantcast
Channel: SCN : Blog List - ABAP Development
Viewing all articles
Browse latest Browse all 943

Using subqueries in ABAP

$
0
0

Here i'm gonna show on performance of using the sub quereis in program instead of two select statements..

 

For EX: Using the two select statements ...

 

SELECT * FROM SPFLI

  INTO TABLE T_SPFLI

  WHERE CITYFROM = 'FRANKFURT'

    AND CITYTO = 'NEW YORK'.

SELECT * FROM SFLIGHT AS F

    INTO SFLIGHT_WA

    FOR ALL ENTRIES IN T_SPFLI

    WHERE SEATSOCC < F~SEATSMAX

      AND CARRID = T_SPFLI-CARRID

      AND CONNID = T_SPFLI-CONNID

      AND FLDATE BETWEEN '19990101' AND '19990331'.

ENDSELECT.

 

 

For EX: the above two select statements can be replaced by  the sub queries

 

SELECT * FROM SFLIGHT AS F INTO SFLIGHT_WA

    WHERE SEATSOCC < F~SEATSMAX

      AND EXISTS ( SELECT * FROM SPFLI

                     WHERE CARRID = F~CARRID

                       AND CONNID = F~CONNID

                       AND CITYFROM = 'FRANKFURT'

                       AND CITYTO = 'NEW YORK' )

      AND FLDATE BETWEEN '19990101' AND '19990331'.

ENDSELECT.

 

And performance wise also sub queries is far better.


Viewing all articles
Browse latest Browse all 943

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>