‎2009 May 11 6:58 AM
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
‎2009 May 11 8:36 AM
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
‎2009 May 12 7:43 AM
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
‎2009 May 12 8:36 AM
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
‎2009 May 12 8:41 AM
...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
‎2009 May 12 9:25 AM
‎2009 May 12 9:39 AM
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
‎2009 May 14 9:11 AM
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.
‎2009 May 15 10:31 AM
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=>flushafter 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.
‎2009 May 15 12:29 PM
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
‎2011 Jun 12 8:48 AM
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.
‎2011 Jun 22 10:03 AM
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...!!!!
‎2013 Nov 06 11:18 AM
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.