1.Class ALV 的双击、F4事件
2.Call Transaction :Vendor、PO
REPORT z_scm_maintain_ekko_ci .
TABLES: ekko.
DATA: BEGIN OF itab OCCURS 0 ,
        flag ,
        werks LIKE ekpo-werks,
        ebeln LIKE ekko-ebeln,
        lifnr LIKE ekko-lifnr,
        name1 LIKE lfa1-name1,
        telf1 LIKE lfa1-telf1,
        aedat LIKE ekko-aedat,
        zzreagree LIKE ekko-zzreagree,
        zzredate LIKE ekko-zzredate,
        zzrereason LIKE ekko-zzrereason,
        zzreperson LIKE ekko-zzreperson,
        zzremode   LIKE ekko-zzremode,
        zzpostatus LIKE ekko-zzpostatus,
      END OF itab .
DATA: ok_code LIKE sy-ucomm .
DATA: l_valid(1) TYPE c.
DATA: go_grid             TYPE REF TO cl_gui_alv_grid,
      go_custom_container TYPE REF TO cl_gui_custom_container.
DATA: gt_fieldcat TYPE lvc_t_fcat,
      gs_fieldcat TYPE lvc_s_fcat,
      gs_variant  TYPE disvariant ,
      gt_sort     TYPE lvc_t_sort,
      gs_sort     TYPE lvc_s_sort,
      gt_filt     TYPE lvc_t_filt,
      gs_filt     TYPE lvc_s_filt,
      ls_cell     TYPE lvc_s_styl,
      sla         TYPE lvc_s_layo,
      gt_f4       TYPE lvc_t_f4,
      gs_f4       TYPE lvc_s_f4.
DATA: lt_exclude TYPE ui_functions.
PARAMETERS p_werks LIKE ekpo-werks OBLIGATORY.
SELECT-OPTIONS:
            s_ebeln FOR ekko-ebeln ,
            s_lifnr FOR ekko-lifnr,
            s_aedat FOR ekko-aedat ."OBLIGATORY.
DATA  cl_gui_alv_grid.
*---------------------------------------------------------------------*
*       CLASS lcl_event_receiver DEFINITION
*---------------------------------------------------------------------*
CLASS lcl_event_receiver DEFINITION.
  PUBLIC SECTION.
    METHODS handle_f4
      FOR EVENT onf4 OF cl_gui_alv_grid
      IMPORTING e_fieldname
                es_row_no
                er_event_data
                et_bad_cells.
    METHODS catch_doubleclick
      FOR EVENT double_click OF cl_gui_alv_grid
      IMPORTING e_row
                e_column
                es_row_no .
ENDCLASS.                    "lcl_event_receiver DEFINITION
*---------------------------------------------------------------------*
*       CLASS lcl_event_receiver IMPLEMENTATION
*---------------------------------------------------------------------*
CLASS lcl_event_receiver IMPLEMENTATION.
  METHOD handle_f4.
    PERFORM f4 USING e_fieldname
                     es_row_no
                     er_event_data
                     et_bad_cells.
  ENDMETHOD.                                                "handle_f4
  METHOD catch_doubleclick.
    PERFORM atdoubleclick USING e_row
                                e_column
                                es_row_no.
  ENDMETHOD.
ENDCLASS.                    "lcl_event_receiver IMPLEMENTATION
DATA: event_receiver TYPE REF TO lcl_event_receiver.
INITIALIZATION.
*  gd_repid = sy-repid.
  PERFORM fieldcat_init USING gt_fieldcat[].
START-OF-SELECTION.
  CALL SCREEN '100'.
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
  CASE ok_code.
    WHEN 'EXIT' OR 'BACK'.
      LEAVE PROGRAM.
    WHEN 'SAVE'.
      PERFORM save.
    WHEN 'ALL'.
      PERFORM all.
    WHEN 'NONE'.
      PERFORM none.
  ENDCASE.
  CLEAR ok_code .
