首页 > 其他分享 >VA02/VA03增加alv

VA02/VA03增加alv

时间:2024-07-22 16:53:44浏览次数:11  
标签:GT GS TYPE ALV LS alv EXCLUDE VA03 VA02

项目背景:

  搞备库单(新建一种类型的销售订单),备库单不出货(通过排程明细类别控制,也需要新增),正式销售订单创建时,备库单分配数量给正式SO,SO的排程明细类别也是新增的(不跑MRP),

创建后,如果备库单已有库存,则从备库单直接自动调拨库存到正式SO上,还有其它的一些增强还有控制,这里不说了。只能说这种需求能不做就尽量不做。后台作业太多了,各种错误都有。还得设置专门

修复错误的程序。

  这里贴上VA02显示分配的情况(自建表)

 

 

MODULE SHOW_BKD_DATA OUTPUT.
*  CHECK SY-UNAME EQ 'MISHM'.
  CHECK SY-TCODE EQ 'VA02' OR SY-TCODE EQ 'VA03'.
  "

  DEFINE %_SET_FCAT.
    CLEAR: GS_FIELDCAT.
    GS_FIELDCAT-FIELDNAME = &1.       "字段名称
    GS_FIELDCAT-COLTEXT   = &2.       "字段描述
    GS_FIELDCAT-REPTEXT   = &2.       "字段描述
    GS_FIELDCAT-SCRTEXT_S = &2.       "字段描述
    GS_FIELDCAT-SCRTEXT_M = &2.       "字段描述
    GS_FIELDCAT-SCRTEXT_L = &2.       "字段描述
    GS_FIELDCAT-HOTSPOT   = &3.       "单机敏感热点事件
    GS_FIELDCAT-KEY       = &4.       "关键字段
    GS_FIELDCAT-NO_ZERO   = &5.       "隐藏前导零
    GS_FIELDCAT-EDIT      = &6.       "可编辑
    GS_FIELDCAT-CHECKBOX  = &7.       "复选框
    GS_FIELDCAT-REF_TABLE = &8.       "参考表
    GS_FIELDCAT-REF_FIELD = &9.       "参考字段
    APPEND GS_FIELDCAT TO LT_FIELDCAT.
  END-OF-DEFINITION.
  DATA:
*       GV_CONTAINER TYPE REF TO CL_GUI_DOCKING_CONTAINER,
       GV_ALV           TYPE REF TO CL_GUI_ALV_GRID ,             "ALV网格
       GV_ROW_ALV       TYPE REF TO CL_GUI_ALV_GRID_BASE,
       GT_EXCLUDE       TYPE UI_FUNCTIONS,                        "用于去掉不要的菜单栏
       GV_INDEX_COLUMNS TYPE LVC_T_COL,                           "选择列
       LT_FIELDCAT      TYPE LVC_T_FCAT,                          "fcat
       GS_FIELDCAT      TYPE LVC_S_FCAT,                  "fcat
       GT_F4            TYPE LVC_T_F4 WITH HEADER LINE,           "搜索帮助
       GS_LAYOUT        TYPE LVC_S_LAYO ,                         "布局结构
       GS_VARIANT       TYPE DISVARIANT,                          "字段格式保存
       GT_SORT          TYPE LVC_T_SORT,                          "用于排序
       GT_INDEX         TYPE LVC_T_COL,                           "选择列
       GT_FILT          TYPE LVC_T_FILT.                          "用于过滤
  DATA:GT_NU3_ROWS TYPE LVC_T_ROW,
       GT_NU3_NO   TYPE  LVC_T_ROID,
       GS_NU3_NO   TYPE  LVC_S_ROID.
  DATA:GV_LINES TYPE I.
  DATA: BEGIN OF GT_EXCLTAB OCCURS 0, "隐藏工具栏按钮
          FCODE LIKE SY-UCOMM,
        END OF GT_EXCLTAB.

  DATA:
        G_CUSTOM_CONTAINER2 TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
        G_CONTAINER2        TYPE SCRFNAME VALUE 'Z_BKD_ALV'.

  IF GV_ALV IS INITIAL .      "ALV对象如果为空,则生成对象,把ALV放入容器中
    CREATE OBJECT G_CUSTOM_CONTAINER2
      EXPORTING
        CONTAINER_NAME = G_CONTAINER2.

    CREATE OBJECT GV_ALV
      EXPORTING
        I_PARENT = G_CUSTOM_CONTAINER2.

