当前位置:网站首页>ABAP-OOAVL模板程序
ABAP-OOAVL模板程序
2022-08-02 11:40:00 【InfoQ】
REPORT ytest_zj001.
*&---------------------------------------------------------------------*
*& Report YTEST_ZJ001
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT ytest_zj001.
*&---------------------------------------------------------------------*
*&INCLUDE
*&---------------------------------------------------------------------*
INCLUDE ytest_zj001_c01.
INCLUDE ytest_zj001_top.
INCLUDE ytest_zj001_s01.
INCLUDE ytest_zj001_f01.
INCLUDE ytest_zj001_o01.
INCLUDE ytest_zj001_i01.
START-OF-SELECTION.
PERFORM get_data.
END-OF-SELECTION.
CALL SCREEN 100.
INCLUDE ytest_zj001_c01
*&---------------------------------------------------------------------*
*& 包含 YTEST_ZJ001_C01
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*&事件类定义
*&---------------------------------------------------------------------*
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
ENDCLASS.
*&---------------------------------------------------------------------*
*&事件类实现
*&---------------------------------------------------------------------*
CLASS lcl_event_receiver IMPLEMENTATION.
ENDCLASS.
INCLUDE ytest_zj001_top.
*&---------------------------------------------------------------------*
*& 包含 YTEST_ZJ001_TOP
*&---------------------------------------------------------------------*
TABLES:sflight.
*&---------------------------------------------------------------------*
*&全局表
*&---------------------------------------------------------------------*
DATA:gt_data TYPE TABLE OF sflight.
*&---------------------------------------------------------------------*
*&全局变量
*&---------------------------------------------------------------------*
DATA:gv_ok_code TYPE sy-ucomm,
ok_code TYPE sy-ucomm,
gv_col TYPE i.
*&---------------------------------------------------------------------*
*&ALV全局变量
*&---------------------------------------------------------------------*
DATA:go_grid TYPE REF TO cl_gui_alv_grid,
go_docking TYPE REF TO cl_gui_docking_container,
gs_layout TYPE lvc_s_layo,
gt_fieldcat TYPE lvc_t_fcat,
gs_fieldcat TYPE lvc_s_fcat,
gt_exclude TYPE ui_functions.
*&---------------------------------------------------------------------*
*&宏
*&---------------------------------------------------------------------*
DEFINE fieldcat_add.
CLEAR gs_fieldcat.
gv_col = gv_col + 1.
gs_fieldcat-col_pos = gv_col. "列的显示位置
gs_fieldcat-fieldname = &1. "表字段
gs_fieldcat-reptext = &2. "列标题
gs_fieldcat-outputlen = &3. "输出长度
gs_fieldcat-no_zero = &4. "为输出隐藏零
gs_fieldcat-decimals = &5. "小数位数
gs_fieldcat-just = &6. "输出格式(L:靠左,C:居中,R:靠右)
gs_fieldcat-hotspot = &7. "是否单点
gs_fieldcat-ref_table = &8. "参考表
gs_fieldcat-ref_field = &9. "参考字段
* gs_fieldcat-convexit = &10. "转换例程
* gs_fieldcat-edit = &11. "这一列设为可编辑状态
APPEND gs_fieldcat TO gt_fieldcat.
END-OF-DEFINITION.
INCLUDE ytest_zj001_s01.
SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE TEXT-001.
PARAMETERS:p_carrid TYPE sflight-carrid.
SELECTION-SCREEN END OF BLOCK blk1.
INCLUDE ytest_zj001_f01.
*&---------------------------------------------------------------------*
*& 包含 YTEST_ZJ001_F01
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form get_data
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM get_data .
SELECT *
FROM sflight
INTO TABLE gt_data
WHERE carrid = p_carrid.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form frm_build_fcat
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM frm_build_fcat .
CLEAR:gv_col,gs_fieldcat,gt_fieldcat.
gv_col = 1.
fieldcat_add: 'CARRID' '航线代码' '5' '' '' 'L' '' '' '',
'CONNID' '航班连接编号' '8' '' '' 'L' '' '' '',
'FLDATE' '航班日期' '10' '' '' 'C' '' '' '',
'PRICE' '航空运费' '10' '' '' 'R' '' 'SFLIGHT' 'PRICE' ,
'CURRENCY' '货币' '5' '' '' 'C' '' 'SFLIGHT' 'CURRENCY'.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form frm_set_layout
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM frm_set_layout .
CLEAR: gs_layout.
gs_layout-zebra = 'X'.
gs_layout-cwidth_opt = 'X'.
gs_layout-sel_mode = 'A'.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form exclude_tb_functions
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> GT_EXCLUDE
*& --> PERFORM
*& --> DISP_ALV
*&---------------------------------------------------------------------*
FORM exclude_tb_functions TABLES pt_exclude TYPE ui_functions .
DATA: ls_exclude TYPE ui_func.
ls_exclude = cl_gui_alv_grid=>mc_fc_maximum .
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_minimum .
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_subtot .
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_sum .
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_average .
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_mb_sum .
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_mb_subtot .
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_sort_asc.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_sort_dsc .
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_find .
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_filter .
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_print .
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_print_prev .
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_mb_export .
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_graph .
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_mb_view .
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_detail .
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_help .
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_info .
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_mb_variant.
APPEND ls_exclude TO pt_exclude.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form disp_alv
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM disp_alv .
DATA:lo_event TYPE REF TO lcl_event_receiver.
FIELD-SYMBOLS: <lfs_tab> TYPE STANDARD TABLE.
ASSIGN gt_data TO <lfs_tab>.
CHECK <lfs_tab> IS ASSIGNED.
CREATE OBJECT go_docking
EXPORTING
repid = sy-repid
dynnr = sy-dynnr
side = cl_gui_docking_container=>dock_at_bottom "dock_at_top
extension = 500
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
OTHERS = 6.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CREATE OBJECT go_grid
EXPORTING
i_parent = go_docking
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CALL METHOD go_grid->set_table_for_first_display
EXPORTING
i_save = 'A'
is_layout = gs_layout
it_toolbar_excluding = gt_exclude
CHANGING
it_outtab = <lfs_tab>
it_fieldcatalog = gt_fieldcat
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
CREATE OBJECT lo_event.
* SET HANDLER cl_event_receiver=>handle_hotspot_click
* "alv_event_receiver=>handle_double_click
* FOR ALL INSTANCES.
ENDFORM.
FORM frm_refresh_alv USING po_grid TYPE REF TO cl_gui_alv_grid.
DATA:ls_stable TYPE lvc_s_stbl.
ls_stable-row = 'X'." 基于行的稳定刷新
ls_stable-col = 'X'." 基于列稳定刷新
CALL METHOD po_grid->refresh_table_display
EXPORTING
is_stable = ls_stable
EXCEPTIONS
finished = 1
OTHERS = 2.
ENDFORM.
INCLUDE ytest_zj001_o01.
*&---------------------------------------------------------------------*
*& 包含 YTEST_ZJ001_O01
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
SET PF-STATUS '0100'.
SET TITLEBAR '0100'.
ENDMODULE.
*&---------------------------------------------------------------------*
*& Module INIT_ALV OUTPUT
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
MODULE init_alv OUTPUT.
IF go_docking IS NOT BOUND.
"创建ALV结构
PERFORM frm_build_fcat.
"设置ALV输出格式及变式
PERFORM frm_set_layout.
PERFORM exclude_tb_functions TABLES gt_exclude.
"显示ALV数据
PERFORM disp_alv.
ELSE.
PERFORM frm_refresh_alv USING go_grid.
ENDIF.
ENDMODULE.
INCLUDE ytest_zj001_i01.
*&---------------------------------------------------------------------*
*& 包含 YTEST_ZJ001_I01
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Module EXIT INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE exit INPUT.
CLEAR:gv_ok_code.
gv_ok_code = ok_code.
CLEAR:ok_code.
CASE gv_ok_code.
WHEN 'BACK'OR 'EXIT' OR 'CANCLE'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE.
边栏推荐
- OSI 七层模型和TCP/IP模型及对应协议(详解)
- sva assertion data
- What is the future of smartwatches?
- JSP中include指令的功能简介说明
- When not to use () instead of Void in Swift
- LeetCode第三题(Longest Substring Without Repeating Characters)三部曲之一
- jvmxmx和xms参数分析(设定优化校准)
- 面积曲线AUC(area under curve)
- ASP.NET Core 6框架揭秘实例演示[31]:路由&ldquo;高阶&rdquo;用法
- 翻译英语的软件-免费翻译软件-各种语言互相翻译
猜你喜欢
今日睡眠质量记录85分
STM32+MPU6050 Design Portable Mini Desktop Clock (Automatically Adjust Time Display Direction)
AQS-AbstractQueuedSynchronizer
X86函数调用模型分析
CCF paper conference IEEE how to query all articles of a conference journal
yolo格式(txt)数据集转VOC(xml)
如何通过DBeaver 连接 TDengine?
The exchange - string dp
Swift中什么时候不能用 () 代替 Void 来使用
翻译英语的软件-免费翻译软件-各种语言互相翻译
随机推荐
CAN总线的AUTOSAR网络管理
Swift中什么时候不能用 () 代替 Void 来使用
SQLAlchemy使用教程
雷克萨斯,锁死的安全,挡不住的心寒
中原银行实时风控体系建设实践
Mysql事务隔离级别与MVCC(多版本并发控制)
匹配滤波(四种滤波器的幅频特性)
STM32+MPU6050设计便携式Mini桌面时钟(自动调整时间显示方向)
SQL function $TRANSLATE
华为eNSP(基础实验通信)
Getting Started with Three.JS Programmatic Modeling
解决anaconda下载pytorch速度极慢的方法
go源码之sync.Waitgroup
Crack detection technology based on deep learning
SQL(面试实战07)
ssm web page access database data error
暑期总结3
CCF paper conference IEEE how to query all articles of a conference journal
OLED的HAL库代码介绍及使用(stm32f1/I2C/HAL库版/100%一次点亮)
当POC遇见RPA:RPA项目顺利实施的关键