ENDMODULE.                 " USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*&      Form  load_data_into_grid
*&---------------------------------------------------------------------*
FORM load_data_into_grid.
  SELECT  ekko~ebeln
          ekko~lifnr
          ekko~aedat
          ekko~zzreagree
          ekko~zzredate
          ekko~zzrereason
          ekko~zzreperson
          ekko~zzremode
          ekko~zzpostatus
          lfa1~name1
          lfa1~telf1
          ekpo~werks
  FROM ekko INNER JOIN ekpo ON ekko~ebeln = ekpo~ebeln AND
                               ekpo~ebelp = '00010'
            INNER JOIN lfa1 ON ekko~lifnr = lfa1~lifnr
  INTO CORRESPONDING FIELDS OF TABLE itab
  WHERE ekko~ebeln IN s_ebeln AND
        ekko~lifnr IN s_lifnr AND
        ekko~aedat IN s_aedat AND
        ekpo~werks = p_werks.
  sla-cwidth_opt = 'X'.
  sla-zebra      = 'X'.
  sla-no_toolbar = 'X'.
*  sla-edit = 'X' .
  CALL METHOD go_grid->set_table_for_first_display
    EXPORTING
      is_variant                    = gs_variant
      i_save                        = 'A'
      is_layout                     = sla
*      IT_TOOLBAR_EXCLUDING          =
    CHANGING
      it_outtab                     = itab[]
      it_fieldcatalog               = gt_fieldcat[]
    EXCEPTIONS
      invalid_parameter_combination = 1
      program_error                 = 2
      too_many_lines                = 3
      OTHERS                        = 4.
  CALL METHOD go_grid->set_ready_for_input "??????
    EXPORTING
      i_ready_for_input = 1.
ENDFORM.                    " load_data_into_grid

*&--------------------------------------------------------------------*
*&      Form  fieldcat_init
*&--------------------------------------------------------------------*
FORM fieldcat_init USING rt_fieldcat TYPE lvc_t_fcat.
  DATA: ls_fieldcat TYPE lvc_s_fcat.
CLEAR ls_fieldcat.
  ls_fieldcat-fieldname     = 'FLAG'.
  ls_fieldcat-scrtext_l     = 'Flag'.
  ls_fieldcat-checkbox      = 'X'.
  ls_fieldcat-edit          = 'X'.
  ls_fieldcat-key           = 'X'.
  APPEND ls_fieldcat TO  rt_fieldcat .
  CLEAR ls_fieldcat.
PERFORM frm_catlg_set USING:
  'WERKS'  '' '门店'         '' 'WERKS' 'EKPO' rt_fieldcat,
  'EBELN'  '' 'PO号码'       '' 'EBELN' 'EKKO' rt_fieldcat,
  'AEDAT'  '' 'PO日期'       '' 'AEDAT' 'EKKO' rt_fieldcat,
  'LIFNR'  '' '供应商'       '' 'LIFNR' 'EKKO' rt_fieldcat, "
  'NAME1'  '' '供应商名称'   '' 'NAME1' 'LFA1' rt_fieldcat,
  'TELF1'  '' '供应商电话'   '' 'TELF1' 'LFA1' rt_fieldcat,
  'ZZREAGREE'  '' '是否同意'  'X'  'ZZREAGREE'  'EKKO' rt_fieldcat,
  'ZZREDATE'  '' '日期'   'X'  'ZZREDATE'  'EKKO' rt_fieldcat,
  'ZZREPERSON'  '' '回复人'   'X'  'ZZREPERSON' 'EKKO' rt_fieldcat,
  'ZZREMODE'  '' '退货方式'   'X'  'ZZREMODE' 'EKKO' rt_fieldcat,
  'ZZPOSTATUS'  '' 'PO状态'   'X'  'ZZPOSTATUS' 'EKKO' rt_fieldcat,
  'ZZREREASON'  '' '不同意原因'   'X'  'ZZREREASON' 'EKKO' rt_fieldcat.
gs_f4-fieldname = 'ZZREPERSON'.
  gs_f4-register = 'X'.
  gs_f4-getbefore = 'X'.
  gs_f4-chngeafter = 'X'.
  INSERT gs_f4 INTO TABLE gt_f4.
ENDFORM.   "fieldcat_init

*---------------------------------------------------------------------*
*       FORM frm_catlg_set                                            *
*---------------------------------------------------------------------*
FORM frm_catlg_set USING p_field p_key p_text p_edit ref_f ref_t
                          rt_fieldcat  TYPE lvc_t_fcat .
  DATA:  tmp_fieldcat TYPE lvc_s_fcat.
