2006 Mar 21 6:00 PM
Hi experts,
Is there any way to limit the quantity of lines, using cl_gui_textedit ?
Thanks
Alexandre Nogueira
2006 Mar 21 6:09 PM
Sure, check the example program. Notice in the constructor of the text editor control, we are forcing that the line size is 72 and that the character count is 216. This means that you are allow 3 lines of 72 characters per line, no more.
report zrich_0001 .
data:
dockingleft type ref to cl_gui_docking_container,
text_editor type ref to cl_gui_textedit,
repid type syrepid.
data: textlines type table of tline-tdline,
wa_text type tline-tdline.
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.
<b> create object text_editor
exporting
WORDWRAP_MODE = 2
max_number_chars = 216
wordwrap_position = 72
parent = dockingleft.</b>
start-of-selection.
call method text_editor->get_text_as_r3table
importing
table = textlines
exceptions
others = 1.
loop at textlines into wa_text.
write:/ wa_text.
endloop.
Regards,
RIch Heilman
2006 Mar 21 6:31 PM
Ok Rich,
But, as this example, I can have 216 lines with 1 caracter. It's the problem.
Alexandre Nogueira
2006 Mar 21 6:41 PM
I see. Would it be ok to check the number of lines and give an error message?
report zrich_0001 .
data:
dockingleft type ref to cl_gui_docking_container,
text_editor type ref to cl_gui_textedit,
repid type syrepid.
data: textlines type table of tline-tdline,
wa_text type tline-tdline.
data: lines 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
* wordwrap_mode = 2
* max_number_chars = 216
* wordwrap_position = 72
parent = dockingleft.
<b>at selection-screen.
check sy-ucomm = 'ONLI'.
call method text_editor->get_text_as_r3table
importing
table = textlines
exceptions
others = 1.
describe table textlines lines lines.
if lines > 2.
message e001(00) with 'The line limit is two'.
endif.</b>
start-of-selection.
loop at textlines into wa_text.
write:/ wa_text.
endloop.
Regards,
Rich Heilman
2006 Mar 21 6:44 PM
Yeap, it's a good way, thanks!
Alexandre Nogueira