Application Development and Automation 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: 
Read only

Clear Text Editor Content

Former Member
4,495

Hello All

In my program I have defined a custom control in a screen wherein a text editor has been called.

My requirement is that in the pbo of that screen the content of the text editor area should get cleared. I am unable to do so.

I have already used method "delete_text" before calling the function "READ_TEXT".

Kindly help.

Edited by: Avishek Bhattacharyya on May 11, 2009 7:58 AM

12 REPLIES 12
Read only

MarcinPciak
Active Contributor
0 Likes
2,648

Try using FM DELETE_TEXT instead of a method.

Please refer [Text Editor Insert , Change , Display |https://www.sdn.sap.com/irj/scn/wiki?path=/display/abap/textEditorInsert%252CChange%252CDisplay].

Regards

Marcin

Read only

0 Likes
2,648

Hello Marcin

My requirement is that I want to clear the text editor area before the screen is called ........ because it is currently retaining the text in that area which was entered previously ........... I don't want to delete the text corresponding to the object parmanently .......

Kindly help

Avishek

Read only

0 Likes
2,648

Hi,

You can use the method 'set_text_as_r3table'.

Pass the internal table as blank.

This would give a cleared text area.

Regards,

Ankur Parab

Read only

0 Likes
2,648

...or use method SET_TEXTSTREAM passing blank string. This is has one advantage over the one mentioned by Ankur's. It is only passing a string, not an entire table.

Regards

Marcin

Read only

0 Likes
2,648

Still not working .......

Kindly help

Avishek

Read only

0 Likes
2,648

Ok try this way:


data: max_lines TYPE i,.

"get line count
obj->get_line_count( IMPORTING lines = max_lines ).

"select all
obj->select_lines( from_line = 0 to_line = max_lines ).

"replace it
obj->SET_SELECTED_TEXT_AS_R3TABLE( IMPORTING table = blank_table ).

Regards

Marcin

Read only

0 Likes
2,648

Hello Avishek / Marcin,

We are also facing the exact issue. The text editor is not getting refreshed/cleared and it still shows the last text content. We tried the above solutions but our issue is still existing.

This is what we are doing :

IN PBO Module :

REFRESH: text_tab[].

CALL METHOD editor->delete_text( ).

CALL METHOD editor->set_text_as_stream

EXPORTING

text = text_tab[]. " this is a blank table intially

  • convert itf text to stream text

CALL FUNCTION 'CONVERT_ITF_TO_STREAM_TEXT'

TABLES

itf_text = gt_text[]

text_stream = text_tab[].

CALL METHOD editor->set_text_as_stream

EXPORTING

text = text_tab[]. " this has the text which we want to display in the text editor

IN PAI module :

CALL METHOD editor->get_text_as_stream

IMPORTING

text = text_tab[].

CALL FUNCTION 'CONVERT_STREAM_TO_ITF_TEXT'

TABLES

text_stream = text_tab"[]

itf_text = gt_text[].

CALL METHOD cl_gui_cfw=>flush

EXCEPTIONS

OTHERS = 1.

Kindly help ,

Anand.

Read only

0 Likes
2,648

Hello Anand

The main problem with my code was that I was creating the container and editor object each and every time the PBO of the screen was being executed ............. I rectified it by setting a flag which was set to 'X' once the objects were declared and the code of creating the objects would only be executed in case of the flag being not equal to 'X'. Thereby creating the objects only once for that entire code run.

I have also used the method

CALL METHOD cl_gui_cfw=>flush

after function module 'READ_TEXT' and the method

CALL METHOD g_editor->get_text_as_r3table

.

Hope this will solve your problem.

Revert back for further issues.

Avishek.

Read only

0 Likes
2,648

Hello Avishek,

Thanks for your help. Even i was creating the container and editor object each and every time the PBO of the screen was being executed ...once i rectified it ,it was working fine.

And it works with CALL METHOD editor->set_text_as_stream too.

Thanks again for your valuable inputs.

Regards,

Anand Ajitsaria

Read only

0 Likes
2,648

Hi

We are also facing the exact issue. The text editor is not getting refreshed/cleared and it still shows the last text content.

The below is the code that is being implemented:

PLease help me to solve my problem... THnaks in advance!

IN PBO:

IF init IS INITIAL.

init = 'X'.

CREATE OBJECT:

container EXPORTING container_name = 'TEXTEDIT',

editor EXPORTING parent = container,

handle.

event-eventid = cl_gui_textedit=>event_f1.

event-appl_event = 'X'. "system event

APPEND event TO event_tab.

event-eventid = cl_gui_textedit=>event_f4.

event-appl_event = 'X'. "application event

APPEND event TO event_tab.

CALL METHOD: editor->set_registered_events

EXPORTING events = event_tab.

SET HANDLER handle->handle_f1

handle->handle_f4 FOR editor.

it_text1[] = it_text[].

CLEAR it_text[].

CALL METHOD editor->set_text_as_stream

EXPORTING

text = it_text1.

CLEAR : lv_lines , lv_lines_to.

DESCRIBE TABLE it_text1 LINES lv_lines.

lv_lines_to = lv_lines + 1.

ENDIF.

IN PAI:

IF NOT editor IS INITIAL.

CALL METHOD editor->get_text_as_stream

IMPORTING

text = it_text1.

CALL METHOD editor->free

EXCEPTIONS

OTHERS = 1.

IF sy-subrc NE 0.

  • add your handling

ENDIF.

  • free ABAP object also

FREE editor.

Read only

vineet_nayan
Discoverer
0 Likes
2,648

Hi,

I have created a custom container with a text editor . The problem is i want to enable or disable a pushbutton based on the content in the text editor.

If the editor is blank, the pushbutton should be disabled and as one starts enetering the text, it should become active.

Kindly Help...!!!!

Read only

hiriyappa_myageri
Participant
0 Likes
2,648

Hi Avishek,

data:goto_notes TYPE REF TO cl_gui_custom_container,

      gnote TYPE REF TO cl_gui_textedit.

In PBO Event You Can use like this it will clear text.

if not goto_notes is initial.

     call method goto_notes->free

       exceptions

         others = 1.

     if sy-subrc <> 0.

     endif.

     free goto_notes.

   endif.

  if not Gnote is initial.

     call method Gnote->free

       exceptions

         others = 1.

     if sy-subrc <> 0.

     endif.

     free Gnote .

   endif.

   call method cl_gui_cfw=>flush

     exceptions

       others = 1.

   if sy-subrc ne 0.

   endif.

Regards,

Hiriyappa.