ABAP hard code value into SELECT and field into an

2019-07-08 09:21发布

问题:

It is possible in ABAP to make a select and include a hard code value and to put a value in any field.

In my exemple i have to fill a range with Company code BUKRS according to VKORG so i have to do a select on TVKO like that:

DATA : lt_rtvko TYPE RANGE OF bukrs.

  SELECT    'I' as sign 'EQ' as option bukrs as low 
  INTO      CORRESPONDING FIELDS OF TABLE lt_rtvko
  FROM      tvko
  WHERE     vkorg EQ p_vkorg.

But i have a dump.

I know a longer solution to do this, To fill manually a table of TVKO and make a LOOP to fill the range, BUT i am sure that we have a solution to do that in one operation like in my example.

Thanks, Experts.

回答1:

It's actually pretty easy. Just get rid of INTO CORRESPONDING and AS. As long as the value order is right, you get no problem:

SELECT 'I', 'EQ', bukrs
  FROM tvko
  INTO TABLE @lt_rtvko
 WHERE vkorg = @p_vkorg.

And I think you have a typo in your range declaration. Should be:

DATA: lt_rtvko TYPE RANGE OF bukrs.


标签: sql sap abap