REPORT demo_dynpro_context_menu.

DATA: field1 TYPE i VALUE 10,
field2 TYPE p DECIMALS 4. DATA: prog TYPE sy-repid,
flag(1) TYPE c VALUE 'X'. DATA: ok_code TYPE sy-ucomm,
save_ok TYPE sy-ucomm. prog = sy-repid. CALL SCREEN 100. MODULE status_0100 OUTPUT.
SET TITLEBAR 'TIT100'.
IF flag = 'X'.
SET PF-STATUS 'SCREEN_100' EXCLUDING 'REVEAL'.
ELSEIF flag = ' '.
SET PF-STATUS 'SCREEN_100' EXCLUDING 'HIDE'.
ENDIF.
LOOP AT SCREEN INTO DATA(screen_wa).
IF screen_wa-group1 = 'MOD'.
IF flag = 'X'.
screen_wa-active = '1'.
ELSEIF flag = ' '.
screen_wa-active = '0'.
ENDIF.
MODIFY SCREEN FROM screen_wa.
ELSEIF screen_wa-name = 'TEXT_IN_FRAME'.
IF flag = 'X'.
screen_wa-active = '0'.
ELSEIF flag = ' '.
screen_wa-active = '1'.
ENDIF.
MODIFY SCREEN FROM screen_wa.
ENDIF.
ENDLOOP.
ENDMODULE. MODULE cancel INPUT.
LEAVE PROGRAM.
ENDMODULE. MODULE user_command_0100.
save_ok = ok_code.
CLEAR ok_code.
CASE save_ok.
WHEN 'HIDE'.
flag = ' '.
WHEN 'REVEAL'.
flag = 'X'.
WHEN 'SQUARE'.
field2 = field1 ** 2.
WHEN 'CUBE'.
field2 = field1 ** 3.
WHEN 'SQUAREROOT'.
field2 = field1 ** ( 1 / 2 ).
WHEN 'CUBICROOT'.
field2 = field1 ** ( 1 / 3 ).
ENDCASE.
ENDMODULE. ************************************************************
* Callback-Routines:
************************************************************ FORM on_ctmenu_text USING l_menu TYPE REF TO cl_ctmenu.
l_menu->load_gui_status(
EXPORTING program = prog
status = 'CONTEXT_MENU_1'
menu = l_menu ).
ENDFORM. FORM on_ctmenu_frame USING l_menu TYPE REF TO cl_ctmenu.
l_menu->load_gui_status(
EXPORTING program = prog
status = 'CONTEXT_MENU_2'
menu = l_menu ).
l_menu->load_gui_status(
EXPORTING program = prog
status = 'CONTEXT_MENU_1'
menu = l_menu ).
l_menu->set_default_function(
EXPORTING fcode = 'HIDE' ).
ENDFORM. FORM on_ctmenu_reveal USING l_menu TYPE REF TO cl_ctmenu.
l_menu->load_gui_status(
EXPORTING program = prog
status = 'CONTEXT_MENU_3'
menu = l_menu ).
l_menu->load_gui_status(
EXPORTING program = prog
status = 'CONTEXT_MENU_1'
menu = l_menu ).
l_menu->set_default_function(
EXPORTING fcode = 'REVEAL' ).
ENDFORM. FORM on_ctmenu_input USING l_menu TYPE REF TO cl_ctmenu.
DATA calculate_menu TYPE REF TO cl_ctmenu.
CREATE OBJECT calculate_menu.
calculate_menu->add_function(
EXPORTING fcode = 'SQUARE'
text = text-001 ).
calculate_menu->add_function(
EXPORTING fcode = 'CUBE'
text = text-002 ).
calculate_menu->add_function(
EXPORTING fcode = 'SQUAREROOT'
text = text-003 ).
calculate_menu->add_function(
EXPORTING fcode = 'CUBICROOT'
text = text-004 ).
l_menu->add_submenu(
EXPORTING menu = calculate_menu
text = text-005 ).
ENDFORM.

Description

The static Next-Screen-Number of screen 100 is 100. The elements TEXT2 and FIELD2 do not have their own context menus. They inherit the context menu FRAME of the frame. The modification group MOD is assigned to them. The screen flow logic is:

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

The GUI status SCREEN_100 is set to PBO statically, in which, depending on the field flag, the function codes HIDE or REVEAL are hidden. The context menus to the screen elements are set up in the callback routines as follows:

  • TEXT: Loading of the static context menu CONTEXT_MENU_1 without modification. This context menu has a line Cancel.
  • FRAME: Setup of the context menu from the static context menus. CONTEXT_MENU_2 und CONTEXT_MENU_1. This context menu has two lines Hide result and Cancel. The line for the function code HIDE is highlighted.
  • REVEAL: Creation of the context menus from the static context menus CONTEXT_MENU_3 and CONTEXT_MENU_1. This context menu has two lines Display result and Cancel. The line to the function code REVEAL is highlighted.
  • INPUT: Setting up the context menu by incorporating the multiline local context menu CALCULATE_MENU as submenu. For the latter, a local reference variable with reference to CL_CTMENU is created, an object is created and the new function codes SQUARE, CUBE, SQUAREROOT and CUBICROOT are added. At the integration into the context menu for INPUT, a text must be specified for the entry, after which the submenu is attached.

