‎2021 Jul 24 4:57 PM
Hi Experts,
I'm getting below syntax error while saving the program. Kindly share your inputs.
Error : "if the new open SQL syntax is used, it must be used throughout. This includes @ to escape host variables.
Getting error in line "INTO TABLE IT_mseg".
tables : bkpf , acdoca , mseg.
types : begin of ty_mseg,
bukrs type bkpf-bukrs,
belnr type bkpf-belnr,
mblnr type mseg-mblnr,
blart type bkpf-blart,
hsl type acdoca-hsl,
end of ty_mseg.
data : it_mseg type table of ty_mseg,
wa_mseg type ty_mseg.
select-options : s_bukrs for bkpf-bukrs,
s_gjahr for bkpf-gjahr,
s_blart for bkpf-blart.
start-of-selection.
select bkpf~bukrs , acdoca~belnr , mseg~mblnr , bkpf~blart , acdoca~hsl
from bkpf inner join acdoca
on bkpf~belnr = acdoca~belnr
inner join mseg
on bkpf~xblnr = mseg~mblnr
INTO TABLE IT_mseg
where bkpf-bukrs in s_bukrs
and bkpf-gjahr in s_gjahr
and bkpf-blart in s_blart.
loop at : it_mseg into wa_mseg.
write : / wa_mseg-bukrs , wa_mseg-belnr , wa_mseg-mblnr , wa_mseg-blart , wa_mseg-hsl.
endloop.
‎2021 Jul 24 5:11 PM
I say like Subhajit and concerning Error : "if the new open SQL syntax is used, it must be used throughout. This includes @ to escape host variables. Getting error in line "INTO TABLE IT_mseg".
This is due to using commas between column names.
Solution (NB: INTO must be at the end):
where bkpf~bukrs in @s_bukrs
and bkpf~gjahr in @s_gjahr
and bkpf~blart in @s_blart
INTO TABLE @IT_mseg
‎2021 Jul 24 5:05 PM
Can you correct it to
where bkpf~bukrs in s_bukrs
and bkpf~gjahr in s_gjahr
and bkpf~blart in s_blart.
Thanks.
‎2021 Jul 24 5:11 PM
I say like Subhajit and concerning Error : "if the new open SQL syntax is used, it must be used throughout. This includes @ to escape host variables. Getting error in line "INTO TABLE IT_mseg".
This is due to using commas between column names.
Solution (NB: INTO must be at the end):
where bkpf~bukrs in @s_bukrs
and bkpf~gjahr in @s_gjahr
and bkpf~blart in @s_blart
INTO TABLE @IT_mseg
‎2021 Jul 26 7:53 AM
Just to escape the variables will fix the error. The INTO position has no effect here (I always put my INTO after the SELECT because I'm used to it).
‎2021 Jul 26 8:24 AM
vicen.lozano Oh, you're right for the INTO. Sometimes the syntax checker requires to place it at the end, not here (I should learn what the exact positioning rules are :-p).
‎2021 Jul 26 8:32 AM
Yup... I remembered it because sometimes the checker asks me to do that, and then I become upset XD
‎2021 Jul 25 8:32 AM
‎2021 Jul 26 8:25 AM
Thanks for the feedback. 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 26 7:53 AM
You're lucky Sandra came here fast. The next time, just read the error message, it's clear enough.