I've declared a type with the type of ref to data. so it looks like this
my_type type ref to data.
Then I declare an internal table, which I want to assign to my_type.
Data:
ref_data type my_type.
itable type it_table.
ref_data = itable.
Why can't I assign itable to ref_data, isn't a ref to data is a generic data type and can be assigned to anything?
A data reference has to be typed, but you type it at run time. data: ref_data type ref to data. data: itable type it_table. "you access the data in a data reference via a field symbol field-symbols: <dref> type any.
TYPE REF TO - defines that the data is a reference to a more complex object - that could be some data, a class or an interface. It's like a pointer to where the object is.
TYPE REF TO {type|(name)}. Effect. The addition TYPE REF TO is used by the statement CREATE DATA to create a reference variable. The static type of the reference variable can be specified either directly as type or dynamically in name.
This is very similar to other programming languages, and it's not a problem of typing the variables or references. You're trying to assign a value to a pointer variable - that won't work anywhere. You need to use GET REFERENCE OF itable INTO ref_data.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With