先看效果,在输入框先来一段《赤壁赋》
然后点击 ‘保存输出’按钮,就能把输入内容从表里读取并输出来
源代码:
*&---------------------------------------------------------------------*
*& Report ZCYCLE060
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT zcycle060.
DATA: ok_code TYPE sy-ucomm.
CONSTANTS: gc_text_line_length TYPE i VALUE 72.
TYPES: text_table_type(gc_text_line_length) TYPE c OCCURS 0.
DATA: gv_splitter TYPE REF TO cl_gui_easy_splitter_container.
DATA: gv_custom_container TYPE REF TO cl_gui_custom_container.
DATA: gv_text_editor TYPE REF TO cl_gui_textedit.
DATA: lt_text_table TYPE text_table_type,
ls_text_table_wa(gc_text_line_length) TYPE c,
gv_xthead_updkz TYPE i.
CALL SCREEN 100.
MODULE splitter_control_vorbereiten OUTPUT.
IF gv_splitter IS INITIAL.
CREATE OBJECT gv_custom_container
EXPORTING
container_name = 'SPLITTER_CONTAINER'.
CREATE OBJECT gv_splitter
EXPORTING
parent = gv_custom_container
orientation = 1 "方向: 0 = 垂直 , 1 = 水平
sash_position = 39.
ENDIF.
IF gv_text_editor IS INITIAL.
CREATE OBJECT gv_text_editor
EXPORTING
parent = gv_splitter->bottom_right_container
* wordwrap_mode = cl_gui_textedit=>wordwrap_at_windowborder
wordwrap_to_linebreak_mode = cl_gui_textedit=>false "自动换行模式关闭
"wordwrap_to_linebreak_mode = cl_gui_textedit=>true
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
gui_type_not_supported = 5.
"CALL METHOD gv_text_editor->set_readonly_mode EXPORTING readonly_mode = cl_gui_textedit=>true. "输入框只读模式开启
CALL METHOD gv_text_editor->set_readonly_mode EXPORTING readonly_mode = cl_gui_textedit=>false. "输入框只读模式关闭
ENDIF.
ENDMODULE. " SPLITTER_CONTROL_VORBEREITEN OUTPUT
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
SET PF-STATUS 'ZCYCLE'.
* SET TITLEBAR 'xxx'.
ENDMODULE.
*&---------------------------------------------------------------------*
*& Module EXIT INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE exit INPUT.
LEAVE TO SCREEN 0.
ENDMODULE.
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
DATA t_tdline1 TYPE TABLE OF standard .
* Texttabelle aus Control abholen
CASE ok_code.
WHEN 'ZSAVE'.
CALL METHOD gv_text_editor->get_text_as_stream "取屏幕上输入的文本存到 lt_text_table
IMPORTING
text = lt_text_table
is_modified = gv_xthead_updkz
EXCEPTIONS
error_dp = 1
error_cntl_call_method = 2
OTHERS = 3.
IF sy-subrc = 0.
cl_demo_output=>write( lt_text_table[] ). "定义哪些东西需要输出,可以是表,也可以是字段
cl_demo_output=>display( ). "一次性把 write进来的元素 输出
ENDIF.
* CALL METHOD gv_text_editor->get_text_as_r3table
* IMPORTING
* table = t_tdline1.
* IF sy-subrc = 0.
*
* ENDIF.
ENDCASE.
ENDMODULE.
100屏幕设计
去SE80输入函数组 SLVC_FULLSCREEN 拉取标准ALV图标过来
做一丢丢改造
这里主要是用于程序退出功能
到这里就完成了。
程序会把屏幕上输入的文字传到内表 lt_text_table 里去
所以就是获取到屏幕上输入的文本框内容了,如果要做其它功能,就可以往下继续做了