1 建立一个新程序,代码如下:
REPORT zdrawer.
TABLES: trdir.
INCLUDE <icon>.
DATA: cc_drawer TYPE REF TO cl_gui_docking_container,
c_drawer TYPE REF TO cl_gui_container_bar,
c_container TYPE REF TO cl_gui_container,
l_caption TYPE sbptcaptn,
lt_captions TYPE sbptcaptns,
l_icon TYPE swd_icon,
lt_icons TYPE swd_icons,
ok_code TYPE sy-ucomm,
*
id TYPE i,
repid TYPE sy-repid,
dynnr TYPE sy-dynnr.
* Display data
TYPES: BEGIN OF ty_data ,
name LIKE trdir-name,
cnam LIKE trdir-cnam,
cdat LIKE trdir-cdat,
END OF ty_data.
DATA : g_alv_sd TYPE REF TO cl_gui_alv_grid,
g_alv_mm TYPE REF TO cl_gui_alv_grid,
g_alv_pp TYPE REF TO cl_gui_alv_grid,
g_alv_fi TYPE REF TO cl_gui_alv_grid,
g_alv_all TYPE REF TO cl_gui_alv_grid,
gs_data TYPE ty_data,
gt_data TYPE STANDARD TABLE OF ty_data.
CLASS lcl_application DEFINITION DEFERRED.
CLASS cl_gui_cfw DEFINITION LOAD.
DATA:
c_application TYPE REF TO lcl_application,
c_alv TYPE REF TO lcl_application.
*---------------------------------------------------------------------*
* CLASS lcl_application DEFINITION
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
CLASS lcl_application DEFINITION.
PUBLIC SECTION.
METHODS:
on_click FOR EVENT clicked OF cl_gui_container_bar
IMPORTING
id
container,
on_hotspot_click FOR EVENT
hotspot_click OF cl_gui_alv_grid IMPORTING
e_row_id e_column_id.
ENDCLASS. "lcl_application DEFINITION
*---------------------------------------------------------------------*
* CLASS lcl_application IMPLEMENTATION
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
CLASS lcl_application IMPLEMENTATION.
METHOD on_click.
DATA: l_fcode TYPE ui_func,
l_link TYPE swd_htmlco,
l_quickinfo TYPE iconquick.
DATA:
lx_variant TYPE disvariant,
lt_alv_cat TYPE lvc_t_fcat,
lx_alv_cat TYPE lvc_s_fcat,
lx_alv_lay TYPE lvc_s_layo.
DEFINE m_fieldcat.
add 1 to lx_alv_cat-col_pos.
lx_alv_cat-fieldname = &1.
case lx_alv_cat-fieldname.
when 'NAME'.
lx_alv_cat-key = 'X'.
lx_alv_cat-hotspot = 'X'.
lx_alv_cat-scrtext_m = 'Program Name'.
lx_alv_cat-colddictxt = 'M'.
lx_alv_cat-tipddictxt = 'M'.
when 'CNAM'.
lx_alv_cat-key = ''.
lx_alv_cat-hotspot = ''.
lx_alv_cat-scrtext_m = 'Created By'.
lx_alv_cat-colddictxt = 'M'.
lx_alv_cat-tipddictxt = 'M'.
when 'CDAT'.
lx_alv_cat-key = ''.
lx_alv_cat-hotspot = ''.
lx_alv_cat-scrtext_m = 'Created On'.
lx_alv_cat-colddictxt = 'M'.
lx_alv_cat-tipddictxt = 'M'.
endcase.
lx_alv_cat-ref_field = &2.
lx_alv_cat-ref_table = &3.
append lx_alv_cat to lt_alv_cat.
END-OF-DEFINITION.
CASE id.
WHEN 1.
FREE : g_alv_sd.
IF g_alv_sd IS INITIAL.
CREATE OBJECT g_alv_sd
EXPORTING i_parent = container.
*Fill gt_data
REFRESH gt_data[].
SELECT name cnam cdat FROM trdir INTO CORRESPONDING FIELDS OF
TABLE gt_data
WHERE name LIKE 'ZSD%'.
*Fill the field catalog
REFRESH lt_alv_cat[].
m_fieldcat 'NAME' 'NAME' 'TRDIR'.
m_fieldcat 'CNAM' 'CNAM' 'TRDIR'.
m_fieldcat 'CDAT' 'CDAT' 'TRDIR'.
*Layout
CLEAR lx_alv_lay.
lx_alv_lay-zebra = 'X'.
lx_alv_lay-cwidth_opt = 'X'.
lx_alv_lay-grid_title = 'Sales and Distribution Reports'.
lx_alv_lay-sel_mode = 'A'.
lx_variant-report = sy-cprog.
*Display
CALL METHOD g_alv_sd->set_table_for_first_display
EXPORTING
* I_BUFFER_ACTIVE =
* I_BYPASSING_BUFFER =
* I_CONSISTENCY_CHECK =
* I_STRUCTURE_NAME =
is_variant = lx_variant
* I_SAVE =
* I_DEFAULT = 'X'
is_layout = lx_alv_lay
* IS_PRINT =
* IT_SPECIAL_GROUPS =
* IT_TOOLBAR_EXCLUDING =
* IT_HYPERLINK =
* IT_ALV_GRAPHICS =
* IT_EXCEPT_QINFO =
CHANGING
it_outtab = gt_data
it_fieldcatalog = lt_alv_cat
* IT_SORT =
* IT_FILTER =
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4
.
IF c_alv IS INITIAL.
CREATE OBJECT c_alv.
ENDIF.
SET HANDLER c_alv->on_hotspot_click FOR g_alv_sd.
ENDIF.
WHEN 2.
FREE : g_alv_mm.
IF g_alv_mm IS INITIAL.
CREATE OBJECT g_alv_mm
EXPORTING i_parent = container.
*Fill gt_data
REFRESH gt_data[].
SELECT name cnam cdat FROM trdir INTO CORRESPONDING FIELDS OF
TABLE gt_data
WHERE name LIKE 'ZMM%'.
*Fill the field catalog
REFRESH lt_alv_cat[].
m_fieldcat 'NAME' 'NAME' 'TRDIR'.
m_fieldcat 'CNAM' 'CNAM' 'TRDIR'.
m_fieldcat 'CDAT' 'CDAT' 'TRDIR'.
*Layout
CLEAR lx_alv_lay.
lx_alv_lay-zebra = 'X'.
lx_alv_lay-cwidth_opt = 'X'.
lx_alv_lay-grid_title = 'Material Management Reports'.
lx_alv_lay-sel_mode = 'A'.
lx_variant-report = sy-cprog.
*Display
CALL METHOD g_alv_mm->set_table_for_first_display
EXPORTING
* I_BUFFER_ACTIVE =
* I_BYPASSING_BUFFER =
* I_CONSISTENCY_CHECK =
* I_STRUCTURE_NAME =
is_variant = lx_variant
* I_SAVE =
* I_DEFAULT = 'X'
is_layout = lx_alv_lay
* IS_PRINT =
* IT_SPECIAL_GROUPS =
* IT_TOOLBAR_EXCLUDING =
* IT_HYPERLINK =
* IT_ALV_GRAPHICS =
* IT_EXCEPT_QINFO =
CHANGING
it_outtab = gt_data
it_fieldcatalog = lt_alv_cat
* IT_SORT =
* IT_FILTER =
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4
.
IF c_alv IS INITIAL.
CREATE OBJECT c_alv.
ENDIF.
SET HANDLER c_alv->on_hotspot_click FOR g_alv_mm.
ENDIF.
WHEN 3.
FREE : g_alv_pp.
IF g_alv_pp IS INITIAL.
CREATE OBJECT g_alv_pp
EXPORTING i_parent = container.
*Fill gt_data
REFRESH gt_data[].
SELECT name cnam cdat FROM trdir INTO CORRESPONDING FIELDS OF
TABLE gt_data
WHERE name LIKE 'ZPP%'.
*Fill the field catalog
REFRESH lt_alv_cat[].
m_fieldcat 'NAME' 'NAME' 'TRDIR'.
m_fieldcat 'CNAM' 'CNAM' 'TRDIR'.
m_fieldcat 'CDAT' 'CDAT' 'TRDIR'.
*Layout
CLEAR lx_alv_lay.
lx_alv_lay-zebra = 'X'.
lx_alv_lay-cwidth_opt = 'X'.
lx_alv_lay-grid_title = 'Production Planning Reports'.
lx_alv_lay-sel_mode = 'A'.
lx_variant-report = sy-cprog.
*Display
CALL METHOD g_alv_pp->set_table_for_first_display
EXPORTING
* I_BUFFER_ACTIVE =
* I_BYPASSING_BUFFER =
* I_CONSISTENCY_CHECK =
* I_STRUCTURE_NAME =
is_variant = lx_variant
* I_SAVE =
* I_DEFAULT = 'X'
is_layout = lx_alv_lay
* IS_PRINT =
* IT_SPECIAL_GROUPS =
* IT_TOOLBAR_EXCLUDING =
* IT_HYPERLINK =
* IT_ALV_GRAPHICS =
* IT_EXCEPT_QINFO =
CHANGING
it_outtab = gt_data
it_fieldcatalog = lt_alv_cat
* IT_SORT =
* IT_FILTER =
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4
.
IF c_alv IS INITIAL.
CREATE OBJECT c_alv.
ENDIF.
SET HANDLER c_alv->on_hotspot_click FOR g_alv_pp.
ENDIF.
WHEN 4.
FREE : g_alv_fi.
IF g_alv_fi IS INITIAL.
CREATE OBJECT g_alv_fi
EXPORTING i_parent = container.
*Fill gt_data
REFRESH gt_data[].
SELECT name cnam cdat FROM trdir INTO CORRESPONDING FIELDS OF
TABLE gt_data
WHERE name LIKE 'ZFI%'.
*Fill the field catalog
REFRESH lt_alv_cat[].
m_fieldcat 'NAME' 'NAME' 'TRDIR'.
m_fieldcat 'CNAM' 'CNAM' 'TRDIR'.
m_fieldcat 'CDAT' 'CDAT' 'TRDIR'.
*Layout
CLEAR lx_alv_lay.
lx_alv_lay-zebra = 'X'.
lx_alv_lay-cwidth_opt = 'X'.
lx_alv_lay-grid_title = 'Finance and Controlling Reports'.
lx_alv_lay-sel_mode = 'A'.
lx_variant-report = sy-cprog.
*Display
CALL METHOD g_alv_fi->set_table_for_first_display
EXPORTING
* I_BUFFER_ACTIVE =
* I_BYPASSING_BUFFER =
* I_CONSISTENCY_CHECK =
* I_STRUCTURE_NAME =
is_variant = lx_variant
* I_SAVE =
* I_DEFAULT = 'X'
is_layout = lx_alv_lay
* IS_PRINT =
* IT_SPECIAL_GROUPS =
* IT_TOOLBAR_EXCLUDING =
* IT_HYPERLINK =
* IT_ALV_GRAPHICS =
* IT_EXCEPT_QINFO =
CHANGING
it_outtab = gt_data
it_fieldcatalog = lt_alv_cat
* IT_SORT =
* IT_FILTER =
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4
.
IF c_alv IS INITIAL.
CREATE OBJECT c_alv.
ENDIF.
SET HANDLER c_alv->on_hotspot_click FOR g_alv_fi.
ENDIF.
WHEN 5.
FREE : g_alv_all.
IF g_alv_all IS INITIAL.
CREATE OBJECT g_alv_all
EXPORTING i_parent = container.
*Fill gt_data
REFRESH gt_data[].
SELECT name cnam cdat FROM trdir INTO CORRESPONDING FIELDS OF
TABLE gt_data
WHERE name LIKE 'Z%'.
*Fill the field catalog
REFRESH lt_alv_cat[].
m_fieldcat 'NAME' 'NAME' 'TRDIR'.
m_fieldcat 'CNAM' 'CNAM' 'TRDIR'.
m_fieldcat 'CDAT' 'CDAT' 'TRDIR'.
*Layout
CLEAR lx_alv_lay.
lx_alv_lay-zebra = 'X'.
lx_alv_lay-cwidth_opt = 'X'.
lx_alv_lay-grid_title = 'All custom Reports'.
lx_alv_lay-sel_mode = 'A'.
lx_variant-report = sy-cprog.
*Display
CALL METHOD g_alv_all->set_table_for_first_display
EXPORTING
* I_BUFFER_ACTIVE =
* I_BYPASSING_BUFFER =
* I_CONSISTENCY_CHECK =
* I_STRUCTURE_NAME =
is_variant = lx_variant
* I_SAVE =
* I_DEFAULT = 'X'
is_layout = lx_alv_lay
* IS_PRINT =
* IT_SPECIAL_GROUPS =
* IT_TOOLBAR_EXCLUDING =
* IT_HYPERLINK =
* IT_ALV_GRAPHICS =
* IT_EXCEPT_QINFO =
CHANGING
it_outtab = gt_data
it_fieldcatalog = lt_alv_cat
* IT_SORT =
* IT_FILTER =
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4
.
IF c_alv IS INITIAL.
CREATE OBJECT c_alv.
ENDIF.
SET HANDLER c_alv->on_hotspot_click FOR g_alv_all.
ENDIF.
ENDCASE.
ENDMETHOD. "on_click
METHOD on_hotspot_click.
DATA:
lx_selected_row TYPE lvc_s_row,
ls_data TYPE ty_data.
CLEAR lx_selected_row.
MOVE-CORRESPONDING e_row_id TO lx_selected_row.
READ TABLE gt_data INTO ls_data INDEX lx_selected_row-index.
SET PARAMETER ID 'RID' FIELD ls_data-name.
CALL TRANSACTION 'SE38' AND SKIP FIRST SCREEN.
ENDMETHOD. "on_hotspot_click
ENDCLASS. "lcl_application IMPLEMENTATION
*DATA: c_application TYPE REF TO lcl_application.
START-OF-SELECTION.
CALL SCREEN 100.
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
SET PF-STATUS '100'.
SET TITLEBAR '100'.
repid = sy-repid.
dynnr = sy-dynnr.
*Test the function
* create container for drawer
IF cc_drawer IS INITIAL.
CREATE OBJECT cc_drawer
EXPORTING
repid = repid
dynnr = dynnr
extension = 300.
ENDIF.
* create drawer
IF c_drawer IS INITIAL.
l_caption-caption = 'Sales and Distribution Reports'(004)."text-004.
l_caption-icon = icon_wizard.
APPEND l_caption TO lt_captions.
l_caption-caption = 'Material Management Reports'(005). "text-005.
l_caption-icon = space.
APPEND l_caption TO lt_captions.
l_caption-caption = 'Production Planning Reports'(006). "text-006.
l_caption-icon = icon_display_text.
APPEND l_caption TO lt_captions.
l_caption-caption = 'Finance and Controlling Reports'(007)."text-007.
l_caption-icon = icon_display_text.
APPEND l_caption TO lt_captions.
l_caption-caption = 'All custom Reports'(008). "text-008.
l_caption-icon = icon_display_text.
APPEND l_caption TO lt_captions.
* Create cl_gui_container_bar
CREATE OBJECT c_drawer
EXPORTING
parent = cc_drawer
captions = lt_captions
EXCEPTIONS
max_number_of_cells_exceeded = 1
OTHERS = 2.
IF sy-subrc <> 0.
SET SCREEN 0. LEAVE SCREEN.
ENDIF.
* Create cl_gui_container_bar
IF c_application IS INITIAL.
CREATE OBJECT c_application.
ENDIF.
SET HANDLER c_application->on_click FOR c_drawer.
CALL METHOD c_drawer->set_active
EXPORTING
id = 1.
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
IF ok_code = 'EX'.
CALL METHOD c_drawer->free.
CALL METHOD cc_drawer->free.
SET SCREEN 0. LEAVE SCREEN.
ELSEIF ok_code = 'HI'.
CALL METHOD c_drawer->set_active
EXPORTING
id = id.
ELSEIF ok_code = 'ENTE'.
CALL METHOD c_drawer->set_active
EXPORTING
id = id.
ENDIF.
ENDMODULE. " USER_COMMAND_0100 INPUT
2 新建SCreen 100
并在屏幕上建立三个空间
2.1 1个文本控件,输入显示文本"vertical_tab_control" 和控件任何名称
2.2 1个文本输入控件,控件名称为"ID"
2.3 1个按钮控件, 输入显示文本"Set tab" 和控件任何名称,功能码为"HI"
2.4 设置屏幕功能码返回字段为"OK_CODE"
2.5 设置screen module
PROCESS BEFORE OUTPUT.
MODULE STATUS_0100.
*
PROCESS AFTER INPUT.
MODULE USER_COMMAND_0100.
并保存激活
3 新建title 100
输入任何文本
4新建Status 100
<v:shapetype o:spt="75" coordsize="21600,21600" filled="f" stroked="f" id="_x0000_t75" path="m@4@5l@4@11@9@11@9@5xe" o:preferrelative="t"> 设置标准工具条按钮对应的功能码: "ENTE" 和"EX"</v:shapetype>
分享到:
相关推荐
在“web-dynpro-abap-ui-element-tree”这个主题中,我们主要探讨的是Web Dynpro ABAP中的UI元素树结构,以及如何在Chapter 1, Curriculum (CV) Introduction中理解和应用这些知识。 在Web Dynpro ABAP中,UI元素是...
在ABAP编程中,FIELD-SYMBOLS是一个非常重要的概念,它允许我们动态地引用数据结构,无需预先声明具体的变量。这在处理多种不同类型的变量或处理...熟练掌握FIELD-SYMBOLS的使用,可以使ABAP编程更加高效且易于维护。
4. **ABAP项目管理**:使用Eclipse ABAP插件,开发者可以创建、管理和组织ABAP项目。这些项目对应于SAP系统中的软件组件或开发对象,方便代码结构化和团队协作。 5. **远程开发与连接SAP系统**:该插件允许开发者...
A complete description of the most important objects for ABAP from ABAP Dictionary. ABAP - Reference A complete description of all ABAP keywords in their relevant context. ABAP - Quick ...
本教程“绝版的从实例到精通ABAP学习--ALV控件的使用”深入浅出地讲解了如何有效地利用ALV控件进行数据展示和处理,尤其适合初学者入门。 首先,`reuse_alv_list_display`是ABAP标准库中的一个函数模块,用于快速、...
-----ABAP FAQs--------------------------------------------
批量下载abap程序-改造版
ABAP-OO也可以应用于SAP Business Warehouse(BW),允许开发人员创建自定义数据提取、转换和加载(ETL)过程。 12. **ABAP Interface and Module Pool** 模块池技术允许将业务逻辑分隔为可重用的模块,接口则...
CD260-ABAP-in-Eclipse-开发-CN CD260-ABAP-in-Eclipse-开发-CNCD260-ABAP-in-Eclipse-开发-CNCD260-ABAP-in-Eclipse-开发-CN
SAP培训2-ABAP基础-语法,对ABAP语法知识进行初步的介绍,初步讲解。
通过分析给定的文件信息,“abap pa - BC400_Col63”可以理解为一份针对ABAP Workbench的培训课程资料,其重点在于向学员介绍如何使用ABAP Workbench进行开发工作。此外,文件还强调了版权、商标和免责声明等内容,...
eclipse-abap-keywordcolors eclipse-abap-关键字颜色
在给定的示例中,作者通过一段ABAP程序展示了如何使用ALV进行一般列表显示。这段程序的主要功能是显示物料细节信息,包括物料编号(MATNR)、创建者(ERNAM)、创建日期(ERSDA)以及物料类别(LABOR)。 1. **数据...
SAP Abap Programming-Total(EN)
ABAP BP-批量创建供应商采购视图,采用方法类的形式批量创建BP中供应商的采购视图,程序可直接修改参数后调用
01. Introduction to ABAP 02. Introduction to ABAP Programming 03. Simple Output Statements 04. Data Declarations 05. Retrieving Data with Select Statements 06. Control Statements 7. Data ...
标题:ABAP SELECT-SCREEN 的几个用法 在SAP ABAP编程中,SELECT-SCREEN是一种用于接收用户输入的关键机制,它允许开发人员设计出直观且功能丰富的屏幕界面。通过SELECT-SCREEN,开发者能够控制屏幕元素的位置、...
SAP外挂报表系统 - ABAP Report - C# Winform源代码 本软件的主要功能是,以C#.NET WINFORM 开发一个固定的客户端,然后以HTTP+XML的方式与SAP进行数据交互,用户和权限管理都在SAP中实现,WINFORM中的报表导航清单...