ABAP中輸入框都是一行一行的,利用cl_gui_textedit和cl_gui_custom_container可以創建類似于記事本輸入的效果。 首先,創建屏幕,畫個Customer control,然後加上退出,保存的按鈕。
代码语言:javascript复制CONSTANTS:
line_length TYPE i VALUE 254.
DATA: ok_code LIKE sy-ucomm.
types: begin of istr,
line(line_length) type c,
end of istr.
DATA:itab type table of istr,
custom_container TYPE REF TO cl_gui_custom_container,
editor TYPE REF TO cl_gui_textedit,
repid LIKE sy-repid.
field-symbols: <fs>.
START-OF-SELECTION.
SET SCREEN '100'.
*---------------------------------------------------------------------*
* MODULE USER_COMMAND_0100 INPUT *
*---------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
CASE ok_code.
WHEN 'EXIT'.
LEAVE TO SCREEN 0.
when 'SAVE'.
//獲取輸入框中的值,把每一行的值按行存進去
call method editor->get_text_as_r3table
importing
table = itab.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
set pf-status '101'.
IF editor IS INITIAL.
repid = sy-repid.
CREATE OBJECT custom_container
EXPORTING
container_name = 'MYCONTAINER1'.
//把容器和要創建的textedit鏈接起來,就是讓textedit顯示在容器中
CREATE OBJECT editor
EXPORTING
wordwrap_mode =
cl_gui_textedit=>wordwrap_at_fixed_position
wordwrap_position = line_length
wordwrap_to_linebreak_mode = cl_gui_textedit=>true
parent = custom_container.
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
運行成功:
點擊保存可以把內容保存在創建的內表itab中
這個可以在發送郵件時使用。