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: 

how to assign current class reference to a variable

RachamallaKiran
Participant
0 Kudos

hi all,

i want to assign current class reference to a variable.

ex; in the below example i am not knowing how to assign lref_A1 in class A2 with reference of A1.

may i know how to assign it.

class A1 defination,
 methods first,
endclass

class A2,
data lref_A1 type ref to A1,
methods some_test,
endclass.

class A1 implementaion.
method first.
create object lref_new2 type ref to A2.
*****how to assign lref_A1 the current reference 

***lref_new2-lref_A1 = this or lref_new2-lref_A1 = me "is not working 

********how to assign
end method.
endclass.

create object lref_new type A1.
lref_new->first( ).
1 ACCEPTED SOLUTION

Muthuraja
Active Participant
0 Kudos

Hi Kiran,

ME should work

class a1 implementation.

  method first.

    data: lref_new2 type ref to a2.

    create object lref_new2.

    lref_new2->lref_A1 = me.

  endmethod.

endclass.


Regards,

Muthu

5 REPLIES 5

Muthuraja
Active Participant
0 Kudos

Hi Kiran,

ME should work

class a1 implementation.

  method first.

    data: lref_new2 type ref to a2.

    create object lref_new2.

    lref_new2->lref_A1 = me.

  endmethod.

endclass.


Regards,

Muthu

kiran rachamalla tried ME but it couldn't work because the true error was that an attribute cannot be assigned with the structure component selector (minus character), it can be assigned only with the object component selector ->.

Muthuraja
Active Participant
0 Kudos

Yes Sandra, Exactly.

0 Kudos

hi Muthu,

i only placed wrong actually i placed type ref to data

that leads to issue.

now corrected .

Regards,

kiran rachamalla.

0 Kudos

So, Kiran, as far as I understand, your question had so many typos that nobody could even find the right issue. Next time, post a compilable source code, PLEASE!