‎2009 Nov 20 6:06 PM
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
‎2009 Nov 20 6:21 PM
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
‎2009 Nov 20 6:21 PM
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
‎2010 Feb 12 8:50 AM
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