二维码

OOalv实现超市分类查询报表

Twilight发表于 2015-03-04 16:58Twilight 最后回复于 2015-03-04 16:58 [复制链接] 6033 0

包含功能:
1、显示、编辑 模式下工具栏保存按钮状态的可用性控制
2、ooALV添加自定义按钮
3、ooalv界面是否可编辑
4、alv checkbox复选框

程序代码:
  1. REPORT zpur_market_002 MESSAGE-ID 00.

  2. *&---------------------------------------------------------------------*
  3. *& INCLUDE
  4. *&---------------------------------------------------------------------*
  5. INCLUDE zpur_market_002_top.                "Type/Data
  6. INCLUDE zpur_market_002_class.        "Class
  7. INCLUDE zpur_market_002_selscr.        "Selection screen
  8. INCLUDE zpur_market_002_form.                "Form
  9. INCLUDE zpur_market_002_module.        "Module

  10. *&---------------------------------------------------------------------*
  11. *& 初始化处理
  12. *&---------------------------------------------------------------------*
  13. *INITIALIZATION.
  14. *  PERFORM xxxxxxx.

  15. *&---------------------------------------------------------------------*
  16. *& 选择屏幕控制
  17. *&---------------------------------------------------------------------*
  18. AT SELECTION-SCREEN OUTPUT.
  19. PERFORM f_modify_screen.

  20. *&---------------------------------------------------------------------*
  21. *& 参数输入检查
  22. *&---------------------------------------------------------------------*
  23. *AT SELECTION-SCREEN.
  24. *  PERFORM xxxxxxx.

  25. *&---------------------------------------------------------------------*
  26. *& 程序开始处理
  27. *&---------------------------------------------------------------------*
  28. START-OF-SELECTION.
  29.   PERFORM f_get_all_data. "取数逻辑
  30.   IF gt_output[] IS NOT INITIAL.
  31.     CLEAR: gt_status_9000,gs_status_9000.
  32.     IF p_disp = 'X'.
  33.       gs_status_9000-fcode = 'SAVE'.
  34.       APPEND gs_status_9000 TO gt_status_9000.
  35.     ENDIF.
  36.     CALL SCREEN 9000.
  37.   ELSE.
  38.     MESSAGE s001(00) DISPLAY LIKE 'E' WITH '没有符合要求的数据!'.
  39.     EXIT.
  40.   ENDIF.
复制代码

