Application Development and Automation 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: 
Read only

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

Former Member
0 Likes
4,826

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

1 ACCEPTED SOLUTION
Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
2,034

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

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

4 REPLIES 4
Read only

Former Member
0 Likes
2,034

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.

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
2,035

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

Read only

Former Member
0 Likes
2,034
 ASSIGN c_accit->* TO <l_itm_details>."De-reference the data reference 

Here pls. let me know,

1) What will do the symbol of

 ->* 

and how do we call it?

2) What does mean of 'De-reference'

Thank you.

Read only

brad_bohn
Active Contributor
0 Likes
2,034

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.