09-08-2014 9:53 AM
Hi Gurus,
I am new to OO ABAP. Recently I learnt about casting concept in OO-ABAP. I was curious to know what is the use of casting, what is the need to use or know casting in OO concept.
I searched for this topic in SDN but didn't got use full answers.
Thanks you
Sreeni
09-08-2014 3:01 PM
Hi,
OO is a reusable code concept.
Look for IF_PURCHASE_ORDER_MM interface and cl_po_header_handle_mm class.
The class was designed with this interface (and others too).
Then, the class has the interface (methods and attributes).
When you code:
o_purchase_order ?= im_header.
*(o_purchase_order type class and im_header type interface)
You will initialize the object o_purchase_order, passing all the attributes and values from interface object im_header.
Note that o_purchase_order has other interfaces, and to initialize theirs values you will need to do the same with their respective interfaces.
Using casting command you will reduce effort, creating clean and quality code.
09-08-2014 3:01 PM
Hi,
OO is a reusable code concept.
Look for IF_PURCHASE_ORDER_MM interface and cl_po_header_handle_mm class.
The class was designed with this interface (and others too).
Then, the class has the interface (methods and attributes).
When you code:
o_purchase_order ?= im_header.
*(o_purchase_order type class and im_header type interface)
You will initialize the object o_purchase_order, passing all the attributes and values from interface object im_header.
Note that o_purchase_order has other interfaces, and to initialize theirs values you will need to do the same with their respective interfaces.
Using casting command you will reduce effort, creating clean and quality code.
09-08-2014 3:32 PM
Hi,
Please try to search a bit harder, I have just found over 800 results on SCN for "ABAP OBJECT CASTING" including numerous blogs, discussions, wiki entries, etc.
Casting is an OO paradigm, not specific to ABAP so you could also try using Google to find out about casting.
As a starter for 10, try reading this blog post about but please search harder in future.
Cheers,
G.