When executing the program and pressing the right (secondary) mouse button or SHIFT F10, the user receives the context menu TEXT in the first line, the context menu INPUT in the second line, and the context menu FRAME in the third line. The fourth line is hidden after program start. On all other remaining screen components, the standard context menu appears with all static function codes and additionally F1 and F4.

When selecting a new dynamic function, calculations are carried out with the number in input field FIELD1 and then put to FIELD2. When selecting the function Hide result (HIDE), the screen is modified dynamically. Thereby, the fourth line is made visible making the context menu REVEAL accessible.

SAP 实例 3 Context Menus的更多相关文章

  1. Google Chrome插件开发-Context Menus

    本节主要介绍如何在Google Chrome浏览器web页面上点击右键弹出自定义菜单,即如何使用谷歌Context Menus API接口.上节已经把主要流程介绍了,这节就直接上代码,代码都是官方例子 ...

  2. Context Menus

    转载:http://open.chrome.360.cn/extension_dev/contextMenus.html 内容 清单 范例 API 参考: Chrome.contextMenus 方法 ...

  3. SAP 实例 8 HTML from the MIME Repository

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

  4. SAP 实例 4 CFW

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

  5. [转] How to change font settings for all UI elements (toolbar and context menus, property editors, etc.)

    https://www.devexpress.com/Support/Center/Question/Details/S35762

  6. SAP 实例- 下拉框

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

  7. SAP 实例- 页签tabsrip

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

  8. SAP 实例 13 Random Grouping with LOOP

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

  9. 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 ...

随机推荐

  1. re模块、collections模块、time模块、datetime模块

    正则表达式之re模块 re.findall用法(重要) re.findall( '正则表达式' , '待匹配的字符' ) 找出所有的目标字符,用列表的形式展现,如果找不到返回空列表. import r ...

  2. Hadoop-Hive组件部署

    一.基础环境 Hive 组件需要基于之前已部署完毕的 Hadoop 全分布系统,在 master 节点上实现 Hive 组件安装. 1.Hadoop-全分布式配置(全部配置) 2.Hadoop-集群运 ...

  3. LAN交换机自学习算法

    LAN交换机自学习算法 提示 第二层交完全忽略帧的数据部分协议,仅根据第二层以太网的MAC地址做出转发决策. MAC地址表有时又被称作内容可编址内存(CAM)表 检查源MAC地址 如果源MAC地址不存 ...

  4. 十、包机制与JavaDoc

    一.包机制 为了更好的组织类,Java提供了包机制,用于区别类名的命名空间. 包语句的语句格式为: package pkg1[. pkg2[. pkg3...]]; 一般使用公司域名倒置作为包名:例如 ...

  5. python基础练习题(题目 一个数如果恰好等于它的因子之和,这个数就称为"完数"。例如6=1+2+3.编程找出1000以内的所有完数)

    day12 --------------------------------------------------------------- 实例019:完数 题目 一个数如果恰好等于它的因子之和,这个 ...

  6. Es5 - 11 详解

    一.ES简介 ECMAScript,欧洲计算机制造商协会 ES是一种标准,而JS是ES的一种实现 每年的ES版本中都会引入新特性 二.NRM的安装与使用 NRM是切换源的工具 ES6 2.1安装 wi ...

  7. Go学习-基本语法(一)

    前言 一直对Service Mesh相关内容比较感兴趣,后面一路学习了Dcoker.Kubernetes等相关内容,可以说是对基本概念和使用有一定了解,随着开始学习一些相关的组件的时候,发现基本上全部 ...

  8. 解决学校在线评测系统不支持C++11的问题

    如图,我们老师搞的这个评测系统它不支持C++11.但分析错误信息可知GCC本身版本是支持C++11的,只不过没开开.平时的时候我们可以对"g++"后使用"-std=c++ ...

  9. ONNXRuntime学习笔记(四)

    接上一篇在Python端的onnx模型验证结果,上一篇在Pytorch和onnxruntime-gpu推理库上分别进行效果效率统计分析,结论要比最初设置的50ms高很多,这一篇我将在C++端写个测试代 ...

  10. 操作系统深度研究(75页PPT)

    上一篇:命令行版的斗地主你玩过没? 内容覆盖操作系统基本概念.分类.关键技术,体系架构,发展历程和主流国产操作系统厂商分析. 文中报告节选自兴业证券经济与金融研究院已公开发布研究报告,具体报告内容及相 ...