Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inline cast of char types

Does abap have any method to perform an inline cast for char types (or any similar types of different length)? Perhaps there is something similar to value operator( for structures) that can be used for fields.

Concrete example (name is of type tdobname, which is char 70 and ebeln is char 10) that leads to a dump due to type mismatch:

call function 'READ_TEXT'
  exporting
    id                      = lv_textid
    language                = sy-langu
    name                    = ls_ekko-ebeln
    object                  = 'EKKO'
  tables
    lines                   = lt_textlines

For now I added an line of conversion to a variable of destination type (which works), but I am hoping to skip that step.

data: lv_name type tdobname.
lv_name = ls_ekko-ebeln.
call function 'READ_TEXT'
  exporting
    ...
    name                    = lv_name
    ...
like image 724
Zero Avatar asked Mar 06 '23 21:03

Zero


1 Answers

Use CONV operator for that:

DATA(lv_name) = CONV tdobname( ls_ekko-ebeln ).
like image 106
Suncatcher Avatar answered Mar 15 '23 10:03

Suncatcher