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

How to define a TYPE REF TO data into my local variable/structure?

Hello,

I am trying to implementing a BADI, in its signature part,

 c_accit TYPE REF TO data. 

My pseudo code goes like,

 DATA: l_itm_details TYPE REF TO data.
l_itm_details = c_accit.
l_itm_details-koart = 'D' =====> here am getting error!
* Do processing
ENDIF.

Here am getting error that, l_itm_details is not a structure! Pls. let me know how to fix it?

Thank you

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Apr 19, 2011 at 06:27 AM

    Hello,

    c_accit TYPE REF TO data.

    C_ACCIT is a "data reference" parameter. In order to access its components you have to "de-reference" it!

    FIELD-SYMBOLS: <l_itm_details> TYPE ANY,
    <l_value> TYPE ANY.
    
    ASSIGN c_accit->* TO <l_itm_details>."De-reference the data reference
    
    ASSIGN COMPONENT 'KOART' OF STRUCTURE <l_itm_details> TO <l_value>.

    If you know the structure of the data reference variable you can define your field-symbol <l_itm_details> of that type directly, else you can define a generic type as mentioned in the code snippet.

    BR,

    Suhas

    Add a comment
    10|10000 characters needed characters exceeded

    • You call '->*' just as Suhas explained. That symbol is called the de-referencing operator and it merely serves to give the field-symbol the value of the data object in the storage area. You can read more about it in the help files on ASSIGN. De-referencing' just means de-coding the value of a data reference.

  • author's profile photo Former Member
    Former Member
    Posted on Apr 19, 2011 at 04:09 AM

    Hi Raju,

    I am not sure what this data is.i.e. class or structure.

    I am assuming that it is a structure. In your code what you have done is only declared references but not created the instance.

    Please try the below code it will resolve your problem.

    DATA : c_accit TYPE REF TO data.

    l_itm_details TYPE REF TO data.

    CREATE DATA c_accit.

    l_itm_details = c_accit.

    l_itm_details->koart = 'D' .

    Hope it will resolve your problem.

    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.