SELECT statements. For example, a WHERE condition for a column
in a database table applies to precisely the results set of this table.
Inner joins between two individual database tables are commutative.
If the same column name appears in multiple database tables of a
single join expression, these tables must be identified in all other
additions of the SELECT statement using the
column selector ~ .
Since join expressions are not subject to
SAP buffering , they should not be used
on buffered tables. Instead it may be a good idea to use the addition
FOR ALL ENTRIES in these cases,
which can access the table buffer.
It is strongly recommended that join conditions are used only between
database columns with the same type and length.
Example ABAP Coding Join of the columns carrname , connid , and
fldate of the database tables scarr , spfli , and
sflight using two inner joins. This creates a list of flights
from p_cityfr to p_cityto . An alias name is assigned to
each table.
PARAMETERS: p_cityfr TYPE spfli-cityfrom,
p_cityto TYPE spfli-cityto.
TYPES: BEGIN OF wa,
fldate TYPE sflight-fldate,
carrname TYPE scarr-carrname,
connid TYPE spfli-connid,
END OF wa.
DATA itab TYPE SORTED TABLE OF wa
WITH UNIQUE KEY fldate carrname connid.
SELECT c~carrname p~connid f~fldate
INTO CORRESPONDING FIELDS OF TABLE itab
FROM ( ( scarr AS c
INNER JOIN spfli AS p ON p~carrid = c~carrid
AND p~cityfrom = p_cityfr
AND p~cityto = p_cityto )
INNER JOIN sflight AS f ON f~carrid = p~carrid
AND f~connid = p~connid ).
cl_demo_output=>display( itab ).
Example ABAP Coding Join of the columns carrid , carrname , and
connid of the database tables scarr and spfli using
an outer join. For all flights that do not depart from p_cityfr ,
the column connid is set to the null value that was transformed
to the initial value for its type (when
passed to the associated data object). All the airlines that do not fly
from p_cityfr are displayed.
PARAMETERS p_cityfr TYPE spfli-cityfrom.
TYPES: BEGIN OF wa,
carrid TYPE scarr-carrid,
carrname TYPE scarr-carrname,
connid TYPE spfli-connid,
END OF wa.
DATA itab TYPE SORTED TABLE OF wa
WITH NON-UNIQUE KEY carrid.
SELECT s~carrid s~carrname p~connid
INTO CORRESPONDING FIELDS OF TABLE itab
FROM scarr AS s
LEFT OUTER JOIN spfli AS p ON s~carrid = p~carrid
AND p~cityfrom = p_cityfr.
DELETE itab WHERE connid <(><<)>> '0000'.
cl_demo_output=>display( itab ).
Documentation extract taken from SAP system, � Copyright SAP AG. All rights reserved