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

SAP 实例 5 CFW Events的更多相关文章

  1. SAP 实例 4 CFW

    *&---------------------------------------------------------------------* *& Report demo_cfw ...

  2. SAP 实例 8 HTML from the MIME Repository

    REPORT demo_html_from_mime. CLASS mime_demo DEFINITION. PUBLIC SECTION. CLASS-METHODS main. PRIVATE ...

  3. SAP 实例 6 HTML input

    REPORT demo_html_input. CLASS demo DEFINITION. PUBLIC SECTION. CLASS-METHODS main. PRIVATE SECTION. ...

  4. SAP 实例- 下拉框

    效果图 源代码 REPORT rsdemo_dropdown_listbox . DATA init. TABLES scarr. TABLES spfli. TABLES sflight. TABL ...

  5. SAP 实例- 页签tabsrip

    屏幕页签:项目上有一需求,对标准TCODE 一个屏幕增加一个页签.于是做了个例子. 下面屏幕有两个页签. 我们来看一下屏幕结构.100屏幕是主屏幕,101,102是子屏幕,对应页签test1,test ...

  6. SAP 实例 13 Random Grouping with LOOP

    REPORT demo_loop_group_by_random. CLASS demo DEFINITION. PUBLIC SECTION. CLASS-METHODS: main, class_ ...

  7. SAP 实例 12 List Box with Value List from PBO Module

    REPORT demo_dynpro_dropdown_listbox. DATA: name TYPE vrm_id, list TYPE vrm_values, value LIKE LINE O ...

  8. SAP 实例 10 List Box with value list from input help

    *&---------------------------------------------------------------------* *& Report DEMO_DROP ...

  9. SAP 实例 9 Text output

    REPORT demo_show_text. CLASS demo DEFINITION. PUBLIC SECTION. CLASS-METHODS main. ENDCLASS. CLASS de ...

随机推荐

  1. 时序数据库influxDB介绍

    https://www.jianshu.com/p/68c471bf5533 https://www.cnblogs.com/wzbk/p/10569683.html

  2. Bootstrap Blazor 组件库 Row 布局组件(栅格系统)

    原文链接:https://www.cnblogs.com/ysmc/p/16133351.html 在 Bootstrap 中,栅格相信大家都很熟悉,简直就是布局神器啊,Bootstrap Blazo ...

  3. Postman+newman+jenkins+git实战

    一.接口分类,流程,用例设计 接口分类: 外部接口:被测系统与外部其他系统之间的接口. 承保系统(被测系统),核算系统. 内部接口:被测系统内部各个子模块之间的接口. 承保系统(A模块,B模块) 测试 ...

  4. Jx.Cms开发笔记(五)-文章编辑页面标签设计

    标签页的样子 设计思路 与其他输入框一样,存在一个Label标签,由于这里不像其他输入框一样可以直接使用Row标签,所以这里需要额外增加. 使用Tag组件显示所有的标签,我们在Blazor 组件库 B ...

  5. Android Studio 的蓝牙串口通信(附Demo源码下载)

    根据相关代码制作了一个开源依赖包,将以下所有的代码进行打包,直接调用即可完成所有的操作.详细说明地址如下,如果觉得有用可以GIthub点个Star支持一下: 项目官网 Kotlin版本说明文档 Jav ...

  6. @Transactional的使用与失效

    @Transactinonal 注解在方法抛出RuntimeException类及其子类时.Error类及其子类时会回滚当前事务,使sql不提交: 只能作用于public的方法:写在类上时,代表给该类 ...

  7. SSM框架中返回的是字符串还是页面跳转的问题

    如果你在控制器前的注解是@RestController的话,将返回controller方法指定的String值,@RestController注解相当于@ResponseBody和@Controlle ...

  8. XCTF练习题---MISC---Ditf

    XCTF练习题---MISC---Ditf flag:flag{Oz_4nd_Hir0_lov3_For3ver} 解题步骤: 1.观察题目,下载附件 2.这道题是安恒办的一场比赛题目,下载附件以后是 ...

  9. Java 18 新特性:使用Java代码启动jwebserver

    前几天分享了Java 18 新特性:简单Web服务器的jwebserver命令行功能. 今天换一种方式,使用Java代码来实现一个静态资源服务器. 详细步骤我录了个视频放到B站了,感兴趣的小伙伴可以点 ...

  10. 离谱的 CSS!从表盘刻度到艺术剪纸

    某日,群里有这样一个问题,如何实现这样的表盘刻度: 这其实是个挺有意思的问题,方法也有很多. 单标签,使用 conic-gradient 实现表盘刻度 最简单便捷的方式,就是利用角向渐变的方式 con ...