ABAP hard code value into SELECT and field into another field

半城伤御伤魂 提交于 2019-12-11 00:55:20

问题


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.


来源:https://stackoverflow.com/questions/39227917/abap-hard-code-value-into-select-and-field-into-another-field

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!