*    PERFORM FRM_PREPARE_LAYOUT       CHANGING GS_LAYOUT .        "获取样式
    GS_LAYOUT-NO_ROWMARK = 'X'.        "禁用行选择
    GS_LAYOUT-CWIDTH_OPT = 'X'.        "最优化宽度
    GS_LAYOUT-ZEBRA      = 'X'.        "间隔颜色(斑马线)
    GS_LAYOUT-STYLEFNAME = 'CELLTAB'.  "单元格可编辑控制字段
    GS_LAYOUT-CTAB_FNAME = 'CELLCOLOR'."颜色控制字段

*    PERFORM FRM_BUILD_FIELDCAT .                                 "获取字段格式
    CLEAR:LT_FIELDCAT.
    %_SET_FCAT 'VKORG'      '銷售組織'                ''  ''  ''  ''  ''  'ZHMSBKALV'  'VKORG'.
    %_SET_FCAT 'ZVBELN'     '備庫單(虛擬SO)'          ''  ''  ''  ''  ''  'ZHMSBKALV'  'ZVBELN'.
    %_SET_FCAT 'ZPOSNR'     '備庫單(虛擬SO)行項目'    ''  ''  ''  ''  ''  'ZHMSBKALV'  'ZPOSNR'.
    %_SET_FCAT 'VBELN'      '正式銷售訂單'            ''  ''  ''  ''  ''  'ZHMSBKALV'  'VBELN'.
    %_SET_FCAT 'POSNR'      '正式銷售訂單行項目'      ''  ''  ''  ''  ''  'ZHMSBKALV'  'POSNR'.
    %_SET_FCAT 'MATNR'      '物料號碼'                ''  ''  ''  ''  ''  'ZHMSBKALV'  'MATNR'.
    %_SET_FCAT 'ZKWMENG_C'  '待調撥(冲销)数量'        ''  ''  ''  ''  ''  'ZHMSBKALV'  'ZKWMENG_C'.
    %_SET_FCAT 'ZKWMENG_F'  '分配的數量'              ''  ''  ''  ''  ''  'ZHMSBKALV'  'ZKWMENG_F'.


*    PERFORM FRM_EXCLUDE_TB_FUNCTIONS CHANGING GT_EXCLUDE .       "去掉不用的菜单按钮
    DATA LS_EXCLUDE TYPE UI_FUNC.

    LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_APPEND_ROW .
    APPEND LS_EXCLUDE TO GT_EXCLUDE.
    LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_COPY .
    APPEND LS_EXCLUDE TO GT_EXCLUDE.
    LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_COPY_ROW .
    APPEND LS_EXCLUDE TO GT_EXCLUDE.
    LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_CUT .
    APPEND LS_EXCLUDE TO GT_EXCLUDE.
    LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_INSERT_ROW .
    APPEND LS_EXCLUDE TO GT_EXCLUDE.
    LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_DELETE_ROW .
    APPEND LS_EXCLUDE TO GT_EXCLUDE.
    LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_MOVE_ROW .
    APPEND LS_EXCLUDE TO GT_EXCLUDE.
    LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_PASTE .
    APPEND LS_EXCLUDE TO GT_EXCLUDE.
    LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_PASTE_NEW_ROW .
    APPEND LS_EXCLUDE TO GT_EXCLUDE.
    LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_UNDO .
    APPEND LS_EXCLUDE TO GT_EXCLUDE.
    LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_PRINT .
    APPEND LS_EXCLUDE TO GT_EXCLUDE.
    LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_MB_VIEW .
    APPEND LS_EXCLUDE TO GT_EXCLUDE.
    LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_INFO .
    APPEND LS_EXCLUDE TO GT_EXCLUDE.

*    PERFORM FRM_EVENTLOAD .                                      "读取事件(总)
    DATA LV_EVENT_HANDLER TYPE REF TO LCL_EVENT_HANDLER .  "事件响应
    DATA:LT_F4 TYPE LVC_T_F4 WITH HEADER LINE. "F4帮助
    CREATE OBJECT LV_EVENT_HANDLER.
*
    IF GV_ALV IS NOT INITIAL.
      "注册单元格可编辑事件
      CALL METHOD GV_ALV->SET_READY_FOR_INPUT
        EXPORTING
          I_READY_FOR_INPUT = 1.
      "注册回车触发单元格校验事件
      CALL METHOD GV_ALV->REGISTER_EDIT_EVENT
        EXPORTING
          I_EVENT_ID = CL_GUI_ALV_GRID=>MC_EVT_ENTER
        EXCEPTIONS
          ERROR      = 1
          OTHERS     = 2.
      "注册鼠标移动触发单元格校验事件
      CALL METHOD GV_ALV->REGISTER_EDIT_EVENT
        EXPORTING
          I_EVENT_ID = CL_GUI_ALV_GRID=>MC_EVT_MODIFIED
        EXCEPTIONS
          ERROR      = 1
          OTHERS     = 2.
      "注册搜索帮助事件
