Do you have any question about this error?
Message type: E = Error
Message class: OO - Class Builder/API
Message number: 119
Message text: Protected methods should not be final
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.
OO119
- Protected methods should not be final ?The SAP error message OO119, which states "Protected methods should not be final," is related to the object-oriented programming principles in ABAP (Advanced Business Application Programming). This error typically arises when you define a method in a class as both
protected
andfinal
.Cause:
In ABAP, a
protected
method is one that can be accessed by the class itself and its subclasses. However, marking a method asfinal
means that it cannot be overridden in any subclass. This creates a contradiction because if a method isprotected
, it is intended to be overridden by subclasses, but marking it asfinal
prevents that. Therefore, the ABAP compiler raises this error to indicate that the method's access level and its finality are incompatible.Solution:
To resolve this error, you need to decide on the intended behavior of the method:
Remove the
final
Keyword: If you want the method to be overridden in subclasses, simply remove thefinal
keyword from the method definition. This allows subclasses to provide their own implementation of the method.CLASS my_class DEFINITION. PROTECTED SECTION. METHODS my_protected_method. ENDCLASS. CLASS my_class IMPLEMENTATION. METHOD my_protected_method. " Implementation here ENDMETHOD. ENDCLASS.
Change the Access Modifier: If you want to keep the method as
final
, you should change its access modifier toprivate
. This way, the method cannot be overridden, and it will not conflict with thefinal
keyword.CLASS my_class DEFINITION. PRIVATE SECTION. METHODS my_final_method FINAL. ENDCLASS. CLASS my_class IMPLEMENTATION. METHOD my_final_method. " Implementation here ENDMETHOD. ENDCLASS.
Related Information:
public
, protected
, private
) and their implications on method visibility and inheritance.By addressing the conflict between the protected
and final
keywords, you can resolve the OO119 error and ensure that your ABAP code adheres to best practices in object-oriented design.
Get instant SAP help. Start your 7-day free trial now.
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...
OO117
Type & cannot be referenced using LIKE
Self-Explanatory Message Since SAP believes that this specific error message is 'self-explanatory,' no more information has been given.The majority of...
OO120
A private method cannot be final (they are not inherited by subclasses)
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...
Click on this link to search all SAP messages.