ABAP--关于SAP Control Framework(入门GUI编程的不错的基础介绍)

一、SAP Control Framework的架构

SAP Control Framework的架构分为客户端和应用服务器端,其中客户端包含重要的部件:“Automation Controller”,应用服务器端包含:“ABAP Objects Control Framework”;
Automation Controller的功能
1) The automation controller is the central instance at the frontend. It administers all instances of custom controls.
2) The Automation Controller also contains a list of the events that a custom control can trigger 
.
3) All communication between the controls at the frontend and the application program at the backend runs through the Automation Controller.

 

 

ABAP Objects Control Framework的功能
1) The ABAP Objects Control Framework has a similar function at the backend to that of the Automation Controller at the frontend. All method calls from an application program to a custom control run through the Control Framework. In order to avoid each method call establishing a separate connection to the frontend, the method calls are buffered in the automation queue. The automation queue is not sent to the frontend until you reach a synchronization point.
2) Like the Automation Controller, the Control Framework has a list of control events. This list also contains the corresponding handler methods that need to be called when the event occurs 
.
3) The Control Framework also maintains a list of the control instances you have created. This list is the basis for the lifetime management of controls

二、SAP Control Framework的事件类型
System events:
该事件发生时,不会发生自动对象的数据交换,不会触发PBO和PAI事件。
在该事件的处理过程里你可以通过set_new_ok_code 函数设置新值到OK_CODE,人为的触发PAI和PBO事件。

Application events:
该事件在PAI event处理完后会自动触发(这种情况下屏幕字段已经传输到程序变量),你也可以在PAI事件当中使用CL_GUI_CFW=>DISPATCH 来人为触发Application events事件的处理。

三、SAP Control Framework事件的交互图

先由控件触发事件,“Automation Controller”就会检查是否有该事件的注册,有就会向应用服务器提交,应用服务器就将由“ABAP Objects Control Framework”来检测事件的注册,找出对应处理过程并调用处理

四、SAP Control Framework的程序设计步骤
1)定义事件处理类
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS Event_Handler
   FOR EVENT
event_name OF cl_gui_picture 
   IMPORTING
event_parameter
             sender
.
ENDCLASS.
2)事件类实现
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
CLASS-METHODS Event_Handler
        FOR EVENT
event_name OF cl_gui_picture
        IMPORTING event_parameter
                  sender
.
ENDCLASS.
3) 定义自定义控件容器变量
DATA container TYPE REF TO cl_gui_custom_container.
4)定义自定义变量
DATA my_control  TYPE REF TO cl_gui_picture. 

5)定义事件内表变量
DATA events TYPE cntl_simple_events.
DATA wa_events TYPE  cntl_simple_event.
6)定义事件处理类的对象
DATA event_receiver TYPE REF TO lcl_event_receiver.
6)创建容器和控件
CREATE OBJECT container
    EXPORTING container_name = 'CUSTOM'
                            lifetime       = lifetime.

CREATE OBJECT my_control
     EXPORTING parent  = container 
              lifetime = lifetime.
7)创建事件处理类的对象
CREATE OBJECT event_receiver.
8)维护事件内表并注册事件
wa_events-eventid = event_id .
wa_events-appl_event =
appl_event . “为X是表示应用类型事件,空表示系统类型事件
APPEND wa_events TO events.

CALL METHOD my_control->set_registered_events
            events = events.

9)设置事件处理过程
SET HANDLER event_receiver->Event_Handler
            FOR my_control.

五、SAP的GUI的类列表

