I want to create a select that left joins multiple tables.
In the following code, I need to select only lines of table EKPO where column EBELN = variable lv_ebeln. But as soon as I add this condition to the WHERE, I get this syntax error:
The elements in the "SELECT LIST" list must be separated using commas.
So, is there a way to add this condition?
DATA: BEGIN OF wa_itab,
gjahr TYPE rseg-gjahr,
ebelp TYPE ekpo-ebelp,
END OF wa_itab,
itab LIKE TABLE OF wa_itab,
lv_belnr TYPE rseg-belnr,
lv_ebeln TYPE ekpo-ebeln.
SELECT rseg~gjahr ekpo~ebelp FROM rseg
LEFT JOIN ekpo ON rseg~ebeln = ekpo~ebeln AND rseg~ebelp = ekpo~ebelp
INTO (wa_itab-gjahr, wa_itab-ebelp )
WHERE rseg~belnr = lv_belnr
AND ekpo~ebeln = lv_ebeln. " <=== SYNTAX ERROR because of this line
...
" some other code
...
APPEND wa_itab TO itab.
ENDSELECT.
WHEREcondition it is clear that what you need is anINNER JOINand notLEFT (OUTER) JOIN.