Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Change Narrowing and Widening Cast

Former Member
0 Kudos

Hi,

Is it right, that at Release 6.40

Up Cast = Narrowing Cast

Down Cast = Widening Cast

and at Release 7.0

Up Cast = Widening Cast

Down Cast = Narrowing Cast

???

7 REPLIES 7

matt
Active Contributor
0 Kudos

No. Why do you suspect that it has?

Up Cast = Widening Cast

Down Cast = Narrowing Cast

matt

Former Member
0 Kudos

OK, Thanks.

Then is my education material (Release 6.40) wrong!

in my material stands, that

Up Cast = Narrowing Cast

Down Cast = Widening Cast

thats why I'm asking.

Sören

matt
Active Contributor
0 Kudos

It seems that it is wrong. Up cast means going up the inheritance tree - i.e. subclass to superclass (or interface). And this is wider, since the superclass is more general.

Former Member
0 Kudos

hi

ur 6.4 material is correct.....

NARROWING CAST --- UP-CAST....

The assignment of a subclass instance to a reference variable of the type “reference to superclass” is described as a narrowing cast, because you are switching from a view with more detail to a view with less detail(Generalization)

It also called as “up-cast” bcoz the casting is done in up.......

WIDENING CAST -


DOWN-CAST.....

Hear the view changes to more detail view (Specialization)..

reward if it useful

0 Kudos

I have only just started reading about Casting.

I have ABAP Object 2007 book from Horst Keller and I also have a 7.0 SAP System.

SAP have certainly changed the terminology from SAP 6.40.

Please see this hyperlink [Version 7.0 ABAP Modification 6|http://help.sap.com/abapdocu/en/ABENNEWS-70-DOCU.htm#!ABAP_MODIFICATION_6@6@]

In addition when I click on Help on MOVE and the Casting operator in my 7.0 Version system is explained as

Up Cast

Also referred to as widening cast. Assignment between reference variables, where the static type of the target variables is similar or identical to the static type of the source variables.

Down cast

Also called a narrowing cast, a down cast is an assignment between reference variables in which the typr static type of the target variable more specific than the static type of the source variable. A down cast is only possible in assignments with the casting operator (?=) or MOVE ... ?TO. Compare with up cast

SAP now want you to use the unambiguous terms of UP and DOWN Version 7.0 of course.

Does anybody else have any comments on this ?

0 Kudos

Does anyone has a final answer about this thread?

I have the Keller's book and metioned Widening = down cast and Narrowing like up cast, obviosly this will depends of the focus that you adopt, but I have the last certification books and metioned in the other sense, please if you have the final SAP answer or explanation about this change, let me know.

Thanks.

0 Kudos

Hello,

Peter is right. The terminology has changed. Up cast is now refered as widening cast . Down cast as narrowing cast . This changed arises from different look at the matter.

Normaly we got used to say windening cast refers to target class that has greater scope (is subclass) than source class (superclass). Subclass usually has more methods than its parent class.

Now we use to say widening cast refers to target class that has more general meaning (superclass) than source class (subclass). So we switch from more specialized view to more general one. That's why we say widening cast.

Regards

Marcin