tmp_fieldcat-fieldname     =  p_field.
  tmp_fieldcat-key           =  p_key .
  tmp_fieldcat-scrtext_l     =  p_text.
  tmp_fieldcat-edit          =  p_edit.
  tmp_fieldcat-f4availabl    = 'X'.
  tmp_fieldcat-ref_field     = ref_f.
  tmp_fieldcat-ref_table     = ref_t.
APPEND tmp_fieldcat TO rt_fieldcat .
  CLEAR tmp_fieldcat .
ENDFORM.                    " FRM_CATLG_SET
*&---------------------------------------------------------------------*
*&      Form  change
*&---------------------------------------------------------------------*
FORM change .
  IF go_grid->is_ready_for_input( ) = 0.
    CALL METHOD go_grid->set_ready_for_input
      EXPORTING
        i_ready_for_input = 1.
  ELSE.
    CALL METHOD go_grid->check_changed_data  "????????????
      IMPORTING
        e_valid = l_valid.
    CALL METHOD go_grid->set_ready_for_input
      EXPORTING
        i_ready_for_input = 0.
    CALL METHOD go_grid->refresh_table_display.
  ENDIF.
ENDFORM.                    " change

*&--------------------------------------------------------------------*
*&      Form  f4
*&--------------------------------------------------------------------*
FORM f4 USING r_fieldname TYPE lvc_fname
              rs_row_no TYPE lvc_s_roid
              rr_event_data TYPE REF TO cl_alv_event_data
              rt_bad_cells TYPE lvc_t_modi.
rr_event_data->m_event_handled = 'X'.
ENDFORM.                                                    " F4
*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
  SET PF-STATUS 'MAIN100'.
  gs_variant-report = sy-repid.
IF go_grid IS INITIAL.
    CREATE OBJECT go_grid
      EXPORTING
        i_parent = cl_gui_container=>screen0.
    CREATE OBJECT event_receiver.
    SET HANDLER event_receiver->handle_f4 FOR go_grid.
    CALL METHOD go_grid->register_f4_for_fields
      EXPORTING
        it_f4 = gt_f4.
    SET HANDLER event_receiver->catch_doubleclick FOR go_grid.
    IF sy-batch IS INITIAL.
      CALL METHOD go_grid->register_edit_event
        EXPORTING
          i_event_id = cl_gui_alv_grid=>mc_evt_enter.
    ENDIF.
    PERFORM load_data_into_grid.
  ENDIF.
ENDMODULE.                 " STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*&      Form  save
*&---------------------------------------------------------------------*
FORM save.
  CALL METHOD go_grid->check_changed_data
        IMPORTING
          e_valid = l_valid.
  IF l_valid = 'X'.
    LOOP AT itab WHERE flag = 'X'.
      UPDATE ekko SET
                zzreagree = itab-zzreagree
                zzredate = itab-zzredate
                zzrereason = itab-zzrereason
                zzreperson = itab-zzreperson
                zzremode   = itab-zzremode
                zzpostatus = itab-zzpostatus
      WHERE ebeln = itab-ebeln .
      IF sy-subrc NE 0.
        MESSAGE e000(z900) WITH 'Update Error!'.
      ENDIF.
    ENDLOOP.
    IF sy-subrc = 0.
      MESSAGE i000(z900) WITH 'Update Success!'.
    ENDIF.
  ELSE.
    MESSAGE e000(z900) WITH 'Data Error'.
  ENDIF.
ENDFORM.                    " save
*&---------------------------------------------------------------------*
*&      Form  all
*&---------------------------------------------------------------------*
FORM all.
  LOOP AT itab.
    itab-flag = 'X'.
    MODIFY itab.
  ENDLOOP.
  CALL METHOD go_grid->refresh_table_display.
ENDFORM.                    " all
*&---------------------------------------------------------------------*
*&      Form  none
*&---------------------------------------------------------------------*
FORM none.
  LOOP AT itab.
    itab-flag = ' '.
    MODIFY itab.
  ENDLOOP.
  CALL METHOD go_grid->refresh_table_display.
ENDFORM.                    " none
*&---------------------------------------------------------------------*
*&      Form  atdoubleclick
*&---------------------------------------------------------------------*
FORM atdoubleclick USING    p_e_row
                            p_e_column
                            p_es_row_no.
  READ TABLE itab INDEX p_e_row.
  IF p_e_column = 'EBELN'.
    SET PARAMETER ID 'BES' FIELD itab-ebeln.
    CALL FUNCTION 'ME_DISPLAY_PURCHASE_DOCUMENT'
         EXPORTING
              i_ebeln = itab-ebeln
              i_enjoy = 'X'.
  ELSEIF p_e_column = 'LIFNR'.
    CALL FUNCTION 'MMPUR_VENDOR_DISPLAY'
         EXPORTING
              im_lifnr = itab-lifnr
              im_ekorg = 'B000'.
  ENDIF.
