cancel
Showing results for 
Search instead for 
Did you mean: 

how to use protected method of a class in application

Former Member
0 Kudos

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.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi,

My requirement is i have to limit the no of text entered in a text edit control.

Thanks

Praba

Former Member
0 Kudos

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.

Answers (5)

Answers (5)

Former Member
0 Kudos

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.....

Former Member
0 Kudos

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.

abdul_hakim
Active Contributor
0 Kudos

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

rainer_hbenthal
Active Contributor
0 Kudos

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

Former Member
0 Kudos

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