生产订单屏幕增强,后续:(文本框)
首先,创建一个定制控制,编辑名称,大小。
接下来将会用到类处理:CL_GUI_TEXTEDIT
![定制控制](https://i-blog.csdnimg.cn/blog_migrate/4960c8b489af1fc50e712474b40504c4.jpeg#pic_center)
然后,在逻辑流里面添加两个module
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/1b6cf81dcc2bebc23aafc893aac0221a.png#pic_center)
详细逻辑:
输出:
----------------------------------------------------------------------
***INCLUDE ZXCO1O02 .
----------------------------------------------------------------------
&---------------------------------------------------------------------
*& Module EDITOR_CONTAINER OUTPUT
&---------------------------------------------------------------------
-
text
----------------------------------------------------------------------
MODULE editor_container OUTPUT.
DATA: line_length TYPE i VALUE 48, "输入框的长度
editor_container TYPE REF TO cl_gui_custom_container,
text_editor TYPE REF TO cl_gui_textedit,
text TYPE string.
TYPES:BEGIN OF ty_text,
line(255) TYPE c,
END OF ty_text.
DATA: lt_text TYPE TABLE OF ty_text,
ls_text TYPE ty_text.
"创建文本域
CREATE OBJECT editor_container
EXPORTING
container_name = ‘COCI_AUFK-ZBZ’
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5.
CREATE OBJECT text_editor
EXPORTING
parent = editor_container
wordwrap_mode = cl_gui_textedit=>wordwrap_at_fixed_position
wordwrap_position = line_length
wordwrap_to_linebreak_mode = cl_gui_textedit=>true.
*You can hide the toolbar and as well as status bar for the text editor control.
"工具栏 0 不可见
CALL METHOD text_editor->set_toolbar_mode
EXPORTING
toolbar_mode = cl_gui_textedit=>false.
"状态栏
CALL METHOD text_editor->set_statusbar_mode
EXPORTING
statusbar_mode = cl_gui_textedit=>false.
"只读状态
IF SY-TCODE = ‘CO03’.
CALL METHOD text_editor->set_readonly_mode
EXPORTING
readonly_mode = 1
EXCEPTIONS
error_cntl_call_method = 1
invalid_parameter = 2
OTHERS = 3.
ENDIF.
"文本处理
CLEAR:ls_text,lt_text,lt_text[].
ls_text-line = coci_aufk-zbz.
APPEND ls_text TO lt_text.
"读取文本编辑器内容 - 文本流
CALL METHOD text_editor->set_text_as_stream
EXPORTING
text = lt_text.
ENDMODULE. " EDITOR_CONTAINER OUTPUT
输入:
----------------------------------------------------------------------
***INCLUDE ZXCO1I01 .
----------------------------------------------------------------------
&---------------------------------------------------------------------
*& Module USER_COMMAND_0100 INPUT
&---------------------------------------------------------------------
-
text
----------------------------------------------------------------------
MODULE user_command_0100 INPUT.
"获取文本框中的内容
CALL METHOD text_editor->get_textstream
-
* EXPORTING
-
* only_when_modified = cl_gui_textedit=>true IMPORTING text = text
-
* is_modified = EXCEPTIONS error_cntl_call_method = 1 not_supported_by_gui = 2 OTHERS = 3. IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF. CALL METHOD cl_gui_cfw=>flush EXCEPTIONS cntl_system_error = 1 cntl_error = 2 OTHERS = 3. coci_aufk-zbz = text.
-
MESSAGE text TYPE 'I'.
ENDMODULE. " USER_COMMAND_0100 INPUT