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: 

Issue while instantiating object of abstract class

meenakshi_raina
Employee
Employee
0 Kudos

Hi All,

I am stuck in this issue. I have two classes -

class 1 - which is an abstract class

class 2 - my class where i want to call a method ( "setup ") of class 1.

I cannot make class 1 as the super class of class 2, as I have already another super class.

I have done this till now -

1. Created an object of class 1 in class 2.

mr_set type ref to "class 1".

mr_set->setup( ). or

CALL METHOD mr_set->setup.

this gives me an error - Method "SETUP" is unknown or PROTECTED or PRIVATE.

2. Then i tried to declare class 2 in the "friend" list of class 1.

this does not give me any error. But in debug mode, it raises some kind of exception.

Can anyone please help me with it.

Thanks

Meenakshi

1 ACCEPTED SOLUTION

horst_keller
Product and Topic Expert
Product and Topic Expert

"I have done this till now -

1. Created an object of class 1 in class 2. "

How that? You cannot create objects of abstract classes.

"this gives me an error - Method "SETUP" is unknown or PROTECTED or PRIVATE."

How and where is setup declared?

"Can anyone please help me with it."

No, ABAP has no means to overcome these limitations.

4 REPLIES 4

horst_keller
Product and Topic Expert
Product and Topic Expert

"I have done this till now -

1. Created an object of class 1 in class 2. "

How that? You cannot create objects of abstract classes.

"this gives me an error - Method "SETUP" is unknown or PROTECTED or PRIVATE."

How and where is setup declared?

"Can anyone please help me with it."

No, ABAP has no means to overcome these limitations.

0 Kudos

Hi Horst,

Please find these details -

1. In class2, in attributes section I have done this declaration -

protected section.

data MR_SET type ref to class1 .

2. Set up is declared in my class 1 .

protected section.

methods SETUP .

Do you need any more details ?

Thanks and Regards

Meenakshi

horst_keller
Product and Topic Expert
Product and Topic Expert
0 Kudos

Still confusing. Is class1 the same as /SIE/KFP_CLASS_DIALOG?

  • You cannot create an instance of an abstract class.
  • You can call methods of a protected section in subclasses only.

It seems that you try to do things that are simply not allowed.

0 Kudos

okay. then it seems that i will have to find another way to do my code, as I cannot access the method of this class.

Thanks Horst. 🙂