Application Development and Automation 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: 
Read only

Persistent Classes and Inheritance

Former Member
0 Likes
554

Hi everybody,

im currently having the following problem:

i have a persistent class called ZCL_COMMENT which is mapped to a database table.

Now another persistent class called ZCL_COMMENT2 has to inherit from this class. I defined ZCL_COMMENT as the superclass and everything seems to work fine.

But how can i now define new attributes? In the persistent data mapper i cant choose another database table where the additional data for new attributes could be saved. Do i have to add extra field to the database table of ZCL_COMMENT to achieve this? The table might get quite big, so this wouldnt be an optimal solution. Perfectly would be a solution where the complete persistent data of ZCL_COMMENT2 would be stored in an extra table.

Thanks in advance,

dsp

1 ACCEPTED SOLUTION
Read only

naimesh_patel
Active Contributor
0 Likes
498

When you create a persistent class, system defaults the class to "Final". If the class is Final, you must not inherit any other class from that class.

So, instead of inheriting the CLASS2 from CLASS1, use the CLASS1 inside the class CLASS2 by creating the attribute reference to CLASS1.

Regards,

Naimesh Patel

2 REPLIES 2
Read only

naimesh_patel
Active Contributor
0 Likes
499

When you create a persistent class, system defaults the class to "Final". If the class is Final, you must not inherit any other class from that class.

So, instead of inheriting the CLASS2 from CLASS1, use the CLASS1 inside the class CLASS2 by creating the attribute reference to CLASS1.

Regards,

Naimesh Patel

Read only

0 Likes
498

Hi dsp and Naimesh Patel

In my system (Netweaver 7.0 ehp 1) inheritance of persistent objects seems not possible. As you say the system defaults the class to "Final", and if I remove the final flag i get a syntax error.

But in Thomas Jungs splendid series of ABAP OO tutorials (Part 3 - Persistent Objects) he actually shows an example of Persistent Classes and Inheritance.

Do you know if this inheritance is possible in my system and maybe you can explain how to use the tool to generate the child class?

best regards

Thomas Madsen Nielsen