cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

What's the difference between "?=" and "CAST"?

EricYu0912
Product and Topic Expert
Product and Topic Expert
0 Kudos
540

Hi experts,

As far as I know, CAST operation ?= only works for object reference. Is there any other difference?

Besides, is casting only possible for objects that has relationship, e.g., interface and class or super class and sub class. For objects that has no relationship, is it possible to do casting?

Regards,
Eric

Accepted Solutions (0)

Answers (2)

Answers (2)

keremkoseoglu
Contributor
0 Kudos

CAST can be used in-line; typically during method calls. Example:

my_method( obj = CAST #( lo_something ) ).
RaymondGiuseppi
Active Contributor
0 Kudos

Read first some basics such as Oo Design Principles as well as Abap documentation =, ?=, Upcast and Downcast and Assignment Rules for Reference Variables.