‎2007 Oct 25 11:29 AM
Hi,
I have declared two classes with names, ZCL_ONE, ZCL_TWO.
ZCL_TWO is inhering ZCL_ONE.
Now i am using them in the se38 program.
While i use it, Narrow casting is working fine, But widening casting is not working.
It is throwing an exception or a dump if i do not catch an exception.
Code:
DATA: OBJ1 TYPE REF TO ZCL_ONE,
OBJ2 TYPE REF TO ZCL_TWO.
CREATE OBJECT OBJ1.
OBJ2 ?= OBJ1.
The above code is giving me dump. Any guesses about how to solve it.
I am able to work with the Narrow casting.. which is below code.. It is working fine.
DATA: OBJ1 TYPE REF TO ZCL_ONE,
OBJ2 TYPE REF TO ZCL_TWO.
CREATE OBJECT OBJ2.
OBJ1 = OBJ2.
How to resolve the error.
Thanks in Advance.
‎2007 Oct 25 5:39 PM
Try the Below code it was working
"This peice i changed for widening casting DATA: OBJ1 TYPE REF TO ZCL_ONE,
OBJ2 TYPE REF TO ZCL_TWO,
OBJ LIKE OBJ2.
CREATE OBJECT OBJ2.
OBJ1 = OB2 .
OBJ ?= OBJ1."This is your code which is correct for Narrow castingDATA: OBJ1 TYPE REF TO ZCL_ONE,
OBJ2 TYPE REF TO ZCL_TWO.
CREATE OBJECT OBJ2.
OBJ1 = OB2 .
Reward points if it is usefull...
Girish