‎2021 Jul 17 8:26 AM
Hello Experts,
I'm new to abap. Trying to add "Left outer join" in the program. However getting below syntax error:
Pls help. Points will be awarded for right answer.
REPORT ZMARA_LEFTOUTERJOIN.
Types : BEGIN OF Ty_mat,
matnr type matnr,
ERNAME TYPE ERNAM,
werks type werks,
LABST TYPE LABST,
END OF TY_MAT.
DATA : it_MAT TYPE TABLE OF ty_MAT,
WA_MAT TYPE TY_MAT.
PARAMETERS : p_MATNR TYPE MATNR.
SELECT MARA-MATNR MARA-ERNAM MARD-WERKS MARD-LABST INTO TABLE it_mat
FROM MARA AS MARA LEFT OUTER JOIN MARD AS MARD
ON MARA-MATNR = MARD-MATNR
where mara-matnr = P_matnr.
Regards
ganesan
‎2021 Jul 17 9:30 AM
In ABAP SQL, use tilde, not dash (and also alias is not needed if it's same as table name
SELECT MARA~MATNR MARA~ERNAM MARD~WERKS MARD~LABST
INTO TABLE it_mat
FROM MARA
LEFT OUTER JOIN MARD
ON MARA~MATNR = MARD~MATNR.
‎2021 Jul 17 8:57 AM
Error
Line 23 Program ZMARA_LEFTOUTERJOIN
Field "MARD-MATNR" is unknown.
‎2021 Jul 17 9:24 AM
Please use the COMMENT button for comments, questions, adding details, replying to a comment or a proposed solution or to the OP question, etc., ANSWER is only to propose a solution, dixit SAP text at the right of the answer area.
‎2021 Jul 17 9:24 AM
Please edit your question, select your code and press the "CODE" button to make it correctly colorized/indented, so that it's easier for us to analyze it. Thank you.
‎2021 Jul 17 9:30 AM
In ABAP SQL, use tilde, not dash (and also alias is not needed if it's same as table name
SELECT MARA~MATNR MARA~ERNAM MARD~WERKS MARD~LABST
INTO TABLE it_mat
FROM MARA
LEFT OUTER JOIN MARD
ON MARA~MATNR = MARD~MATNR.
‎2021 Jul 17 9:56 AM
Wonderful. It worked. one quick question, while using write statement, I'm using dash like "mara-matnr" which is working, why not dash is not working while using join statement.
Thanks!!
‎2021 Jul 17 10:44 AM
Because you don't deal with same nature of object - table/alias column versus component of a structured variable, type or constant:
‎2021 Jul 19 7:40 AM
And remove the "points" phrase. It's offensive for people who try to help "for free"