Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Error in Left Outer join

2,448

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

1 ACCEPTED SOLUTION
Read only

Sandra_Rossi
Active Contributor
2,143

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.
7 REPLIES 7
Read only

0 Likes
2,143

Error

Line 23 Program ZMARA_LEFTOUTERJOIN

Field "MARD-MATNR" is unknown.

Read only

0 Likes
2,143

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.

Read only

Sandra_Rossi
Active Contributor
2,143

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.

Read only

Sandra_Rossi
Active Contributor
2,144

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.
Read only

0 Likes
2,143

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!!

Read only

0 Likes
2,143

Because you don't deal with same nature of object - table/alias column versus component of a structured variable, type or constant:

Read only

VXLozano
Active Contributor
0 Likes
2,143

And remove the "points" phrase. It's offensive for people who try to help "for free"