2020 Nov 23 3:56 PM
Please advise me for below problem. Select statement for all entries is giving me error for inline data declaration.
This is written inside an RFC function module.
Product version is as below.
SAP_BASIS 7530002SAPK-75302 INSAPBASIS SAP Basis Component
SAP_ABA 75D0002SAPK-75D02 INSAPABA Cross-Application Component
Code:-
select matnr werks
from marc
into table @data(lt_marc)
for all entries in it_mat_plant_list
where matnr = it_mat_plant_list-matnr
and werks = it_mat_plant_list-werks.
Also tried as below.
select matnr werks
from marc
into table @data(lt_marc)
for all entries in @it_mat_plant_list
where matnr = @it_mat_plant_list-matnr
and werks = @it_mat_plant_list-werks.
Syntax Error for both codes:-
Function Module ZMM_SRM_CTR_TO_SA
If host variables are escaped using @, new OpenSQL must used throughout. This includes using commas as separators for list elements.
thank you in advance.
2020 Nov 23 4:48 PM
I re-wrote your code and I don't have syntax errors.
Check your code with mine.
report zprogram01.
types: begin of ty_data,
matnr type matnr,
werks type werks_d,
end of ty_data.
data it_mat_plant_list type standard table of ty_data.
start-of-selection.
select matnr, werks " <-- New syntax forces to add commas and @
from marc
into table @data(lt_marc) " <-- New syntax forces to add commas and @
for all entries in @it_mat_plant_list " <-- New syntax forces to add commas and @
where matnr = @it_mat_plant_list-matnr " <-- New syntax forces to add commas and @
and werks = @it_mat_plant_list-werks. " <-- New syntax forces to add commas and @
2020 Nov 23 4:15 PM
Use "inner join" instead of for all entries. You can join database table and internal table with new syntax.
DATA lt_carrids TYPE TABLE OF sflight_light.
APPEND VALUE sflight_light( carrid = 'AA' ) to lt_carrids.
SELECT s~carrid, ( s~carrname && s~currcode ) AS inco
FROM scarr AS s
inner JOIN @lt_carrids as i on i~carrid = s~carrid
INTO TABLE @DATA(scarr_s).
2020 Nov 23 4:57 PM
2020 Nov 23 4:48 PM
I re-wrote your code and I don't have syntax errors.
Check your code with mine.
report zprogram01.
types: begin of ty_data,
matnr type matnr,
werks type werks_d,
end of ty_data.
data it_mat_plant_list type standard table of ty_data.
start-of-selection.
select matnr, werks " <-- New syntax forces to add commas and @
from marc
into table @data(lt_marc) " <-- New syntax forces to add commas and @
for all entries in @it_mat_plant_list " <-- New syntax forces to add commas and @
where matnr = @it_mat_plant_list-matnr " <-- New syntax forces to add commas and @
and werks = @it_mat_plant_list-werks. " <-- New syntax forces to add commas and @
2020 Nov 23 5:00 PM
2020 Nov 23 6:47 PM
As it said in the syntax error and as you posted:
If host variables are escaped using @, new OpenSQL must used throughout. This includes using commas as separators for list elements.
2020 Nov 23 5:01 PM
thank you for both the answers! i want to accept both but i cudn't.