Skip to Content
author's profile photo Former Member
Former Member

Type Ref to DATA

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..

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Posted on Nov 07, 2007 at 01:09 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 22, 2007 at 10:03 AM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.