SAP 实例 5 CFW Events
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的更多相关文章
- SAP 实例 4 CFW
*&---------------------------------------------------------------------* *& Report demo_cfw ...
- SAP 实例 8 HTML from the MIME Repository
REPORT demo_html_from_mime. CLASS mime_demo DEFINITION. PUBLIC SECTION. CLASS-METHODS main. PRIVATE ...
- SAP 实例 6 HTML input
REPORT demo_html_input. CLASS demo DEFINITION. PUBLIC SECTION. CLASS-METHODS main. PRIVATE SECTION. ...
- SAP 实例- 下拉框
效果图 源代码 REPORT rsdemo_dropdown_listbox . DATA init. TABLES scarr. TABLES spfli. TABLES sflight. TABL ...
- SAP 实例- 页签tabsrip
屏幕页签:项目上有一需求,对标准TCODE 一个屏幕增加一个页签.于是做了个例子. 下面屏幕有两个页签. 我们来看一下屏幕结构.100屏幕是主屏幕,101,102是子屏幕,对应页签test1,test ...
- SAP 实例 13 Random Grouping with LOOP
REPORT demo_loop_group_by_random. CLASS demo DEFINITION. PUBLIC SECTION. CLASS-METHODS: main, class_ ...
- 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 ...
- SAP 实例 10 List Box with value list from input help
*&---------------------------------------------------------------------* *& Report DEMO_DROP ...
- SAP 实例 9 Text output
REPORT demo_show_text. CLASS demo DEFINITION. PUBLIC SECTION. CLASS-METHODS main. ENDCLASS. CLASS de ...
随机推荐
- vwware workstation虚机网络配置NAT
1.在编辑中选择虚拟网络编辑器,新增NAT模式网络适配器,如下图: 2.在虚拟机中选择设置,在网络适配器中自定义为上一步配置的网络适配器,如下图: 3.进入虚拟机后,编辑/etc/sysconfig/ ...
- Lumia一键刷稳定版 Win10 arm 及其报错处理
前言 之前我发了一篇Lumia1520 刷Win10 arm双系统的文章,不过后来发现那个方法对小白来说太不友好,且系统也不稳定,所以我找到了更好的方法 刷机 我们可以利用刷机迷进行刷机,支持一键刷机 ...
- OSPF 路由协议详解(一)
(文章目录) ospf 协议是网络层协议 此篇文章适合有一定网络基础的人 ospf 协议最多应用在企业网络中,针对于运营商网络并不是特别的适用,端口号为 89 通过 IP 进行数据的转发 ospf 基 ...
- AWS - Basic 1
之前由于公司 Training 考取了 AWS-SAP 的证书,更多理解的是概念和理论上的知识,并未实操.但对于学习一门技术来说,实践是加深理解和掌握该技术的必经之路,强调知行合一.所以最近打算重新熟 ...
- 学习打卡day12&构建之法阅读笔记第一篇
今天浅读了<构建之法>的前四章,稍微有一些个人的见解与感受 第一点即是开篇提及到的算法与数据结构这门学科开设的必要,大二上学期学习了这门课程,就我个人目前接触到的层面来看,几乎可以说用不太 ...
- Educational Codeforces Round 113 (Rated for Div. 2)
多拿纸画画 ! ! ! Problem - B - Codeforces 题意 给出n个数字(数字为1或2), 1代表这第i个选手没有输过, 2代表这第i个选手至少赢一次 输出为n*n矩阵( i行j ...
- Elasticsearch 索引策略
Elasticsearch 7.6 索引生命周期 es的生命周期就对应了索引的策略,比如我们在使用elk的时候,由于数据量较大,时间比较久远的数据就没有那么有价值了,因此就需要定期的清除这些历史数据, ...
- [译]ng指令中的compile与link函数解析 转
通常大家在使用ng中的指令的时候,用的链接函数最多的是link属性,下面这篇文章将告诉大家complie,pre-link,post-link的用法与区别. 原文地址 angularjs里的指令非常神 ...
- LCA的离线快速求法
最常见的LCA(树上公共祖先)都是在线算法,往往带了一个log.有一种办法是转化为"+-1最值问题"得到O(n)+O(1)的复杂度,但是原理复杂,常数大.今天介绍一种允许离线时接近 ...
- go学习第一课--语法基础
一.hello world 新建文件helloworld.go package main import "fmt" func main() { fmt.Println( ...