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. ThingsBoard安装编译搭建环境踩坑记录

    1.首先从github拉下来项目,我们采用源码编译的方式部署 git clone https://github.com/thingsboard/thingsboard.git 2.切换分支 git c ...

  2. 『现学现忘』Git基础 — 2、Git和SVN的区别

    1.Git和SVN的区别 (1)SVN(集中式版本管理系统) 集中式的版本控制系统都有一个单一的集中管理的服务器,保存所有文件的修订版本,而协同工作的人们都通过客户端连到这台服务器,取出最新的文件或者 ...

  3. Postman大势已去

    作为一名前端,日常开发过程中除了写业务代码,前后端联调更是重要的一环.但这一环却往往是整个开发中最繁琐也最累人的一环.任谁都想早点下班,然而提升联调效率并不是个纯技术相关的问题,而是需要有良好工作流程 ...

  4. 『现学现忘』Git基础 — 3、Git介绍

    目录 1.Git的历史 2.Git的特点 3.Git在项目协作开发中所解决的问题 1.Git的历史 Git是目前世界上最先进的分布式版本控制系统,开源.免费. Git 是 Linus (林纳斯)为了帮 ...

  5. vue动态绑定属性--基本用法及动态绑定class

    动态绑定属性v-bind:,语法糖形式:省略v-bind,仅写一个冒号. 一.动态绑定基本属性 1 <body> 2 <!-- v-bind 动态绑定属性-基本用法 --> 3 ...

  6. 转载:Linux图形界面知识(介绍X、X11、GNOME、Xorg、KDE等之间的关系)

    转载 http://blog.csdn.net/zhangxinrun/article/details/7332049Linux初学者经常分不清楚linux和X之间,X和Xfree86之间,X和KDE ...

  7. pdf.js 预览文件中文内容丢失

    问题: 在.netcore中使用pdf.js,pdf中有部分中文无法显示 在浏览器控制台发现有报错 发现在pdf.view.js中url路径异常,没有指向cmaps文件,于是调整了正确的相对路径 再次 ...

  8. 【科普】为什么ip地址通常以192.168开头?

    开源Linux 回复"读书",挑选书籍资料~ 我们做运维的,与ip地址接触最多,无论是运维的哪方面,都需要跟ip地址打交道,通常我们也会经常听到公网.内网?那什么是公网ip地址呢? ...

  9. 低代码 —— 初步认识 Appsmith

    初步认识 Appsmith appsmith 是什么 appsmith 是 github 上的一个开源项目,截至此刻(20220512)有 17.7k Star. Appsmith 是一个低代码.开源 ...

  10. Java 统计新客户

    上周做了一个订单数据统计的任务,统计的是订单的新客户数量,本文做一个解题过程的记录和整理. 新客户的定义 新客户指的是选取时间段有订单,时间段之前没有订单. 比如下面的订单数据: 时间段 2月1日之前 ...