INCLUDE zpur_market_002_top.
  1. *&---------------------------------------------------------------------*
  2. *&  包括              ZPUR_MARKET_002_TOP
  3. *&---------------------------------------------------------------------*
  4. CLASS zpu_cl_event_receiver DEFINITION DEFERRED.
  5. TYPE-POOLS:icon.
  6. TABLES:t001w,mara,zpu_matnr_d.
  7. TYPES:BEGIN OF ty_matnr_dl,
  8.        matnr       TYPE zpu_matnr_d-matnr,
  9.        lifnr       TYPE zpu_matnr_d-lifnr,
  10.        werks_d     TYPE zpu_matnr_d-werks_d,
  11.        oder_flag   TYPE zpu_matnr_d-oder_flag,
  12.        send_flag   TYPE zpu_matnr_d-send_flag,
  13.        datae       TYPE zpu_matnr_d-datae,
  14.        datab       TYPE zpu_matnr_d-datab,
  15.        del_flag    TYPE zpu_matnr_d-del_flag,
  16.       END OF ty_matnr_dl.
  17. TYPES:BEGIN OF ty_matnr_ps,
  18.        matnr       TYPE zpu_matnr_p-matnr,
  19.        lifnr       TYPE zpu_matnr_p-lifnr,
  20.        werks_s     TYPE zpu_matnr_p-werks_s,
  21.        oder_flag   TYPE zpu_matnr_p-oder_flag,
  22.        send_flag   TYPE zpu_matnr_p-send_flag,
  23.        datae       TYPE zpu_matnr_p-datae,
  24.        datab       TYPE zpu_matnr_p-datab,
  25.        del_flag    TYPE zpu_matnr_p-del_flag,
  26.       END OF ty_matnr_ps.
  27. TYPES:BEGIN OF ty_mod,
  28.         row TYPE i,
  29.       END OF ty_mod.
  30. TYPES:BEGIN OF ty_excltab,
  31.         fcode LIKE sy-ucomm,
  32.       END OF ty_excltab.

  33. DATA:BEGIN OF gt_output OCCURS 0,
  34.       matnr     TYPE mara-matnr,            "商品编码
  35.       maktx     TYPE makt-maktx,            "商品名称
  36.       lifnr     TYPE lfa1-lifnr,            "供应商编码
  37.       name1     TYPE lfa1-name1,            "供应商名称
  38.       werks     TYPE t001w-werks,           "地点
  39.       name_w    TYPE t001w-name1,           "地点名称
  40.       werks_cl(4),                          "地点种类
  41.       matnr_at(8),                          "商品属性
  42.       oder_flag TYPE zpu_matnr_s-oder_flag, "可订购标识
  43.       send_flag TYPE zpu_matnr_s-send_flag, "可出货标识
  44.       datab     TYPE zpu_matnr_s-datab,     "有效开始日期
  45.       datae     TYPE zpu_matnr_s-datae,     "有效截至日期
  46.       del_flag  TYPE zpu_matnr_s-del_flag,  "删除标识
  47.      END OF gt_output.

  48. DATA:gt_matnr_d TYPE TABLE OF ty_matnr_dl WITH HEADER LINE,
  49.      gt_matnr_l TYPE TABLE OF ty_matnr_dl WITH HEADER LINE,
  50.      gt_matnr_p TYPE TABLE OF ty_matnr_ps WITH HEADER LINE,
  51.      gt_matnr_s TYPE TABLE OF ty_matnr_ps WITH HEADER LINE.
  52. DATA:gt_mod TYPE STANDARD TABLE OF ty_mod WITH HEADER LINE.

  53. DATA:go_grid    TYPE REF TO cl_gui_alv_grid,
  54.      go_event_receiver TYPE REF TO zpu_cl_event_receiver.
  55. DATA:gt_functions TYPE ui_functions. "隐藏按钮的内表
  56. DATA: gs_stable TYPE lvc_s_stbl.
  57. gs_stable-row = 'X'.
  58. gs_stable-col = 'X'.
  59. *定义两个变量用来存储变灰的按钮信息
  60. DATA:gt_status_9000 TYPE TABLE OF ty_excltab, " Application toolbar exclude options
  61.      gs_status_9000 TYPE ty_excltab.

  62. DATA:gt_fieldcat_lvc TYPE lvc_t_fcat.
  63. DATA:gs_fieldcat_lvc TYPE LINE OF lvc_t_fcat.
  64. DATA:gs_layout_lvc TYPE lvc_s_layo.

  65. DATA: ok_code LIKE sy-ucomm.
  66. DATA: save_ok LIKE sy-ucomm.
复制代码