*    lt_f4[] = VALUE #( ( fieldname = 'ZXSY'  register = 'X' getbefore = 'X' chngeafter = 'X' ) ).
      CALL METHOD GV_ALV->REGISTER_F4_FOR_FIELDS
        EXPORTING
          IT_F4 = LT_F4[].

      "为ALV添加按钮
      SET HANDLER LV_EVENT_HANDLER->HANDLE_TOOLBAR FOR GV_ALV .
      "数据更新事件
      SET HANDLER LV_EVENT_HANDLER->HANDLE_DATA_CHANGED FOR GV_ALV.
      "数据更新完成后事件
      SET HANDLER LV_EVENT_HANDLER->HANDLE_DATA_CHANGED_FINISHED FOR GV_ALV.
      "单机事件
      SET HANDLER LV_EVENT_HANDLER->HANDLE_HOTSPOT_CLICK FOR GV_ALV.
      "双击事件
      SET HANDLER LV_EVENT_HANDLER->HANDLE_DOUBLE_CLICK FOR GV_ALV.
      "按钮触发前事件
      SET HANDLER LV_EVENT_HANDLER->HANDLE_BEFORE_USER_COMMAND FOR GV_ALV.
      "搜索帮助事件
      SET HANDLER LV_EVENT_HANDLER->HANDLE_ONF4 FOR GV_ALV.

      DATA LV_EVENT_HANDLER1 TYPE REF TO LCL_EVENT_HANDLER .  "事件响应
      CREATE OBJECT LV_EVENT_HANDLER1.
    ENDIF.

    IF GT_ALV[] IS INITIAL.
      CASE VBAK-AUART.
        WHEN 'ZBK1'."備庫單
          SELECT *
            INTO CORRESPONDING FIELDS OF TABLE GT_ALV
            FROM ZHMTSDXH01
           WHERE ZVBELN EQ VBAK-VBELN. "備庫單

        WHEN OTHERS."正式SO
          SELECT *
            INTO CORRESPONDING FIELDS OF TABLE GT_ALV
            FROM ZHMTSDXH01
           WHERE VBELN EQ VBAK-VBELN. "正式SO
      ENDCASE.
    ENDIF.
    LOOP AT GT_ALV INTO GS_ALV.
      IF GS_ALV-ZFLAG EQ 'X'.
        GS_ALV-ZKWMENG_C = 0.
      ENDIF.
      MODIFY GT_ALV FROM GS_ALV .
      CLEAR GS_ALV.
    ENDLOOP.
*----------------------显示ALV--------------------------
    CLEAR GS_VARIANT.
    GS_VARIANT-REPORT = SY-REPID.
    GS_VARIANT-HANDLE = 9000.
    CALL METHOD GV_ALV->SET_TABLE_FOR_FIRST_DISPLAY
      EXPORTING
        IS_LAYOUT                     = GS_LAYOUT
        IT_TOOLBAR_EXCLUDING          = GT_EXCLUDE
        IS_VARIANT                    = GS_VARIANT
        I_SAVE                        = 'A'
      CHANGING
        IT_OUTTAB                     = GT_ALV
        IT_FIELDCATALOG               = LT_FIELDCAT
      EXCEPTIONS
        INVALID_PARAMETER_COMBINATION = 0
        PROGRAM_ERROR                 = 0
        TOO_MANY_LINES                = 0
        OTHERS                        = 0.
  ELSE .

    CASE VBAK-AUART.
      WHEN 'ZBK1'."備庫單
        SELECT *
          INTO CORRESPONDING FIELDS OF TABLE GT_ALV
          FROM ZHMTSDXH01
         WHERE ZVBELN EQ VBAK-VBELN. "備庫單

      WHEN OTHERS."正式SO
        SELECT *
          INTO CORRESPONDING FIELDS OF TABLE GT_ALV
          FROM ZHMTSDXH01
         WHERE VBELN EQ VBAK-VBELN. "正式SO
    ENDCASE.

    LOOP AT GT_ALV INTO GS_ALV.
      IF GS_ALV-ZFLAG EQ 'X'.
        GS_ALV-ZKWMENG_C = 0.
      ENDIF.
      MODIFY GT_ALV FROM GS_ALV .
      CLEAR GS_ALV.
    ENDLOOP.

