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

Inheritance

BGarcia
Active Contributor
0 Likes
361

Hello Everybody,

I just one doubt concerning inheritance. For example, the class CL_CRM_IC_SRVTHEAD_IMPL has private methods.

If I create one class, and point CL_CRM_IC_SRVTHEAD_IMPL as his superclass, this methods are not inherited.

Must I implement them by hand in the new class, in the same way they're define in superclass? Or when their are called in application, they're gonna be called CL_CRM_IC_SRVTHEAD_IMPL methods.

Best Regards,

Bruno Garcia

View Entire Topic
rainer_liebisch
Product and Topic Expert
Product and Topic Expert
0 Likes

Hi Bruno,

you don't have to rewrite the classes. Just use the cast operator. Let me give you an example:

You have a class Z_CL_1 which inherits from CL_1 and a class Z_CL_2 which inherits from CL_2. In CL_2 you have the attribute:

attr type ref to CL_1.

When you need attr in a method in Z_CL_2, you can write in that method:

method mymethod.

data: z_attr type ref to Z_CL_1.

z_attr ?= attr.

...

endmethod.

When you need it in your programme, you can do the same. Just make sure that an instance of Z_CL_1 exists before you use the cast.

Regards,

Rainer

...