08-29-2006 12:43 AM
Hello All,
I am using <b>'set_text_as_r3table'</b> in change mode to display/edit long text of notification. Now, when the text is entered I need to get the modified text and update the notification long text. Can anybody tell me how to achieve this?
I was thinking of using method '<b>get_text_as_r3table</b>' to get the data and use SAVE_TEXT to update long text. But,the mehod <b>'get_text_as_r3table'</b> retireves everything on text editor, not just the modified text.
Any Suggestions??
And, Is there any alternative (method) to the FM <b>SAVE_TEXT</b>?
Is there any way to open text editor in change mode and existing text grayed out?
08-29-2006 1:08 AM
Please see the example program. THis should solve your problem.
report zrich_0001.
data:
dockingleft type ref to cl_gui_docking_container,
text_editor type ref to cl_gui_textedit,
repid type syrepid.
data: begin of header.
include structure thead.
data: end of header.
data: begin of lines occurs 0.
include structure tline.
data: end of lines.
data: textlines type table of tline-tdline,
wa_text type tline-tdline.
data: totlines type i.
data: start_line type i.
parameters: p_check.
at selection-screen output.
repid = sy-repid.
create object dockingleft
exporting repid = repid
dynnr = sy-dynnr
side = dockingleft->dock_at_left
extension = 1070.
create object text_editor
exporting
parent = dockingleft.
clear lines. refresh lines.
call function 'READ_TEXT'
exporting
id = 'Z001'
language = sy-langu
name = '999999'
object = 'ZPT_DET'
tables
lines = lines.
clear wa_text. refresh textlines.
loop at lines .
wa_text = lines-tdline .
append wa_text to textlines.
endloop.
* Add a blank like to start adding new text
clear wa_text. append wa_text to textlines.
call method text_editor->set_text_as_r3table
exporting
table = textlines
exceptions
others = 1.
describe table textlines lines totlines.
start_line = totlines.
* Protect only text lines, not the added one
totlines = totlines - 1.
call method text_editor->protect_lines
exporting
from_line = 1
* PROTECT_MODE = TRUE
to_line = totlines
* ENABLE_EDITING_PROTECTED_TEXT = false
exceptions
error_cntl_call_method = 1
invalid_parameter = 2
others = 3.
call method text_editor->GO_TO_LINE( start_line ).
start-of-selection.
call method text_editor->get_text_as_r3table
importing
table = textlines
exceptions
others = 1.
* Set SAPscript Header
clear header.
header-tdname = '999999' . "Name
header-tdobject = 'ZPT_DET'. "Object
header-tdid = 'Z001'. "Id
header-tdspras = sy-langu.
* Move text from container to function module table
clear lines. refresh lines.
loop at textlines into wa_text .
lines-tdline = wa_text.
append lines .
endloop.
call function 'SAVE_TEXT'
exporting
client = sy-mandt
header = header
tables
lines = lines
exceptions
id = 1
language = 2
name = 3
object = 4
others = 5.
Regards,
Rich Heilman
08-22-2007 9:25 AM
Hi Rich,
This is very good example! Thanks for it!
I use a similar code to protect the existing lines from editing and to keep the opportunity for adding new lines.
BUT a strange problem occurs - when I call the function that calls
call method text_editor->protect_lines
exporting
from_line = 1
to_line = totlines
exceptions
error_cntl_call_method = 1
invalid_parameter = 2
others = 3.
for the first time it protects only the first "totlines" characters form the text. The next times it is called it always protects the exact number of lines set in "totlines".
Do you have any idea why does it happen?
Thanks in advance!
BR,
Peter