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: 

Inline data declaration for all entries

bhakti2
Active Participant
0 Kudos
5,523

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.

1 ACCEPTED SOLUTION

nmirandaghn
Participant
3,162

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 @
6 REPLIES 6

tugay_birihan
Participant
0 Kudos
3,162

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).


0 Kudos
3,162

thanks a tonn. i would have never found it myself.

nmirandaghn
Participant
3,163

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 @

bhakti2
Active Participant
0 Kudos
3,162

yes, comma made it work. thank you!

matt
Active Contributor
0 Kudos
3,162

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.

bhakti2
Active Participant
0 Kudos
3,162

thank you for both the answers! i want to accept both but i cudn't.