CLASS NAME Super CLASS NAME DESCRIPTIO
CL_GUI_OBJECT   Proxy Class for a GUI Object
CL_FORMPAINTER_BASEWINDOW CL_GUI_OBJECT SAP Form Painter Window Base Class
CL_FORMPAINTER_BITMAPWINDOW CL_FORMPAINTER_BASEWINDOW SAP Form Painter Bitmap Window Class
CL_FORMPAINTER_TEXTWINDOW CL_FORMPAINTER_BASEWINDOW SAP Form Painter Text Window Class
CL_GUI_CONTROL CL_GUI_OBJECT Proxy Class for Control in GUI
CL_DSVAS_GUI_BUSIGRAPH CL_GUI_CONTROL DSVAS: Proxy for Business Graphic
CL_GFW_GP_PRES_CHART CL_GUI_CONTROL GFW: Product-specific section of CL_GUI_GP_PRES (Chart)
CL_GFW_GP_PRES_PIG CL_GUI_CONTROL GFW: product specific section for web view
CL_GFW_GP_PRES_SAP CL_GUI_CONTROL GFW: product-specific section of CL_GUI_GP_PRES (SAP BUSG)
CL_GUI_ALV_GRID_BASE CL_GUI_CONTROL Basis Class for ALV Grid
CL_CALENDAR_CONTROL_SCHEDULE CL_GUI_ALV_GRID_BASE Calendar View (Day, Week, Month)
CL_GUI_ALV_GRID CL_GUI_ALV_GRID_BASE ALV List Viewer
CL_ALV_DD_LISTBOX CL_GUI_ALV_GRID D&D List Box
CL_BUKF_CAT_GRID CL_GUI_ALV_GRID Key Figures - Grid of categories
CL_BUKF_DSRC_GRID CL_GUI_ALV_GRID Key Figures - Grid for Data sources
CL_BUKF_FILTER_GRID CL_GUI_ALV_GRID Key Figures - Filter for Key Figure
CL_BUKF_KF_GRID CL_GUI_ALV_GRID Key Figures - Grid for Key Figures
CL_BUKF_TERMS_GRID CL_GUI_ALV_GRID Key Figures - Grid for terms
CL_FTR_GUI_ENTRY_ALV CL_GUI_ALV_GRID Class: ALV Grid Control for Initial Screen (Without Toolbar)
CL_GFW_GP_GRID_ALV CL_GUI_ALV_GRID ALV grid proxy
CL_GUI_AQQGRAPHIC_ADAPT CL_GUI_CONTROL Network Adapter
CL_GUI_AQQGRAPHIC_CONTROL CL_GUI_CONTROL BW Basis Class Network Control
CL_GUI_AQQGRAPHIC_NETPLAN CL_GUI_AQQGRAPHIC_CONTROL Network Control
CL_GUI_BARCHART CL_GUI_CONTROL Bar chart wrapper
CL_GUI_BORDERPAINTER CL_GUI_CONTROL SAP Border Painter Control Proxy Class
CL_GUI_BTFEDITOR CL_GUI_CONTROL SAP BTF Editor Control Proxy Class
CL_GUI_CALENDAR CL_GUI_CONTROL Calendar Control Proxy Class
CL_GUI_CHART_ENGINE_WIN CL_GUI_CONTROL Graphics: Presentation Graphics (SAP GUI for Windows)
CL_GUI_CONTAINER CL_GUI_CONTROL Abstract Container for GUI Controls
CL_GUI_CONTAINER_INFO CL_GUI_CONTAINER Information on Container Controls
CL_GUI_CUSTOM_CONTAINER CL_GUI_CONTAINER Container for Custom Controls in the Screen Area
CL_GUI_DIALOGBOX_CONTAINER CL_GUI_CONTAINER Container for Custom Controls in the Screen Area
CL_ECL_VIEWER_FRAME CL_GUI_DIALOGBOX_CONTAINER Manage EAI Control in Own Window
CL_GUI_ECL_VIEWERBOX CL_GUI_DIALOGBOX_CONTAINER ECL Viewer as Dialog Box
CL_GUI_DOCKING_CONTAINER CL_GUI_CONTAINER Docking Control Container
CL_GUI_EASY_SPLITTER_CONTAINER CL_GUI_CONTAINER Reduced Version of Splitter Container Control
CL_EU_EASY_SPLITTER_CONTAINER CL_GUI_EASY_SPLITTER_CONTAINER Internal Test; Do Not Use
CL_GUI_GOS_CONTAINER CL_GUI_CONTAINER Generic Object Services Container
CL_GUI_SIMPLE_CONTAINER CL_GUI_CONTAINER Anonymous Container
CL_GUI_SPLITTER_CONTAINER CL_GUI_CONTAINER Splitter Control
CL_GUI_ECL_2DCOMPARE CL_GUI_CONTROL Compare Module for 2D Viewer
CL_GUI_ECL_3DCOMPARE CL_GUI_CONTROL Compare Module for 3D Viewer
CL_GUI_ECL_3DMEASUREMENT CL_GUI_CONTROL Measurement Module for 3D Viewer
CL_GUI_ECL_3DSECTIONING CL_GUI_CONTROL Sectioning Module for 3D Viewer
CL_GUI_ECL_MARKUP CL_GUI_CONTROL Markup (Redlining) Component
CL_GUI_ECL_PMI CL_GUI_CONTROL PMI Module for the 3D Viewer
CL_GUI_ECL_PRIMARYVIEWER CL_GUI_CONTROL Basis Class for ECL Viewers (2D und 3D)
CL_GUI_ECL_2DVIEWER CL_GUI_ECL_PRIMARYVIEWER Engineering Client 2D Viewer
CL_GUI_ECL_3DVIEWER CL_GUI_ECL_PRIMARYVIEWER Engineering Client 3D Viewer
CL_GUI_ECL_VIEWER CL_GUI_CONTROL Proxy Class for Engineering Client Viewer
CL_GUI_FORMPAINTER CL_GUI_CONTROL SAP Form Painter Control Proxy Class
CL_GUI_GLT CL_GUI_CONTROL Internal; Do Not Use!
CL_GUI_GP CL_GUI_CONTROL GFW: Superclass of all graphics proxies
CL_GUI_GP_GRID CL_GUI_GP GFW: Grid proxy
CL_GUI_GP_HIER CL_GUI_GP GFW: Structure graphics
CL_GUI_GP_PRES CL_GUI_GP GFW: Business graphic
CL_GUI_GRLT CL_GUI_CONTROL Internal; Do Not Use !! ( restricted license - see docu)
CL_GUI_HTML_EDITOR CL_GUI_CONTROL HTML Editor
CL_GUI_ILIDRAGNDROP_CONTROL CL_GUI_CONTROL Interactive List: Drag & Drop
CL_GUI_MOVIE CL_GUI_CONTROL SAP Movie Control
CL_GUI_NETCHART CL_GUI_CONTROL Network wrapper
CL_GFW_GP_HIER_SAP CL_GUI_NETCHART GFW: Product-specific section of CL_GUI_GP_HIER (NETZ)
CL_GUI_PDFVIEWER CL_GUI_CONTROL PDF Viewer
CL_GUI_PICTURE CL_GUI_CONTROL SAP Picture Control
CL_GFW_GP_PRES_WEB CL_GUI_PICTURE GFW: product specific section for web view
CL_GUI_RTF_EDITOR CL_GUI_CONTROL SAP SAPscript Editor Control
CL_GUI_SAPSCRIPT_EDITOR CL_GUI_RTF_EDITOR SAP SAPscript Editor Control
CL_GUI_SELECTOR CL_GUI_CONTROL SAPSelector: Control for selecting colors or bitmaps
CL_GUI_SPH_STATUS_CONTROL CL_GUI_CONTROL SAPphone: Status Event Control
CL_GUI_TABLEPAINTER CL_GUI_CONTROL SAP Table Painter Control Proxy Class
CL_GUI_TIMER CL_GUI_CONTROL SAP Timer Control
CL_GUI_TOOLBAR CL_GUI_CONTROL Toolbar Control
CL_CCMS_AL_GUI_TOOLBAR CL_GUI_TOOLBAR Alerts: GUI Toolbar Used in the Visual Framework
CL_GUI_WCF_WWP CL_GUI_CONTROL Internal Tool - DO NOT USE
CL_KW_AUTOMATION_CONTROL CL_GUI_CONTROL Helper Class for General Automation Objects
CL_LC_EDITOR_CONTROL CL_GUI_CONTROL Lifecycle Editor Control
CL_GCM_LCEDITOR_CONTROL CL_LC_EDITOR_CONTROL Control for the display of definition life cycles
CL_SOTR_SPELLCHECKER CL_GUI_CONTROL Interface with OTR Spellchecker
CL_SRM_BASE_CONTROL CL_GUI_CONTROL SRM Control
CL_SRM_STACKED_CONTROL CL_SRM_BASE_CONTROL RM Control with Stack
CL_TREE_CONTROL_BASE CL_GUI_CONTROL Internal Tree Control Class
CL_GUI_SIMPLE_TREE CL_TREE_CONTROL_BASE Simple Tree Control
CL_ITEM_TREE_CONTROL CL_TREE_CONTROL_BASE Internal Tree Control Class
CL_GUI_COLUMN_TREE CL_ITEM_TREE_CONTROL Column Tree Control
BDMT_CONTROL CL_GUI_COLUMN_TREE Administers Tree Control for Monitoring
CL_BUCC_TREE CL_GUI_COLUMN_TREE Consistency Checks - Library Tree
CL_GFW_COLUMN_TREE CL_GUI_COLUMN_TREE Do not use!!!!!!!!
CL_GFW_GP_HIER_SAPTREE CL_GFW_COLUMN_TREE GFW: Product-specific section of CL_GUI_GP_HIER
CL_HU_COLUMN_TREE CL_GUI_COLUMN_TREE Tree that Displays Handling Units
CL_GUI_LIST_TREE CL_ITEM_TREE_CONTROL List Tree Control
C_OI_CONTAINER_CONTROL_PROXY CL_GUI_CONTROL For Internal Use
SCE_HTML_CONTROL_EVENT_HANDLER CL_GUI_CONTROL Event Handler for SCE HTML Control
CL_ALV_TREE_BASE CL_GUI_CONTROL Basis Class ALV Tree Control
CL_GUI_ALV_TREE CL_ALV_TREE_BASE ALV Tree Control
CL_GCM_WORKLIST_TREE CL_GUI_ALV_TREE CM: Worklist
CL_PT_GUI_TMW_ALV_TREE CL_GUI_ALV_TREE Small Modification to CL_GUI_ALV_TREE
CL_GUI_ALV_TREE_SIMPLE CL_ALV_TREE_BASE Simple ALV Tree
CL_SIMPLE_TREE_VIEW_MM CL_GUI_ALV_TREE_SIMPLE Simplest Kind of Tree
CL_GUI_ECATT_RECORDER CL_GUI_CONTROL SAP eCATT Recorder Control - To be used by eCATT only!
CL_GUI_TEXTEDIT CL_GUI_CONTROL SAP TextEdit Control
CL_GCM_TEXTEDIT CL_GUI_TEXTEDIT CM: Long text control
CL_SOTR_TEXTEDIT CL_GUI_TEXTEDIT Edit Control for the OTR
CL_GUI_HTML_VIEWER CL_GUI_CONTROL HTML Control Proxy Class
CL_BFW_HTML_VIEWER_POC CL_GUI_HTML_VIEWER Browser Framework: Proxy for HTML Control
CL_CCMS_BSP_VIEWER CL_GUI_HTML_VIEWER HTML Control Proxy Class
CL_CCMS_AL_OBJ_DET_HTML_VIEWER CL_CCMS_BSP_VIEWER Alerts: Component That Displays Object Properties with HTML
CL_CCMS_FROG_HTML_VIEWER CL_GUI_HTML_VIEWER CL_GUI_FROG_HTML_VIEWER
CL_SSF_HTML_VIEWER CL_GUI_HTML_VIEWER Smart Forms: Enhanced HTML Viewer
CL_GUI_ECL_MATRIX CL_GUI_OBJECT Represents a Complete Data Type with 13 Floats
CL_GUI_RESOURCES CL_GUI_OBJECT GUI Resources (Fonts, Colors, ...)
CL_WF_GUI_RESOURCES CL_GUI_RESOURCES Getting Front Settings
CL_WF_GUI_RESOURCES_4_HTML CL_GUI_RESOURCES Get Front Settings for HTML Generation
CL_KW_AUTOMATION_OBJECT CL_GUI_OBJECT For Internal Use
CL_TABLEPAINTER_BASETABLE CL_GUI_OBJECT SAP Table Painter Table Base Class
CL_TABLEPAINTER_TABLE CL_TABLEPAINTER_BASETABLE SAP Table Painter Table Class
CL_TABLEPAINTER_TEMPLATE CL_TABLEPAINTER_BASETABLE SAP Table Painter Template Class
C_OI_AUTOMATION_OBJECT CL_GUI_OBJECT For Internal Use
CL_GUI_FRONTEND_SERVICES CL_GUI_OBJECT Frontend services

本篇只是介绍sap的SAP Control Framework基本原理,具体实例大家可以参见:BCALV_GRID_08等等。

 

posted on 2007-10-29 16:38  毛小娃  阅读(1195)  评论(0编辑  收藏  举报

导航