Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Using the METHOD textnote_editor->limit_text

Former Member
0 Kudos

Hi guys,

I'm trying to use the method "textnote_editor->limit_text" to limit the rows in the text box, but there is an error message that this method is "Protected or Private". How can I use it or limit the rows in my text box ?

Best Regards.

Carlos Lima.

1 ACCEPTED SOLUTION

Clemenss
Active Contributor
0 Kudos

Hi Carlos,

if you are talking about SAP standard class CL_GUI_TEXTEDIT, then you could create a new class INHERITED FROM CL_GUI_TEXTEDIT. Then you can use the protected method LIMIT_TEXT inside any new method.

CLASS LCL_TEXTEDIT DEFINITION INHERITING FROM CL_GUI_TEXTEDIT.
PUBLIC SECTION.
  methods MY_LIMIT_TEXT
    importing
      MAX_NUMBER_CHARS type I
    exceptions
      ERROR_CNTL_CALL_METHOD .

ENDCLASS.
CLASS LCL_TEXTEDIT IMPLEMENTATION.
  method my_limit_text.
    limit_text( MAX_NUMBER_CHARS ).
  endmethod.
ENDCLASS.

Now you have a public method. But as you do not describe your questions details, i have doubts that this solution works for you.

Regards,

Clemens

3 REPLIES 3

Clemenss
Active Contributor
0 Kudos

Hi Carlos,

if you are talking about SAP standard class CL_GUI_TEXTEDIT, then you could create a new class INHERITED FROM CL_GUI_TEXTEDIT. Then you can use the protected method LIMIT_TEXT inside any new method.

CLASS LCL_TEXTEDIT DEFINITION INHERITING FROM CL_GUI_TEXTEDIT.
PUBLIC SECTION.
  methods MY_LIMIT_TEXT
    importing
      MAX_NUMBER_CHARS type I
    exceptions
      ERROR_CNTL_CALL_METHOD .

ENDCLASS.
CLASS LCL_TEXTEDIT IMPLEMENTATION.
  method my_limit_text.
    limit_text( MAX_NUMBER_CHARS ).
  endmethod.
ENDCLASS.

Now you have a public method. But as you do not describe your questions details, i have doubts that this solution works for you.

Regards,

Clemens

Former Member
0 Kudos

Hi Clemens how are you,

thanks for your help,

well, my problem continues, I declareted the public section like you sent-me and the error is the same, the error message is the Method LIMET_TEXT is private.

"Access to protected method "LIMIT_TEXT" is not allowed."

My problem is, I made a copy of standard FM "TXW_TEXTNOTE_EDIT" and I'm changing some declarations to try to block the rows in the text box, the user should not save a long text in the process, only the resume, thats why I need to block the rows and I tried to change some methods but nothing.

What I can do to do it on this FM ?.

Best Regards.

Carlos Lima.

Clemenss
Active Contributor
0 Kudos

Hi Carlos,

what ever you did.

I just copied my code to a test program - no syntax error. That means I can use method MY_LIMIT_TEXT.

BUT: TXW_TEXTNOTE_EDIT can not save a text.

You can count the characters in the table returned and issue an error message instead of saving if there are too many.


* before saving...
field-symbols:
 <TXW_NOTE> type TXW_NOTE.
data:
  lv_charcount type sy-tleng.
loop at lT_TXWNOTE assigning <TXW_NOTE>,
   lv_charcount  =  lv_charcount  + strlen( <TXW_NOTE>-LINE ).
endloop.
if  lv_charcount  > lv_maxchars.
... MESSAGE Ennn(ZXY) with ...
endif.

Something like that.

Regards,

Clemens