ENDFORM. " atdoubleclick

CLASS ALV Event相关推荐

  1. ABAP实例之ALV

    *&-----------------------* *& Report  ZLG_ALV                                                ...

  2. ABAP ALV LVC模板

    模板包含选择屏幕.ALV.菜单栏事件.打印程序内容 ******************************************************************** * 事务代 ...

  3. ABAP源码--当前及可用库存查询

    *& REPORT  ZCOK_MM_RINVINQ12. *     System        : ******** ERP项目 *     Module        : MM *    ...

  4. YHLMR009 交货单查询

    *********************************************************************** * Title : YHLMR009 * * Appli ...

  5. WDA-文档-基础篇/进阶篇/讨论篇

    本文介绍SAP官方Dynpro开发文档NET310,以及资深开发顾问编写的完整教程.   链接:http://pan.baidu.com/s/1eR9axpg 密码:kf5m NET310 ABAP ...

  6. ALV DataChange EVENT

    在CX项目中,根据需求,自定义一个表,维护供应商的银行账号信息,当输入供应商编号时,自动在供应商名称列里自动填写供应商名称,用到了ALV  DataChange 事件 ,下面是源代码: *&- ...

  7. OO ALV 设置搜索帮助的三种方式 ONF4 EVENT

    一.在 FIELDCAT 中设置参照 二.CALL FUNCTION  'F4IF_INT_TABLE_VALUE_REQUEST ' 三.CALL FUNCTION ' HELP_VALUES_GE ...

  8. 实战ALV OO技术实现添加工具条按钮

    REPORT  Z_ALV_ERIC. *定义使用图标,按钮使用 INCLUDE <ICON>. *定义事件类型 CLASS LCL_EVENT_RECEIVER DEFINITION D ...

  9. ALV面向对象方法研究:添加自定义工具栏(三)

    本文主要讲解添加自定义工具栏. 跟双击一样,添加自定义的工具栏其实也是在CLASS里面添加方法并实现之. 引进图标: INCLUDE <ICON>. 定义: * 定义事件属性跟方法 CLA ...

最新文章

  1. 人人都能看懂的 6 种限流实现方案!(纯干货)
  2. vue实现pdf导出,解决生成canvas模糊等问题
  3. (pytorch-深度学习系列)正向传播与反向传播-学习笔记
  4. python画平面直角坐标系_Python 数据可视化:重新认识坐标系
  5. 简述oracle函数的功能,Oracle 最常用功能函数经典汇总 (zz)
  6. 【Hive】性能调优 - EXPLAIN
  7. CSS3 transform-style 属性
  8. spring 视频教程
  9. 高数竞赛、数学建模、算法、计算机专业书籍等亲情大甩卖
  10. Androidstudio ADB调试
  11. 【MySQL】按各科成绩进行排序,并显示排名
  12. 如何实现app直播源代码,通过HLS进行直播观看
  13. 微信小程序实现单选、全选、反选、取消全选功能
  14. 如何检查电脑端安装的Flash Activex 控件版本?
  15. 【Java语言】项目实践:汽车租赁系统(源码)(面向对象方法)
  16. 论文阅读:Adaptive Graph Convolution for Point Cloud analysis
  17. vue学习笔记 element-plus/icons-vue el-menu动态菜单(路由)
  18. {转}我们需要什么样的人生
  19. 使用循环语句判断月份是31天还是30天?
  20. U9 实体操作API参考手册

热门文章

  1. 软件工程(2018)第1次团队作业
  2. Linux 服务器如何修改主机名
  3. 25个创意的交互式图表设计欣赏
  4. Secure Delivery Center (SDC)功能概述
  5. Linux系统灾难恢复技术和方法-[3]
  6. Word 2007中隐藏段落和格式标记
  7. 数据分析能力到底有多重要
  8. 用友U9 cloud助力临工重机实现定制化生产
  9. linux网络配置详细
  10. java面试-Java并发编程(九)——批量获取多条线程的执行结果