Correct way of using TYPE REF TO data?

abap, assignment-operator

Solution

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.

Problem

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?

Original source