Google Search - Blog...........

ABAP - OOPS: Sample Program On Widening Cast In Method Programming.

REPORT YSUBDEL .

class c1 definition.
public section.
data : num type i value 5.
endclass.

class c1 implementation.
endclass.

class c2 definition inheriting from c1.
public section.
endclass.

class c2 implementation.
endclass.

start-of-selection .
data : obj1 type ref to c1 ,
obj2 type ref to c2 .
create object : obj1 ,
obj2 .

TRY.
obj2 ?= obj1.
CATCH cx_sy_move_cast_error.
write:/5 'cx_sy_move_cast_error trapped'.
ENDTRY.


Output:
cx_sy_move_cast_error trapped

No comments:

Post a Comment