Do you have any question about this error?
Stop googling SAP errors. Use our Free Essentials plan instead - no credit card needed. Start Now →
Message type: E = Error
Message class: OO - Class Builder/API
Message number: 120
Message text: A private method cannot be final (they are not inherited by subclasses)
Since SAP believes that this specific error message is 'self-explanatory,' no more information has been given.The majority of messages in the SAP system have a message text, however this is frequently insufficient to comprehend or resolve the problem.
To make things easier, more detailed information is frequently added to describe the issue, how to fix it, and the necessary steps or configuration modifications.
Unfortunately, there isn't any extra information in this error notice.
First, use our AnswerBot below to get a possible cause and solution (requires a premium subscription).
Also, review the in-depth Common Questions & Answers listed below; you could discover a solution there or be able to connect with others who have faced similar challenges.
You can also try searching the SAP support portal (support.sap.com) but you need a special user ID to access it. It is possible that an SAP support note exists that provides additional details about the mistake or even steps for fixing it.
OO120
- A private method cannot be final (they are not inherited by subclasses) ?The SAP error message "OO120 A private method cannot be final (they are not inherited by subclasses)" typically occurs in ABAP Object-Oriented programming when you attempt to declare a private method as
FINAL
.Cause:
In ABAP, a method declared as
FINAL
indicates that it cannot be overridden in any subclass. However, private methods are not inherited by subclasses at all. Since private methods cannot be accessed or overridden by subclasses, marking them asFINAL
is redundant and not allowed, leading to this error message.Solution:
To resolve this error, you should remove the
FINAL
keyword from the method declaration. Here’s how you can do it:
- Locate the Method Declaration: Find the method in your class where the error is occurring.
- Remove the
FINAL
Keyword: Change the method declaration from:METHOD my_private_method FINAL.
to:
METHOD my_private_method.
Related Information:
Access Modifiers: Understand the different access modifiers in ABAP:
FINAL Keyword: The FINAL
keyword is used to prevent method overriding in subclasses. It is only applicable to PROTECTED
and PUBLIC
methods.
Best Practices: When designing your classes, consider the visibility and inheritance of methods carefully. Use FINAL
only when you want to restrict method overriding and ensure that the method is either PUBLIC
or PROTECTED
.
By following these guidelines, you can avoid the OO120 error and ensure that your ABAP code adheres to the principles of object-oriented programming.
Get instant SAP help. Sign up for our Free Essentials Plan.
OO119
Protected methods should not be final
Self-Explanatory Message Since SAP believes that this specific error message is 'self-explanatory,' no more information has been given.The majority of...
OO118
Methods cannot be both abstract and final
Self-Explanatory Message Since SAP believes that this specific error message is 'self-explanatory,' no more information has been given.The majority of...
OO121
Constructors cannot be abstract (and are therefore implicitly final)
Self-Explanatory Message Since SAP believes that this specific error message is 'self-explanatory,' no more information has been given.The majority of...
OO122
Class &1 set to abstract
Self-Explanatory Message Since SAP believes that this specific error message is 'self-explanatory,' no more information has been given.The majority of...
Click on this link to search all SAP messages.