简体   繁体   中英

ABAP hard code value into SELECT and field into another field

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM