Stop googling SAP errors. Use our Free Essentials plan instead - no credit card needed. Start Now

Close

How To Fix OO086 - Constructors and destructors must be created explicitly


SAP Error Message - Details

  • Message type: E = Error

  • Message class: OO - Class Builder/API

  • Message number: 086

  • Message text: Constructors and destructors must be created explicitly

  • Show details Hide details


  • Self-Explanatory Message

    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.



    What else can you do?

    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.


Smart SAP Assistant

  • What is the cause and solution for SAP error message OO086 - Constructors and destructors must be created explicitly ?

    The SAP error message OO086, which states "Constructors and destructors must be created explicitly," typically occurs in ABAP Object-Oriented programming when you are trying to use a class that requires explicit constructors or destructors, but they have not been defined.

    Cause:

    1. Missing Constructor/Destructor: The class you are working with is defined without an explicit constructor or destructor. In ABAP, if you define a class that has attributes or requires initialization, you must provide a constructor to initialize those attributes.
    2. Inheritance Issues: If you are inheriting from a superclass that has a constructor or destructor, and you do not define one in the subclass, this error can occur.
    3. Abstract Classes: If you are trying to instantiate an abstract class directly, which cannot be done, you may encounter this error.

    Solution:

    1. Define a Constructor: If your class requires initialization, you need to define a constructor method. You can do this by adding the following code to your class definition:

      CLASS your_class_name DEFINITION.
        PUBLIC SECTION.
          METHODS: constructor.
      ENDCLASS.
      
      CLASS your_class_name IMPLEMENTATION.
        METHOD constructor.
          " Initialization code here
        ENDMETHOD.
      ENDCLASS.
    2. Define a Destructor: If your class requires cleanup, you should also define a destructor method:

      CLASS your_class_name DEFINITION.
        PUBLIC SECTION.
          METHODS: constructor,
                   destructor.
      ENDCLASS.
      
      CLASS your_class_name IMPLEMENTATION.
        METHOD constructor.
          " Initialization code here
        ENDMETHOD.
      
        METHOD destructor.
          " Cleanup code here
        ENDMETHOD.
      ENDCLASS.
    3. Check Inheritance: If your class is inheriting from another class, ensure that you are calling the superclass constructor in your subclass constructor:

      METHOD constructor.
        SUPER->constructor( ). " Call to superclass constructor
        " Additional initialization code
      ENDMETHOD.
    4. Avoid Instantiating Abstract Classes: If you are trying to instantiate an abstract class, make sure to create a concrete subclass that implements the abstract methods and can be instantiated.

    Related Information:

    • ABAP Documentation: Refer to the official SAP documentation for more details on object-oriented programming in ABAP, constructors, destructors, and class definitions.
    • Debugging: Use the ABAP debugger to trace where the error occurs and ensure that the class is being instantiated correctly.
    • Best Practices: Always define constructors and destructors when creating classes that manage resources or require initialization to avoid runtime errors.

    By following these guidelines, you should be able to resolve the OO086 error and ensure that your ABAP classes are properly defined.

    • Do you have any question about this error?


      Upgrade now to chat with this error.


Instant HelpGet instant SAP help. Sign up for our Free Essentials Plan.


Related SAP Error Messages

Click the links below to see the following related messages:

Click on this link to search all SAP messages.


Rating
ERPlingo simplifies finding the accurate answers to SAP message errors. I now use every week. A must have tool for anyone working with SAP! Highly recommended!
Rate 1
Kent Bettisworth
Executive SAP Consultant