Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Correct way of using TYPE REF TO data?

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?

like image 303
gidoy nyemot Avatar asked Aug 22 '12 11:08

gidoy nyemot


People also ask

How do you read data from type ref to data?

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.

What is type ref?

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.

What is type ref to in SAP ABAP?

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.


1 Answers

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.

like image 148
vwegert Avatar answered Sep 30 '22 11:09

vwegert