OO ALV(一屏幕显示多个ALV, 双击事件)例子

这是一个使用ABAP创建的示例,展示了如何在一屏幕上显示多个ALV(ABAP List Viewer),并处理双击事件。程序通过OO方式创建ALV网格,设置表格和布局,然后在双击事件中触发处理函数,展示选定行的详细数据。此外,还包含了数据查询、筛选和ALV事件处理的代码实现。
摘要由CSDN通过智能技术生成
*&---------------------------------------------------------------------*
*& Report  ZVR_V051

REPORT  zvr_v051.

TABLES:afpo,afko,ekkn,resb,eket,mard,jest.


DATA:t_main TYPE TABLE OF zbb_zcocx,
     w_main TYPE zbb_zcocx.


DATA:t_resb TYPE TABLE OF zbb_zcocx_i,
     p_resb TYPE TABLE OF zbb_zcocx_i,
     d_resb TYPE TABLE OF zbb_zcocx_i,
     w_resb TYPE zbb_zcocx_i,
     h_resb TYPE zbb_zcocx_i.


TYPES:BEGIN OF typ_makt,
     matnr TYPE makt-matnr,
     maktx TYPE makt-maktx,
   END OF typ_makt.
DATA: t_makt TYPE TABLE OF typ_makt,
      w_makt TYPE typ_makt.

TYPES:BEGIN OF typ_mard,
    matnr TYPE mard-matnr,
    labst TYPE mard-labst,
    kalab TYPE mska-kalab,
    werks TYPE mska-werks,
    lgort TYPE mska-lgort,
    vbeln TYPE mska-vbeln,
    posnr TYPE mska-posnr,
  END OF typ_mard.
DATA:t_mard TYPE TABLE OF typ_mard,
     t_mska TYPE TABLE OF typ_mard,
     w_mard TYPE typ_mard,
     w_mska TYPE typ_mard.

TYPES:BEGIN OF typ_zgysqr,
  ebeln TYPE zgysqr-ebeln,
  ebelp TYPE zgysqr-ebelp,
  shrq  TYPE  zgysqr-shrq,
  END OF typ_zgysqr.
DATA:t_zgysqr TYPE TABLE OF typ_zgysqr,
      w_zgysqr TYPE typ_zgysqr.

TYPES:BEGIN OF typ_ekkn,
   ebeln TYPE ekkn-ebeln,
   ebelp TYPE ekkn-ebelp,
   matnr TYPE ekpo-matnr,
   eindt TYPE eket-eindt,
   vbeln TYPE ekkn-vbeln,
   vbelp TYPE ekkn-vbeln,
   werks TYPE ekpo-werks,
   shrq  TYPE zgysqr-shrq,
  END OF typ_ekkn.
DATA:t_ekkn TYPE TABLE OF typ_ekkn,
      w_ekkn TYPE typ_ekkn.


TYPES: BEGIN OF typ_aufk,
    aufnr TYPE aufk-aufnr,
    objnr TYPE aufk-objnr,
    inact TYPE jest-inact,
  END OF typ_aufk.
DATA: t_aufk TYPE TABLE OF typ_aufk,
      w_aufk TYPE typ_aufk.

TYPES:BEGIN OF typ_shrq,
  ebeln TYPE zgysqr-ebeln,
  ebelp TYPE zgysqr-ebelp,
  shrq  TYPE zgysqr-shrq,
  END OF typ_shrq.
DATA: t_shrq TYPE TABLE OF typ_shrq,
      w_shrq TYPE typ_shrq.


* OO alv声明
DATA:
* wcl_container type ref to cl_gui_docking_container,
  wcl_container TYPE REF TO cl_gui_custom_container,       "存放ALV的容器
  wcl_container1 TYPE REF TO cl_gui_custom_container,      "存放ALV的容器
  wcl_alv   TYPE REF TO cl_gui_alv_grid ,                  "ALV网格
  wcl_alv1  TYPE REF TO cl_gui_alv_grid ,                  "ALV网格
  pt_exclude TYPE ui_functions,                            "用于去掉不要的菜单栏
  pt_exclude1 TYPE ui_functions,                           "用于去掉不要的菜单栏
  gt_fieldcat TYPE lvc_t_fcat ,
  gt_fieldcat1 TYPE lvc_t_fcat ,
  gs_layout TYPE lvc_s_layo ,                              "布局结构
  gs_layout1 TYPE lvc_s_layo .                             "布局结构
DATA: ls_stable  LIKE lvc_s_stbl.
DATA: ts_layout  TYPE disvariant.

DATA: it_events TYPE slis_t_event,
      wa_events LIKE LINE OF it_events.
DATA: lr_grid   TYPE REF TO cl_gui_alv_grid.

DATA l_tabix TYPE sy-tabix.

* OK_CODE
DATA ok_code TYPE sy-ucomm.
DATA save_ok TYPE sy-ucomm.




SELECTION-SCREEN BEGIN OF BLOCK b2_block WITH FRAME.
SELECT-OPTIONS: s_pwerk FOR afpo-pwerk,     "工厂
                s_matnr FOR afpo-matnr,     "物料号
                s_gstrp FOR afko-gstrp.     "开始日期
PARAMETERS: p_rfc AS CHECKBOX .          " FUNCTION调用,不显示ALV
SELECTION-SCREEN END OF BLOCK b2_block.


AT SELECTION-SCREEN OUTPUT .
  LOOP AT SCREEN .
    IF screen-name = 'P_RFC'.
      screen-active = 0 .
      MODIFY SCREEN .
    ENDIF.
  ENDLOOP.

START-OF-SELECTION .
* 查询产品数据
  PERFORM frm_sel_afpo .
* 查询组件数据
  PERFORM frm_sel_resb .

END-OF-SELECTION.
  CHECK p_rfc IS INITIAL .
* 添加alv 输出结构
  PERFORM frm_alv_fieldcat.
* 添加alv 输出样式
  PERFORM frm_alv_layout .

  IF t_main IS NOT INITIAL.
    CALL SCREEN 100 .
  ELSE.
    MESSAGE s002(zdev) DISPLAY LIKE 'E'.
  ENDIF.




* ALV事件
  CLASS lcl_event_receiver DEFINITION DEFERRED.
  "
  DATA event_receiver TYPE REF TO lcl_event_receiver.

*----------------------------------------------------------------------*
*       CLASS lcl_event_receiver DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_event_receiver DEFINITION.
  PUBLIC SECTION.
*--双击事件
    METHODS:
      handle_double_click FOR EVENT double_click OF cl_gui_alv_grid
              IMPORTING e_row e_column.
ENDCLASS.                    "LCL_EVENT_RECEIVER DEFINITION
*----------------------------------------------------------------------*
*       CLASS lcl_event_receiver IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_event_receiver IMPLEMENTATION.

  METHOD handle_double_click.
    PERFORM handle_double_click USING e_row e_column.
  ENDMETHOD.                    &#
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值