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

OPEN SQL error

former_member625844
Participant
0 Likes
1,232

I wrote a SQL like below.

FIELD-SYMBOLS:
          <datarow> TYPE ANY,
          <datafield> TYPE ANY.
SELECT adrc~street FROM ekko left join lfa1 on ekko~lifnr = lfa1~lifnr   
left join adrc on lfa1~adrnr = adrc~addrnumber
INTO <datarow>.

And it has error 'If new OPEN SQL syntax used it must used throughtput, including using @ for host variable' I wonder what caused this error, because I tried other SQL clauses and it worked fine. Thx.

1 ACCEPTED SOLUTION
Read only

Sandra_Rossi
Active Contributor
0 Likes
1,159

It's using the strict SQL syntax because of the table ADRC which is left-joined on the already left-joined table LFA1. I'm not sure why it's so bad, but the syntax with INNER JOIN is accepted and should do exactly what you want (+ I added ENDSELECT):

SELECT adrc~street
    FROM ekko
    LEFT JOIN lfa1 ON ekko~lifnr = lfa1~lifnr
    INNER JOIN adrc ON lfa1~adrnr = adrc~addrnumber
    INTO <datarow>.
ENDSELECT.
4 REPLIES 4
Read only

JamesG
Participant
0 Likes
1,159
FIELD-SYMBOLS:
          <datarow> TYPE ANY,
          <datafield> TYPE ANY.
SELECT adrc~street FROM ekko left join lfa1 on ekko~lifnr = lfa1~lifnr
left join adrc on lfa1~adrnr = adrc~addrnumber
INTO @<datarow>.
ENDSELECT.

it need host variable. host variable is your defined variable,it need @.

Read only

JamesG
Participant
0 Likes
1,159
FIELD-SYMBOLS:
          <datarow> TYPE ANY,
          <datafield> TYPE ANY.
SELECT adrc~street FROM ekko left join lfa1 on ekko~lifnr = lfa1~lifnr
left join adrc on lfa1~adrnr = adrc~addrnumber
INTO @<datarow>.
ENDSELECT.

in join table,need it.

Read only

0 Likes
1,159

You need to mention @ before mentioning the internal table or work area

Read only

Sandra_Rossi
Active Contributor
0 Likes
1,160

It's using the strict SQL syntax because of the table ADRC which is left-joined on the already left-joined table LFA1. I'm not sure why it's so bad, but the syntax with INNER JOIN is accepted and should do exactly what you want (+ I added ENDSELECT):

SELECT adrc~street
    FROM ekko
    LEFT JOIN lfa1 ON ekko~lifnr = lfa1~lifnr
    INNER JOIN adrc ON lfa1~adrnr = adrc~addrnumber
    INTO <datarow>.
ENDSELECT.