Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

save and read data on TEXTEDIT

Dear all.

i have not used this class for textedit.

i've looked this article via this forum. but i am not clear on it.

what type do i use for this field be applied for textedit? string? or rawstring?

please correct my source to save data from textedit into ztable and read data from field of ztable.

save and read,,, please help me.

1. what type do i have to use for textedit? maybe string?

2. how to save data to ztable from textedit.

3. how to read data from ztable and then put on textedit?.

&----


*& Report Z_TEXTEDIT01

*&

&----


*&

*&

&----


report z_textedit01.

data : g_editor type ref to cl_gui_textedit,

g_editor_container type ref to cl_gui_custom_container,

g_ok_code like sy-ucomm,

ok_code like sy-ucomm,

g_repid like sy-repid.

types : begin of mytable_line,

line(256) type c,

end of mytable_line.

data : g_mytable type table of mytable_line.

start-of-selection.

call screen 100.

&----


*& Module START OUTPUT

&----


  • text

----


module start output.

if g_editor is initial.

set pf-status 'MAIN100'.

g_repid = sy-repid.

create object g_editor_container

exporting

container_name = 'TEXTEDITOR1'.

create object g_editor

exporting

parent = g_editor_container

wordwrap_mode = cl_gui_textedit=>wordwrap_at_windowborder.

endif.

endmodule. " START OUTPUT

&----


*& Module EXIT INPUT

&----


  • text

----


module exit input.

*Destroy Control.

if not g_editor is initial.

call method g_editor->free.

*free abap object also

free g_editor.

endif.

*destroy container

if not g_editor_container is initial.

call method g_editor_container->free.

*free abap object also

free g_editor_container.

endif.

*finally flush

call method cl_gui_cfw=>flush.

leave program.

endmodule. " EXIT INPUT

&----


*& Module USER_COMMAND_0100 INPUT

&----


  • text

----


module user_command_0100 input.

g_ok_code = ok_code.

clear ok_code.

case g_ok_code.

when 'CHAN'.

perform change_status.

when 'PROT'.

perform prot_status.

when 'INDT'.

perform indt_status.

when 'FIND'.

perform find_status.

when 'HIGH'.

perform high_status.

when 'DELE'.

perform dele_status.

when 'TOOL'.

perform tool_status.

endcase.

endmodule. " USER_COMMAND_0100 INPUT

&----


*& Form change_status

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form change_status .

data : readonly type i.

readonly = g_editor->m_readonly_mode.

if readonly <> g_editor->false.

readonly = g_editor->false.

else.

readonly = g_editor->true.

endif.

call method g_editor->set_readonly_mode

exporting

readonly_mode = readonly.

endform. " read_status

&----


*& Form prot_status

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form prot_status .

data g_mytable type table of mytable_line.

data n type i value 2.

call method g_editor->get_selected_text_as_r3table

importing

table = g_mytable.

describe table g_mytable lines n.

call method g_editor->protect_lines

exporting

from_line = 1

to_line = n

protect_mode = 1

enable_editing_protected_text = 0.

endform. " prot_status

&----


*& Form indt_status

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form indt_status .

data g_mytable type table of mytable_line.

data n type i.

call method g_editor->get_selected_text_as_r3table

importing

table = g_mytable.

describe table g_mytable lines n.

call method g_editor->indent_lines

exporting

from_line = 1

to_line = n

enable_editing_protected_text = 1.

endform. " indt_status

&----


*& Form find_status

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form find_status.

  • data g_mytable type table of mytable_line.

*

  • call method g_editor->find_and_select_text

  • exporting

  • search_string = search_string

  • case_sensitive_mode = 0

  • whole_word_mode = 1

  • changing

  • string_found = found.

endform. " find_status

&----


*& Form high_status

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form high_status .

data g_mytable type table of mytable_line.

data n type i.

call method g_editor->get_selected_text_as_r3table

importing

table = g_mytable.

describe table g_mytable lines n.

call method g_editor->highlight_lines

exporting

from_line = 0

to_line = n

highlight_mode = 1.

endform. " high_status

&----


*& Form dele_status

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form dele_status .

call method g_editor->delete_text.

endform. " dele_status

&----


*& Form tool_status

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form tool_status .

data : toolbar type i,

statusbar type i.

toolbar = g_editor->m_toolbar_mode.

statusbar = g_editor->m_statusbar_mode.

if ( ( toolbar <> g_editor->false ) or ( statusbar <> g_editor->false ) ).

toolbar = statusbar = g_editor->false.

else.

toolbar = statusbar = g_editor->true.

endif.

call method g_editor->set_toolbar_mode

exporting

toolbar_mode = toolbar.

call method g_editor->set_statusbar_mode

exporting

statusbar_mode = statusbar.

endform. " tool_status

Tags:
Former Member
Not what you were looking for? View more on this topic or Ask a question