Skip to Content
author's profile photo Former Member
Former Member

Initializing Instance Attributes of a Class

Dear Experts,

I want to know how can i initialize the instance attributes of a ZClass?

I have copied the standard class "CL_WB_MIME_REPOSITORY" into my ZClass as "ZCL_WB_MIME_REPOSITORY".

In the standard class we have private instance attributes as "HTML_VIEWER" and "KW_EXPLORER" and these gets initialized

automatically when i run the standard tcode SE80.

Now, when i am running my ZTcode having my ZClass, these attributes are not initialized and are NULL.

Can you please tell me how should i initialize these attributes in my ZClass and where should i write the code and what will be that code?

Thanks a lot,


Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Posted on Oct 08, 2010 at 09:53 AM

    Hello Praveen

    Instance attributes are initialized within the CONSTRUCTOR method.

    Static attributes can be set within the CLASS_CONSTRUCTOR method.

    *       METHOD constructor                                            *
    * stores the new object instance in class variable
    METHOD constructor .
      cl_wb_mime_repository=>instance = me.
    ENDMETHOD.                    "constructor of CL_WB_MIME_REPOSITORY

    The attribute HTML_VIEWER is instantiated in method TOGGLE_PREVIEW:

    * Make sure HTML viewer control is created
      IF me->html_viewer IS INITIAL.
        DATA: l_html_container TYPE REF TO cl_gui_container.
    * Get container for the HTML Viewer
        CALL METHOD me->splitter->get_container
            row       = wbmr_c_splitter_row_preview
            column    = 1
            container = l_html_container
            OTHERS    = 1.
        IF sy-subrc <> 0.
          MESSAGE i002(mimes)
            RAISING error_occured.
    *   Fehler im Control Framework
    * Create HTML Viewer Control



    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Oct 08, 2010 at 10:03 AM


    The attribute "KW_EXPLORER" is being initialised in the method PROCESS_WB_REQUEST of the associated interface IF_WB_PROGRAM. See this:

    IF me->kw_explorer IS INITIAL.
            CALL METHOD me->create_kw_explorer
                i_window_id   = p_window_id
                name_space    = l_name_space
                application   = l_application
                error_occured = 1.

    Similarly check how the attribute "HTML_VIEWER" is being instantiated.

    Although i've not worked with the class CL_WB_MIME_REPOSITORY, what i understand is the class exposes itself to the external user via the associated IFs. (Most of the methods of the class are PRIVATE!!)



    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Suhas Saha

      Hi Suhas,

      Thanks for the reply.

      I did read through your eariler post and understood where "HTML_VIEWER" and "KW_EXPLORER" are being initialized.

      All of this logic for initializing the objects is based on the interface "IF_WB_PROGRAM~WB_PROGRAM".

      Now when i am using the same interface in my ZClass, this interface is coming as NULL, while this comes auto initialized for the standard class "CL_WB_MIME_REPOSITORY" with the object value = "".

      Can you please tell me how should i update my ZClass so that this interface will not be NULL?



  • Posted on Oct 11, 2010 at 02:12 PM

    Looks like you have copied the class CL_WB_MIME_REPOSITORY to your Z class, but didn't change the use of all Static Variables of the class CL_WB_MIME_REPOSITORY. In your Z class search the string CL_WB_MIME_REPOSITORY. You may find occurrence where your Z class is still using the static variables of the CL_WB_MIME_REPOSITORY. If you may want to replace them and try again!


    Naimesh Patel

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.