INCLUDE zpur_market_002_class.
  1. *&---------------------------------------------------------------------*
  2. *&  包括              ZPUR_MARKET_002_CLASS
  3. *&---------------------------------------------------------------------*
  4. *----------------------------------------------------------------------*
  5. *       CLASS zpu_cl_event_receiver DEFINITION
  6. *----------------------------------------------------------------------*
  7. *
  8. *----------------------------------------------------------------------*
  9. CLASS zpu_cl_event_receiver DEFINITION.
  10.   PUBLIC SECTION.
  11.     METHODS:
  12.     handle_toolbar        FOR EVENT toolbar OF cl_gui_alv_grid
  13.         IMPORTING e_object e_interactive,
  14.     handle_user_command   FOR EVENT user_command OF cl_gui_alv_grid
  15.         IMPORTING e_ucomm,
  16.     handle_data_changed   FOR EVENT data_changed OF cl_gui_alv_grid
  17.         IMPORTING er_data_changed.
  18. ENDCLASS.                    "zpu_CL_EVENT_RECEIVER DEFINITION
  19. *----------------------------------------------------------------------*
  20. *       CLASS zpu_cl_event_receiver IMPLEMENTATION
  21. *----------------------------------------------------------------------*
  22. *
  23. *----------------------------------------------------------------------*
  24. CLASS zpu_cl_event_receiver IMPLEMENTATION.
  25.   METHOD handle_toolbar.
  26.     DATA:ls_toolbar TYPE stb_button.
  27.     CLEAR ls_toolbar.
  28.     ls_toolbar-function = 'B_DELX_FLAG'.
  29.     ls_toolbar-icon = icon_delete.
  30.     ls_toolbar-quickinfo = '删除'.
  31.     ls_toolbar-text = '删除'.
  32.     ls_toolbar-butn_type = '0'.
  33.     APPEND ls_toolbar TO e_object->mt_toolbar.
  34.     CLEAR ls_toolbar.
  35.     ls_toolbar-function = 'B_DEL_FLAG'.
  36.     ls_toolbar-icon = icon_system_undo.
  37.     ls_toolbar-quickinfo = '取消删除'.
  38.     ls_toolbar-text = '取消删除'.
  39.     ls_toolbar-butn_type = '0'.
  40.     APPEND ls_toolbar TO e_object->mt_toolbar.
  41.     CLEAR ls_toolbar.
  42.     ls_toolbar-function = 'B_ODER_FLAG'.
  43.     ls_toolbar-icon = icon_mass_change.
  44.     ls_toolbar-quickinfo = '批量更改可订购'.
  45.     ls_toolbar-text = '批量更改可订购'.
  46.     ls_toolbar-butn_type = '0'.
  47.     APPEND ls_toolbar TO e_object->mt_toolbar.
  48.     CLEAR ls_toolbar.
  49.     ls_toolbar-function = 'B_SEND_FLAG'.
  50.     ls_toolbar-icon = icon_mass_change.
  51.     ls_toolbar-quickinfo = '批量更改可出货'.
  52.     ls_toolbar-text = '批量更改可出货'.
  53.     ls_toolbar-butn_type = '0'.
  54.     APPEND ls_toolbar TO e_object->mt_toolbar.
  55.   ENDMETHOD.                    "HANDLE_TOOLBAR
  56. *处理功能码事件
  57.   METHOD handle_user_command.
  58.     CASE e_ucomm.
  59.       WHEN 'B_DELX_FLAG'.
  60.         PERFORM f_change_del_flag USING 'X'.
  61.       WHEN 'B_DEL_FLAG'.
  62.         PERFORM f_change_del_flag USING ''.
  63.       WHEN 'B_ODER_FLAG'.
  64.         PERFORM f_change_oder_flag.
  65.       WHEN 'B_SEND_FLAG'.
  66.         PERFORM f_change_send_flag.
  67.     ENDCASE.
  68.     CALL METHOD go_grid->refresh_table_display "刷新
  69.      EXPORTING
  70.        is_stable      = gs_stable.
  71.   ENDMETHOD.                    "HANDLE_USER_COMMAND

  72.   METHOD handle_data_changed.
  73.     PERFORM f_handle_data_changed USING er_data_changed .
  74.   ENDMETHOD.                    "handle_data_changed

  75. ENDCLASS.                    "zpu_CL_EVENT_RECEIVER IMPLEMENTATION
复制代码

INCLUDE zpur_market_002_selscr.
  1. *&---------------------------------------------------------------------*
  2. *&  包括              ZPUR_MARKET_002_SELSCR
  3. *&---------------------------------------------------------------------*
  4. SELECTION-SCREEN BEGIN OF BLOCK block1 WITH FRAME TITLE text-001.
  5. SELECT-OPTIONS:s_werks FOR t001w-werks,
  6.                s_matnr FOR mara-matnr,
  7.                s_prdha FOR mara-prdha,
  8.                s_matkl FOR mara-matkl,
  9.                s_lifnr FOR zpu_matnr_d-lifnr.
  10. SELECT-OPTIONS:s_oderf FOR zpu_matnr_d-oder_flag.
  11. SELECT-OPTIONS:s_sendf FOR zpu_matnr_d-send_flag.
  12. PARAMETER: p_over AS CHECKBOX DEFAULT 'X' MODIF ID ove,
  13.            p_dele AS CHECKBOX DEFAULT 'X' MODIF ID del.
  14. SELECTION-SCREEN END OF BLOCK block1.
  15. SELECTION-SCREEN BEGIN OF BLOCK block2 WITH FRAME TITLE text-002.
  16. PARAMETER: p_disp RADIOBUTTON GROUP gp1 DEFAULT 'X' USER-COMMAND singleclick.
  17. PARAMETER: p_edit RADIOBUTTON GROUP gp1.
  18. SELECTION-SCREEN END OF BLOCK block2.
复制代码
回复

使用道具 举报

快速回帖

本版积分规则
您需要登录后才可以回帖 登录 | 注册有礼

快速回复 返回顶部 返回列表