2012 Sep 22 5:43 PM
Hi all,
how can I cast object that was declared as REF TO DATA on REF TO cl_some_class?
DATA: lr_source TYPE REF TO data.
FIELD-SYMBOLS: <lr_dest> TYPE REF TO CL_WDR_CONTEXT_ELEMENT.
I've tried:
ASSIGN lr_source->* TO <lr_dest> CASTING.
but it's leading to error. Any ideas?
Best Regards
Marcin Cholewczuk
2012 Sep 22 10:36 PM
Hi,
Whats the error you are getting when using
ASSIGN lr_source->* TO <lr_dest> CASTING.
Best,
Iftah
2012 Sep 22 7:49 PM
You have to use "Create data" statement before de-referencing data reference variable.
CREATE DATA lr_source TYPE REF TO cl_wdr_context_element
Regards,Vinod
2012 Sep 22 10:31 PM
Data was already created by SAP (as you can see in screenshot). I need only to cast it to other type.
Best regards
Marcin Cholewczuk
2012 Sep 22 10:36 PM
Hi,
Whats the error you are getting when using
ASSIGN lr_source->* TO <lr_dest> CASTING.
Best,
Iftah
2012 Sep 22 10:41 PM
Hi,
it's webdynpro application and on www I'm getting
500 SAP Internal Server Error
ERROR: Type conflict with ASSIGN in program /1BCWDY/H1UTWYPFI3KEUNC5NTTT==CP . (termination: RABAX_STATE)
Best regards
Marcin Cholewczuk
2012 Sep 22 11:23 PM
Hi,
I know it's a webdynpro.
Ok, so I can help you, I need the code in the method where you are using it (for example in
WDDOINIT,WDDOMODIFYVIEW) because it is not clear how did you created the reference lr_source. Meanwhile try (with out the casting):
ASSIGN lr_source->* TO <lr_dest>.
Best,
Iftah.
2012 Sep 22 11:31 PM
Ok, i did it.
DATA: lr_source TYPE REF TO data,
lr_dest TYPE REF TO CL_WDR_CONTEXT_ELEMENT.
FIELD-SYMBOLS: <lr_any> TYPE ANY.
ASSIGN lr_source->* TO <lr_any>.
lv_dest ?= <lr_any>.
Best Regards
Marcin Cholewczuk