Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Type Ref to DATA

Former Member
0 Kudos

Hi All,

I have parameter in a method, which of "type ref to data".. while debugging I could see some values are getting populated inside that.. ( a structure/group of values )

Now my question is simple,, how can access those values populated inside this variable ?..

Please Help me,, 4 points..

Thanks in Advance, Sudeep..

2 REPLIES 2

marcelo_ramos
Active Contributor
0 Kudos

Hi,

Look at the follow example. I hope it's usefull for you.


CLASS mar_test DEFINITION.

  PUBLIC SECTION.

"   Defining a method with a returning parameter
    METHODS get_value
            RETURNING value(r_data) TYPE REF TO data.

ENDCLASS.                    "mar_test DEFINITION

*----------------------------------------------------------------------*
*       CLASS mar_test IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS mar_test IMPLEMENTATION.

  METHOD get_value.

    FIELD-SYMBOLS <variable> TYPE ANY.

    DATA v_variable TYPE char2.
"   Here we're creating a new reference to Data v_variable
    CREATE DATA r_data LIKE v_variable.

"   Moving the reference to a field-symbols
    ASSIGN r_data->* TO <variable>.

"   Manipulating the content of the reference through field-symbols <variable>
    MOVE 'AB' TO <variable>.

  ENDMETHOD.                    "get_value

ENDCLASS.                    "mar_test IMPLEMENTATION

DATA o_mar_test TYPE REF TO mar_test.
DATA v_variable TYPE char2.
DATA v_value TYPE REF TO data.

FIELD-SYMBOLS <variable> TYPE ANY.

START-OF-SELECTION.

  CREATE OBJECT o_mar_test.

" The method returns the reference of a data into v_value
  v_value = o_mar_test->get_value( ).

" You can't access directly the Content of reference so, you must use
" dereferencing operator ->* to move values to a field-symbols
  ASSIGN v_value->* TO <variable>.
" After make the dereferencing you can move the value of field-symbols to any Compatible Data
  MOVE <variable> TO v_variable.

" Now you can work with a Data that contains the value returned from method
  WRITE v_variable.

Regards.

Marcelo Ramos

Former Member
0 Kudos

hi,

check this.

data ref type ref to data.

field-symbols:

<fs_x> type any.

create data ref type ....."your type here.

assign ref->* to <fs_x>.

************fs_x contains the dta pointed by ref.