REPORT demo_custom_control .

* Declarations *****************************************************

CLASS event_handler DEFINITION.
PUBLIC SECTION.
METHODS: handle_f1 FOR EVENT f1 OF cl_gui_textedit
IMPORTING sender,
handle_f4 FOR EVENT f4 OF cl_gui_textedit
IMPORTING sender.
ENDCLASS. DATA: ok_code LIKE sy-ucomm,
save_ok LIKE sy-ucomm. DATA: init,
container TYPE REF TO cl_gui_custom_container,
editor TYPE REF TO cl_gui_textedit. DATA: event_tab TYPE cntl_simple_events,
event TYPE cntl_simple_event. DATA: line(256) TYPE c,
text_tab LIKE STANDARD TABLE OF line,
field LIKE line. DATA handle TYPE REF TO event_handler. * Reporting Events *************************************************** START-OF-SELECTION. line = 'First line in TextEditControl'.
APPEND line TO text_tab.
line = '--------------------------------------------------'.
APPEND line TO text_tab.
line = '...'.
APPEND line TO text_tab. CALL SCREEN 100. * Dialog Modules ***************************************************** MODULE status_0100 OUTPUT.
SET PF-STATUS 'SCREEN_100'.
IF init is initial.
init = 'X'.
CREATE OBJECT: container EXPORTING container_name = 'TEXTEDIT',
editor EXPORTING parent = container,
handle.
event-eventid = cl_gui_textedit=>event_f1.
event-appl_event = ' '. "system event
APPEND event TO event_tab.
event-eventid = cl_gui_textedit=>event_f4.
event-appl_event = 'X'. "application event
APPEND event TO event_tab.
editor->set_registered_events(
EXPORTING events = event_tab ).
SET HANDLER handle->handle_f1
handle->handle_f4 FOR editor.
ENDIF.
editor->set_text_as_stream( EXPORTING text = text_tab ).
ENDMODULE. MODULE cancel INPUT.
LEAVE PROGRAM.
ENDMODULE. MODULE user_command_0100 INPUT.
save_ok = ok_code.
CLEAR ok_code.
CASE save_ok.
WHEN 'INSERT'.
editor->get_text_as_stream( IMPORTING text = text_tab ).
WHEN 'F1'.
MESSAGE i888(sabapdemos) WITH text-001.
WHEN OTHERS.
MESSAGE i888(sabapdemos) WITH text-002.
cl_gui_cfw=>dispatch( ). "for application events
MESSAGE i888(sabapdemos) WITH text-003.
ENDCASE.
SET SCREEN 100.
ENDMODULE. * Class Implementations ********************************************** CLASS event_handler IMPLEMENTATION.
METHOD handle_f1.
DATA row TYPE i.
MESSAGE i888(sabapdemos) WITH text-004.
sender->get_selection_pos(
IMPORTING from_line = row ).
sender->get_line_text(
EXPORTING line_number = row
IMPORTING text = field ).
cl_gui_cfw=>set_new_ok_code( "raise PAI for
EXPORTING new_code = 'F1' ). "system events
cl_gui_cfw=>flush( ).
ENDMETHOD.
METHOD handle_f4.
DATA row TYPE i.
MESSAGE i888(sabapdemos) WITH text-005.
sender->get_selection_pos(
IMPORTING from_line = row ).
sender->get_line_text(
EXPORTING line_number = row
IMPORTING text = field ).
cl_gui_cfw=>flush( ).
ENDMETHOD.
ENDCLASS.

Description

Screen 100 contains an output field field and a custom control called textedit. The flow logic of screen 100 is as follows:

PROCESS BEFORE OUTPUT.
  MODULE status_0100.
PROCESS AFTER INPUT.
  MODULE cancel AT EXIT-COMMAND.
  MODULE user_command_0100.

In the GUI status SCREEN_100, the function codes BACK, EXIT, and CANCEL have been created with type E and the function code INSERT has been created without any specific type.

The program contains a local class called event_handler with event handlers for the events F1 and F4 of global class CL_GUI_TEXTEDIT. When the program is executed, screen 100 instantiates objects of the classes CL_GUI_CUSTOM_CONTAINER, CL_GUI_TEXTEDIT, and event_handler at the PBO event.

The container control is linked to the custom control on the screen, and the instance of the textedit control is linked to this container. Since the events F1 and F4 of the textedit control are to be passed to the application server, the SET_REGISTERED_EVENTS method is used to register them, defining F1 as a system event and F4 as an application event. The event handling methods of the instance handle of the class event_handler are registered as handlers for the events.

Before the screen is sent, the textedit control is filled with the contents of table text_tab. As long as the screen is displyed, the user is allowed to edit the text. When INSERT is chosen, the PAI event is triggered, and the current text from the textedit control is copied into table text_tab.

If the user chooses the F1 key on the textedit control, the system immediately executes the handle_f1 method, assigning the row contents to the field field. Calling the SET_NEW_OK_CODE method triggers the PAI event. This is the only way to ensure that the PBO event is also processed and the contents of field are passed to the screen.

If the user chooses the F4 key on the textedit control, PAI is triggered. By calling the DISPATCH method, the system executes the handle_f4 method, assigning the row contents to the field field. Since the system then automatically returns to PAI processing, PBO is also processed and the field contents are transported.

In either case, regardless of whether the user chooses F1 or F4, the contents of the textedit control are not passed to the internal table text_tab. Consequently, the textedit control is overwritten with the previous contents of text_tab at the PBO event

最新文章

  1. WCF学习之旅—TcpTrace工具(二十五)
  2. Looper.prepare()和Looper.loop()
  3. 本周进步要点20161023(含李笑来第二场live笔记要点)
  4. web前端基础知识-(二)CSS基本操作
  5. linux服务器init 5启动图形界面,报错Retrigger failed udev events
  6. 127.0.0.1和localhost完全相等吗?
  7. IE 的resize事件问题
  8. Oracle用户的单张表的读写权限控制
  9. POJ1905Expanding Rods(二分)
  10. 关于Qt5 UI设计的一些小知识
  11. 字符串转换为float<2>
  12. UVA 1513 - Movie collection(树状数组)
  13. DFS算法(——模板习题与总结)
  14. SQL2008全部数据导出导入两种方法
  15. 基于centos6.5安装部署mongdb3.6
  16. NVMe概述
  17. Java中创建线程的三种方式以及区别
  18. Codeforces Div3 #498 A-F
  19. python opencv3 图像与原始字节转换
  20. 基于OpenCV进行图像拼接原理解析和编码实现(提纲 代码和具体内容在课件中)

热门文章

  1. springboot读取配置文件赋值给静态变量
  2. linux修改中文字符集
  3. JVM诊断及工具笔记(4) 使用visualvm分析JVM堆内存泄漏
  4. Codeforces Round #703 (Div. 2)__ B. Eastern Exhibition__ 纯纯的思维
  5. Ajax错误处理
  6. 2021.07.17 P3177 树上染色(树形DP)
  7. 源码解析Synchronous Queue 这种特立独行的队列
  8. 攻防世界-MISC:wireshark-1
  9. 【ACM程序设计】并查集
  10. NLP教程(2) | GloVe及词向量的训练与评估