SAP Context menu(菜单)
*&---------------------------------------------------------------------*
*& Report RSDEMO_CONTEXT_MENU_LIST *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------* REPORT RSDEMO_CONTEXT_MENU_LIST .
tables spfli.
*set pf-status 'LIST'. select * from spfli.
WRITE: / spfli-carrid,
spfli-connid,
spfli-cityfrom,
spfli-airpfrom,
spfli-cityto,
spfli-airpto,
spfli-fltime,
spfli-deptime,
spfli-arrtime.
endselect. form on_ctmenu_request using p_menu type ref to cl_Ctmenu. call method p_menu->LOAD_GUI_STATUS
exporting program = 'RSDEMO_CONTEXT_MENU_LIST'
STATUS = 'CONTEXT'
MENU = p_menu
exceptions READ_ERROR = 1. endform.
on screen
*&---------------------------------------------------------------------*
*& Report RSDEMO_CONTEXT_MENU_DYNPR *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------* REPORT rsdemo_context_menu_dynpr .
DATA ok_code LIKE sy-ucomm.
CONTROLS table_control TYPE TABLEVIEW USING SCREEN 100.
tables spfli.
data spfli_wa like spfli.
DATA spfli_itab LIKE STANDARD TABLE OF spfli.
DATA init.
DATA mark. CALL SCREEN 100. *&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
SET PF-STATUS 'STATUS_100'.
SET TITLEBAR '100'. ENDMODULE. " STATUS_0100 OUTPUT *&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
CASE ok_code.
WHEN 'CARRID'.
MESSAGE i300(eu) WITH 'CARRID'. "#EC NOTEXT
WHEN 'BOX_1'.
MESSAGE i300(eu) WITH 'BOX_1'. "#EC NOTEXT
WHEN 'TABLE_CONTROL'.
MESSAGE i300(eu) WITH 'TABLE CONTROL'. "#EC NOTEXT
WHEN 'TABLE_TITLE'.
MESSAGE i300(eu) WITH 'TABLE CONTROL TITLE'. "#EC NOTEXT
WHEN 'EXIT'.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT *&---------------------------------------------------------------------
*& Form Routine: setting context menu for CARRID
*----------------------------------------------------------------------
FORM on_ctmenu_carrid USING p_menu TYPE REF TO cl_ctmenu.
CALL METHOD p_menu->load_gui_status
EXPORTING program = 'RSDEMO_CONTEXT_MENU_DYNPR'
status = 'CONTEXT'
menu = p_menu.
ENDFORM. *&---------------------------------------------------------------------
*& Form Routine: setting context menu for BOX_1
*----------------------------------------------------------------------
FORM on_ctmenu_box_1 USING p_menu TYPE REF TO cl_ctmenu.
CALL METHOD p_menu->add_function
EXPORTING fcode = 'BOX_1'
text = TExt-001
icon = ' '
ftype = ' '
disabled = ' '
hidden = ' '
checked = ' '.
CALL METHOD p_menu->add_function
EXPORTING fcode = 'BOX_2'
text = TExt-001
icon = ' '
ftype = ' '
disabled = ' '
hidden = ' '
checked = ' '.
call method p_menu->set_default_function exporting fcode = 'BOX_1'.
ENDFORM. *&---------------------------------------------------------------------
*& Form Routine: setting context menu for TABLE
*----------------------------------------------------------------------
FORM on_ctmenu_table USING p_menu TYPE REF TO cl_ctmenu.
CALL METHOD p_menu->add_function
EXPORTING fcode = 'TABLE_CONTROL'
text = text-002
icon = ' '
ftype = ' '
disabled = ' '
hidden = ' '
checked = ' '. ENDFORM. *&---------------------------------------------------------------------
*& Form Routine: setting context menu for TITLE
*----------------------------------------------------------------------
FORM on_ctmenu_title USING p_menu TYPE REF TO cl_ctmenu.
CALL METHOD p_menu->add_function
EXPORTING fcode = 'TABLE_TITLE'
text = text-003
icon = ' '
ftype = ' '
disabled = ' '
hidden = ' '
checked = ' '. ENDFORM.
in control
*&---------------------------------------------------------------------*
*& Include SIMPLE_TREE_CONTEXT_MEN_DEMTOP *
*& *
*&---------------------------------------------------------------------* REPORT sapsimple_tree_context_men_dem MESSAGE-ID tree_control_msg. CLASS lcl_application DEFINITION DEFERRED.
CLASS cl_gui_cfw DEFINITION LOAD. TYPES: node_table_type LIKE STANDARD TABLE OF mtreesnode
WITH DEFAULT KEY.
* CAUTION: MTREESNODE is the name of the node structure which must
* be defined by the programmer. DO NOT USE MTREESNODE! DATA: g_application TYPE REF TO lcl_application,
g_custom_container TYPE REF TO cl_gui_custom_container,
g_tree TYPE REF TO cl_gui_simple_tree,
g_ok_code TYPE sy-ucomm,
g_ctx_fcode TYPE sy-ucomm. *** INCLUDE SIMPLE_TREE_CONTEXT_MEN_DEMTOP
*----------------------------------------------------------------------*
* INCLUDE SIMPLE_TREE_CONTROL_DEMOCL1 *
*----------------------------------------------------------------------* CLASS lcl_application DEFINITION.
PUBLIC SECTION.
METHODS:
handle_node_context_menu_req
FOR EVENT node_context_menu_request
OF cl_gui_simple_tree
IMPORTING node_key menu,
handle_node_context_menu_sel
FOR EVENT node_context_menu_select
OF cl_gui_simple_tree
IMPORTING node_key fcode.
ENDCLASS. *---------------------------------------------------------------------*
* CLASS LCL_APPLICATION IMPLEMENTATION
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
CLASS lcl_application IMPLEMENTATION. METHOD handle_node_context_menu_req.
" this method handles the node context menu request event of the
" tree control instance
data: text type gui_text.
" first entry in context menu
text = 'Node with key'. "#EC NOTEXT
concatenate text node_key into text SEPARATED by ' '.
call method menu->add_function
exporting text = text fcode = 'Entry1'. "#EC NOTEXT
" second entry in context menu
call method menu->add_function
exporting
text = 'Second Entry' "#EC NOTEXT
fcode = 'Entry2'. "#EC NOTEXT
ENDMETHOD. METHOD handle_node_context_menu_sel.
" this method handles the node context select event of the tree
" control instance
" write chosen FCODE in dynpro field
g_ctx_fcode = fcode.
ENDMETHOD. ENDCLASS.
*-------------------------------------------------------------------
***INCLUDE simple_tree_control_demoO01 .
*-------------------------------------------------------------------
*&---------------------------------------------------------------------*
*& Module PBO_0400 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE PBO_100 OUTPUT.
SET PF-STATUS 'MAIN'.
IF G_TREE IS INITIAL.
" The Tree Control has not been created yet.
" Create a Tree Control and insert nodes into it.
PERFORM CREATE_AND_INIT_TREE.
ENDIF.
ENDMODULE. " PBO_0100 OUTPUT
*** INCLUDE simple_tree_context_men_demO01
*-------------------------------------------------------------------
***INCLUDE simple_tree_control_demoI01 .
*-------------------------------------------------------------------
*&---------------------------------------------------------------------*
*& Module PAI_0400 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE PAI_100 INPUT.
data: return_code type i.
* CL_GUI_CFW=>DISPATCH must be called if events are registered
* that trigger PAI
* this method calls the event handler method of an event
CALL METHOD CL_GUI_CFW=>DISPATCH
importing return_code = return_code.
if return_code <> cl_gui_cfw=>rc_noevent.
" a control event occured => exit PAI
clear g_ok_code.
exit.
endif. CASE G_OK_CODE.
WHEN 'BACK'. " Finish program
IF NOT G_CUSTOM_CONTAINER IS INITIAL.
" destroy tree container (detroys contained tree control, too)
CALL METHOD G_CUSTOM_CONTAINER->FREE
EXCEPTIONS
CNTL_SYSTEM_ERROR = 1
CNTL_ERROR = 2.
IF SY-SUBRC <> 0.
MESSAGE A000.
ENDIF.
CLEAR G_CUSTOM_CONTAINER.
CLEAR G_TREE.
ENDIF.
LEAVE PROGRAM.
ENDCASE. * CAUTION: clear ok code!
CLEAR G_OK_CODE.
ENDMODULE. " PAI_0100 INPUT
*** INCLUDE simple_tree_context_men_demI01
*-------------------------------------------------------------------
***INCLUDE simple_tree_context_men_demF01 .
*------------------------------------------------------------------- *&---------------------------------------------------------------------*
*& Form CREATE_AND_INIT_TREE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM create_and_init_tree.
DATA: node_table TYPE node_table_type,
events TYPE cntl_simple_events,
event TYPE cntl_simple_event. * create a container for the tree control
CREATE OBJECT g_custom_container
EXPORTING
" the container is linked to the custom control with the
" name 'TREE_CONTAINER' on the dynpro
container_name = 'TREE_CONTAINER'
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5.
IF sy-subrc <> 0.
MESSAGE a000.
ENDIF. * create a tree control
CREATE OBJECT g_tree
EXPORTING
parent = g_custom_container
node_selection_mode = cl_gui_simple_tree=>node_sel_mode_single
EXCEPTIONS
lifetime_error = 1
cntl_system_error = 2
create_error = 3
failed = 4
illegal_node_selection_mode = 5.
IF sy-subrc <> 0.
MESSAGE a000.
ENDIF. * define the events which will be passed to the backend
" node context menu request
event-eventid = cl_gui_simple_tree=>eventid_node_context_menu_req.
event-appl_event = ' '. " no PAI if event occurs
APPEND event TO events. " process PAI if context menu select event occurs
call method g_tree->SET_CTX_MENU_SELECT_EVENT_APPL
exporting appl_event = 'X'. CALL METHOD g_tree->set_registered_events
EXPORTING
events = events
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
illegal_event_combination = 3.
IF sy-subrc <> 0.
MESSAGE a000.
ENDIF. * assign event handlers in the application class to each desired event
SET HANDLER g_application->handle_node_context_menu_req FOR g_tree.
SET HANDLER g_application->handle_node_context_menu_sel FOR g_tree. * add some nodes to the tree control
* NOTE: the tree control does not store data at the backend. If an
* application wants to access tree data later, it must store the
* tree data itself. PERFORM build_node_table USING node_table. * node_table_structure_name = 'MTREESNODE'
* A programmer using the tree control must create a structure in the
* dictionary. This structure must include the structure TREEV_NODE
* and must contain a character field with the name 'TEXT'. CALL METHOD g_tree->add_nodes
EXPORTING
table_structure_name = 'MTREESNODE'
node_table = node_table
EXCEPTIONS
failed = 1
error_in_node_table = 2
dp_error = 3
table_structure_name_not_found = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE a000.
ENDIF. * expand the root node
call method g_tree->expand_node
exporting
node_key = 'Root' "#EC NOTEXT
exceptions
FAILED = 1
ILLEGAL_LEVEL_COUNT = 2
CNTL_SYSTEM_ERROR = 3
NODE_NOT_FOUND = 4
CANNOT_EXPAND_LEAF = 5.
IF SY-SUBRC <> 0.
MESSAGE A000.
ENDIF. ENDFORM. " CREATE_AND_INIT_TREE
*&---------------------------------------------------------------------*
*& Form build_node_table
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------* FORM build_node_table
USING
node_table TYPE node_table_type. DATA: node LIKE mtreesnode. * Node with key 'Root'
node-node_key = 'Root'. "#EC NOTEXT
node-isfolder = 'X'.
node-text = 'Root'.
APPEND node TO node_table. * Node with key 'Child1'
clear node.
node-node_key = 'Child1'. "#EC NOTEXT
node-relatkey = 'Root'.
node-relatship = cl_gui_simple_tree=>relat_last_child.
node-text = 'Child1'.
APPEND node TO node_table. ENDFORM. " build_node_table *** INCLUDE simple_tree_context_men_demF01
SAP Context menu(菜单)的更多相关文章
- Win7/Win8右键菜单管理工具(Easy Context Menu) v1.5 绿色版
软件名称: Win7/Win8右键菜单管理工具(Easy Context Menu)软件语言: 简体中文授权方式: 免费软件运行环境: Win8 / Win7 / Vista / WinXP软件大小: ...
- 手机浏览器中屏蔽img的系统右键菜单context menu
我们知道通过oncontextmenu事件可以屏蔽浏览器右键菜单 $('img').on("contextmenu",function(E){E.preventDefault(); ...
- Vue 2.0 右键菜单组件 Vue Context Menu
Vue 2.0 右键菜单组件 Vue Context Menu https://juejin.im/entry/5976d14751882507db6e839c
- 添加删除系统右键菜单(就是上下文菜单,也就是Context Menu)中的一些选项
随着电脑安装的东西越来越多,右侧菜单也原来越长,很不方面.所以打算清理一下 我删除的大约以下几个,友好一点的都可以配置.当然也可以通过注册表直接删除. 特:注册表备份,即导入导出,避免一失足成千古恨. ...
- Android Contextual Menus之一:floating context menu
Android Contextual Menus之一:floating context menu 上下文菜单 上下文相关的菜单(contextual menu)用来提供影响UI中特定item或者con ...
- Android系列之UI组件----Menu菜单
[声明] 欢迎转载,但请保留文章原始出处→_→ 生命壹号:http://www.cnblogs.com/smyhvae/ 文章来源:http://www.cnblogs.com/smyhvae/p/4 ...
- node-webkit教程<>Native UI API 之Menu(菜单)
node-webkit教程(6)Native UI API 之Menu(菜单)1 前言... 2 6.1 Menu 概述... 3 6.2 menu api6 6.2.1 new Menu([o ...
- Android4.0 -- UI控件之 Menu 菜单的的使用(三)
上一讲 [Android 开发]:UI控件之 Menu 菜单的的使用(二) 我们讲解了创建上下文菜单的第一种使用方式:Creating a floating context menu [创建悬浮的上下 ...
- Android4.0 -- UI控件之 Menu 菜单的的使用(二)
上一讲我们讲解了android中在代码或者xml文件中定义菜单,这一讲我们继续来讲解一下定义菜单的其他方式:创建上下文的菜单.查看API文档 Menus :Creating Contextual Me ...
随机推荐
- 使用 Nginx 实现 URL 的重定向
1. 概述 老话说的好:取乎上,得其中:取乎中,得其下.因此我们不妨把目标定的高一些,去努力,才能得到更好回报. 言归正传,今天我们来聊聊 使用 Nginx 实现 URL 的重定向. 2. 使用 Ng ...
- JavaWeb学习第一阶段结束
模仿狂神实现简单的用户增删改查,增加了前端登录时的密码验证 JavaWeb学习第一阶段结束,相较于第一阶段的一味学习,第二阶段想拿出更多的时间来阅读别人的源码以及跟着做简单的小项目,同时进一步深入学习 ...
- Dom基础(二):Dom性能优化
一.尽量将DOM查询做缓存 1 let pElements = document.getElementById('div1') //将dom缓存 2 3 for(let i=0:i<pEleme ...
- petite-vue源码剖析-逐行解读@vue-reactivity之effect
当我们通过effect将副函数向响应上下文注册后,副作用函数内访问响应式对象时即会自动收集依赖,并在相应的响应式属性发生变化后,自动触发副作用函数的执行. // ./effect.ts export ...
- linux创建磁盘阵例10
Linux创建RAID10 生产环境中用到的服务器一般都配备RAID阵列卡,尽管服务器的价格越来越便宜,但是我们没有必要为了做一个实验而去单独购买一台服务器,而是可以学会使用mdadm命令在Linux ...
- RabbitMQ 3.9( 基础 )
1.认识MQ 1.1.什么是MQ? MQ全称:message queue 即 消息队列 这个队列遵循的原则:FIFO 即 先进先出 队列里面存的就是message 1.2.为什么要用MQ? 1.2.1 ...
- 记一次调试YOLOv5+DeepSort车辆跟踪项目的经过
摘要:学习别人的开源项目是日常的一项必备技能,本文通过一个车辆跟踪(YOLOv5+DeepSort)的例子介绍如何配置和调试GitHub上的开源代码.以第一人称的视角给出本人调试代码的过程,包括项目r ...
- 关闭BottomSheetDialogFragment从后台返回后的动画
问题 显示BottomSheetDialogFragment后.将当前应用放于后台,切换到其他APP,然后再返回当前应用.此时会看到BottomSheetDialogFragment从下而上的动画再次 ...
- docker 1.2 之docker基本用法
1.docker的基本用法 镜像相关操作:dockerhub查找镜像,例如查找centos的镜像 [root@elk ~]# docker search centos NAME DESCRIPTION ...
- JWT 访问令牌
JWT 访问令牌 更为详细的介绍jwt 在学习jwt之前我们首先了解一下用户身份验证 1 单一服务器认证模式 一般过程如下: 用户向服务器发送用户名和密码. 验证服务器后,相关数据(如用户名,用户角色 ...