‎2008 Jun 28 11:09 AM
Hi all,
Can anybody please tell the usuage of wide casting.
preferable with simple code.
Anirban Bhattacharjee
‎2008 Jun 28 1:23 PM
Anirban,
wide casting is nothing but method os assinging data object.
just refer:
http://help.sap.com/saphelp_nw04/helpdata/en/79/c55491b3dc11d5993800508b6b8b11/content.htm
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3930358411d1829f0000e829fbfe/content.htm
Amit.
‎2008 Jun 28 12:58 PM
‎2008 Jun 28 1:23 PM
Anirban,
wide casting is nothing but method os assinging data object.
just refer:
http://help.sap.com/saphelp_nw04/helpdata/en/79/c55491b3dc11d5993800508b6b8b11/content.htm
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3930358411d1829f0000e829fbfe/content.htm
Amit.
‎2008 Jun 30 7:28 AM
Hi,
1. Wider/up casting :
This means a ref object used is of a parent. Now here technically speaking you can only call the methods of the parent class and not of the child class. Even if the parent object is referencing to a child object at runtime, the compiler does not allow you to call the child method.
Wide casting does not have run-time errors as the compiler is able to identify the error at compile time only.
Wide casting is helpful when you want to have a generic parameter as the importing parameter in OOPs.
For eg.
Class p1
{
method x.
}
Class c1 parent p1
{
method y.
}
Class c2 parent p1
{
method z.
}
In the above example both class c1 and c2 are subclasses of p1 and therefore has method x.
Now let us say the user at runtime can pass object of c1,c2 or p1 and method x has to be capable of receiving all these, then in such case you can assign reference object of parent to method x.
So method x can be defined as follows
Class p1
{
method x importing p -
> where p is type ref to p1.
}
I hope this explains your query.
Regards,
Saurabh
‎2008 Jun 30 12:19 PM