*    PERFORM FRM_REFURBISH_ALV. "刷新ALV
    DATA:LS_STABLE TYPE LVC_S_STBL.

    CALL METHOD GV_ALV->SET_FRONTEND_LAYOUT
      EXPORTING
        IS_LAYOUT = GS_LAYOUT.
    LS_STABLE-ROW = 'X'.
    LS_STABLE-COL = 'X'.
    CALL METHOD GV_ALV->REFRESH_TABLE_DISPLAY
      EXPORTING
        IS_STABLE = LS_STABLE
      EXCEPTIONS
        FINISHED  = 0
        OTHERS    = 0.
  ENDIF .

ENDMODULE.                    "SHOW_BKD_DATA OUTPUT
View Code

 

标签:GT,GS,TYPE,ALV,LS,alv,EXCLUDE,VA03,VA02
From: https://www.cnblogs.com/chaguoguo/p/18316371

相关文章

  • VisualVM第一章-VisualVM的下载和使用
    一、下载地址VisualVMDownload二、安装解压缩后编辑visualvm/etc/visualvm.conf文件,尾部插入visualvm_jdkhome=你的jdk目录,例如我的:visualvm_jdkhome="D:/software/runtime/jdk-17.0.5"三、使用VisualVM选择你要查看的应用进程,双击3.1概览以下是应用程序的概览部分,......
  • SAP ABAP ALV中列项目添加检索帮助
    ALV列项目自定义检索帮助发布日期:2024/07/15大多数时候,我们需要定义alv事件时会直接用OOALV实现,这样定义事件比较简洁。但有时候,我们在初期用REUSE_ALV_GRID_DISPLAY_LVC简单地实现了一个ALV,但后续要求我们为alv的列项目追加检索帮助,此时我们就需要为函数添加事件。案......
  • GraalVM简介及使用
    在本文中,我们将回顾GraalVM是什么、它是如何工作的,以及即时(JIT)编译和提前(AOT)编译之间的区别?GraalVM是一种高性能运行时,为用Java和其他语言编写的应用程序提供了显着的优势。它由Oracle开发,通过利用高级优化和独特的架构,可以更快、更高效地运行应用程序。1.......
  • RealVNC远程连接Ubuntu20.04(无显示器,开机后可连接)
    场景远程连接工控机时,无法使用VNC连接。需要以下配置菜可以在无屏幕情况下远程直接连接工控机,主要包括:使用Ubuntu内置的vinoVNC提供远程桌面访问。配置自动登录配置虚拟桌面环境Ubuntu20.04配置1、安装Ubuntu内置的桌面共享VNC服务vino。sudoaptinstallvino在“设置->共享->屏......
  • 如何读取 ALV 列表中保存的布局元数据?
    我有一个ALV列表作为程序的输出,并且需要能够动态获取/提取列及其位置。用户还可以将列/位置保存为布局以供将来使用,我希望获取已保存布局的相关信息。我希望以内部表格的形式获取ALV列表的列及其位置,以便进一步使用,例如,生成.xls文件。获取和保......
  • 【雷丰阳-谷粒商城 】【分布式高级篇-微服务架构篇】【13】压力压测JMeter-性能监控jv
    持续学习&持续更新中…守破离【雷丰阳-谷粒商城】【分布式高级篇-微服务架构篇】【13】压力压测JMeter-性能监控jvisualvm压力测试概述性能指标JMeter基本使用添加线程组添加HTTP请求添加监听器启动压测&查看分析结果JMeterAddressAlreadyinuse错误解决性......
  • SAP: SALV Grid 单元格颜色
    1、SAP:SALVGrid单元格颜色2、详细程序代码*&---------------------------------------------------------------------**&ReportZ17_43*&*&---------------------------------------------------------------------**&SALV单元格颜色*&*&---------......
  • C# get TotalVisibleMemorySize FreePhysicalMemory TotalVirtualMemorySize FreeVirt
    1.InstallSystem.ManagementinNuget;2usingSystem.Management;namespaceConsoleApp37{internalclassProgram{staticvoidMain(string[]args){System.Timers.Timertm=newSystem.Timers.Timer();tm.......
  • SAP:SALV双击事件(Double Click)
    *&---------------------------------------------------------------------**&ReportZ17_30*&*&---------------------------------------------------------------------**&SALV双击事件*&*&------------------------------------------------......
  • SAP: SALV 利用控制器的模式
    SAP:SALV 例子利用控制器的模式利用控制器的SALV方法与实际业务中最常用的利用GRID显示ALV的方法其步骤一样。为了在画面上显示ALV事例,必须要存在连接画面和ALVGRID控件的SAP容器控件。SAP控制器为了充当LINKER将SAP控件包含于自己的领域。SAP控件包含SAPTree、SAPPIC......