Skip to Content
avatar image
Former Member

how to use protected method of a class in application

Hi,

will u please tell me how to use protected method of class in application. (class:cl_gui_textcontrol, method:limit_text)

Thanks in advance,

Praba.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

6 Answers

  • Best Answer
    avatar image
    Former Member
    Apr 06, 2006 at 11:56 AM

    Hi,

    I donot know the feasibility here but in such cases u can inherit that class into a custom class where u can write ur own method and in that method u can call the protected method.

    Please let us know the requirement.

    Regards,

    ND

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi Prabha,

      You can set the maximum number of characters in a textedit control in the CREATE OBJECT statement itself.

      Just see the first parameter in the method . I mean MAX_NUMBER_CHARS. Just set that value to the required number.

      Eg:

      data: edit type ref to CL_GUI_TEXTEDIT.

      create object edit

      exporting

      MAX_NUMBER_CHARS = 10

      • STYLE = 0

      • WORDWRAP_MODE = WORDWRAP_AT_WINDOWBORDER

      • WORDWRAP_POSITION = -1

      • WORDWRAP_TO_LINEBREAK_MODE = FALSE

      • FILEDROP_MODE = DROPFILE_EVENT_OFF

      parent = OBJ_CUSTOM_CONTAINER

      • LIFETIME =

      • NAME =

      EXCEPTIONS

      ERROR_CNTL_CREATE = 1

      ERROR_CNTL_INIT = 2

      ERROR_CNTL_LINK = 3

      ERROR_DP_CREATE = 4

      GUI_TYPE_NOT_SUPPORTED = 5

      others = 6

      .

      IF sy-subrc <> 0.

      • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

      • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

      ENDIF.

      In this case, the max: number of characters will be set to 10.

      I hope your query is solved.

      Regards,

      SP.

  • avatar image
    Former Member
    Apr 06, 2006 at 11:59 AM

    Prabhavathi,

    The PROTECTED method cannot be access inside a program. That is why it has been defined as PROTECTED.

    If you want to use that, you will define a SUB Class for that and use it inside that.

    Regards,

    Ravi

    Note : Please mark the helpful answers

    Add comment
    10|10000 characters needed characters exceeded

  • Apr 06, 2006 at 12:04 PM

    hi

    u can call ur protected method from ur class or its subclass.

    if you wanna call from outside that is from a other class then declare it in <b>PUBLIC SECTION</b>.

    Cheers,

    Abdul Hakim

    Add comment
    10|10000 characters needed characters exceeded

  • Apr 06, 2006 at 12:02 PM

    make it a public method. protected methods are not callable from outside. Thats why they are protected.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Apr 06, 2006 at 12:09 PM

    Hi Prabha,

    Which version you are using? I don't think there is a class called CL_GUI_TEXTCONTROL till 4.7 Enterprise Edition.

    So I suppose you are talking about CL_GUI_TEXTEDIT.

    Protected components of a class can be accessed by instance of that class and all the subclasses of that class. So I think you have to create a new class whose superclass is CL_GUI_TEXTEDIT.

    Then make the instance of the newly created class and access the protected members of the class.

    Regards,

    Sylendra.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 27, 2006 at 04:34 AM

    Hi Friends,

    Can u please explain what is the use of the class CL_GUI_TEXTEDIT. I tried to find the doucmentation of this class. But I could not succeed. If anybody know it please explain.....

    Add comment
    10|10000 characters needed characters exceeded