SAP ABAP实现类似于ME23N/MIGO的折叠屏幕开发

本文用于说明折叠屏幕的开发实现方式,类似于标准前台ME23N或者MIGO类似的效果,最终demo程序实现效果如下。

实际上屏幕折叠并不是真正的控件,而是根据想要的折叠或者展开效果,来选择不同的子屏幕进行展现。

比如下图点击折叠抬头按钮后,变为右图的效果,实际上是进行了子屏幕切换 

SAP ABAP实现类似于ME23N/MIGO的折叠屏幕开发_第1张图片SAP ABAP实现类似于ME23N/MIGO的折叠屏幕开发_第2张图片

 同理如果再次点击折叠中间明细区域的按钮,则是将子屏幕9002切换为9003

SAP ABAP实现类似于ME23N/MIGO的折叠屏幕开发_第3张图片

SAP ABAP实现类似于ME23N/MIGO的折叠屏幕开发_第4张图片

 其他屏幕同理,所以当我们折叠区域有三个的时候,要覆盖到所有展开关闭的情况,总共需要8种组合来应对。(哪有什么折叠屏幕,只是有很多子屏幕在负重前行)

SAP ABAP实现类似于ME23N/MIGO的折叠屏幕开发_第5张图片

 以下是开发实现部分:

1.首先创建主屏幕9000,其中包含一块子屏幕区域,这个区域也就是后续点击展开关闭按钮,要去动态切换的区域,demo里我默认了初始为上面9001的展开模式。

SAP ABAP实现类似于ME23N/MIGO的折叠屏幕开发_第6张图片

 SAP ABAP实现类似于ME23N/MIGO的折叠屏幕开发_第7张图片

 SAP ABAP实现类似于ME23N/MIGO的折叠屏幕开发_第8张图片

 2.创建第一个子屏幕9001(其中9101,9102,9103分别代表抬头,明细,详情区域的子屏幕)

SAP ABAP实现类似于ME23N/MIGO的折叠屏幕开发_第9张图片

 屏幕流如下:

SAP ABAP实现类似于ME23N/MIGO的折叠屏幕开发_第10张图片

 在USER_COMMAND中对三个展开按钮进行处理,变更全局变量,来达到切换子屏幕的效果,具体每个按钮点完之后应该使用哪个子屏幕,可以对照上面列出的8种场景。

SAP ABAP实现类似于ME23N/MIGO的折叠屏幕开发_第11张图片

 3.同理,参照上面子屏幕9001/9002/9003的屏幕样式,依次创建其他7个子屏幕

SAP ABAP实现类似于ME23N/MIGO的折叠屏幕开发_第12张图片

 SAP ABAP实现类似于ME23N/MIGO的折叠屏幕开发_第13张图片

SAP ABAP实现类似于ME23N/MIGO的折叠屏幕开发_第14张图片

 SAP ABAP实现类似于ME23N/MIGO的折叠屏幕开发_第15张图片SAP ABAP实现类似于ME23N/MIGO的折叠屏幕开发_第16张图片

SAP ABAP实现类似于ME23N/MIGO的折叠屏幕开发_第17张图片

 SAP ABAP实现类似于ME23N/MIGO的折叠屏幕开发_第18张图片

 SAP ABAP实现类似于ME23N/MIGO的折叠屏幕开发_第19张图片

 至此,8种展示方式的子屏幕框架已创建完成,现在继续为上中下三个区域的子屏幕分别创建子屏幕中的具体内容,本例抬头区域(命名后缀为H)跟底部详情区域(命名后缀为B)均为Tabstrip,中间明细区域(命名后缀为C)为TableControl。

4.创建抬头区域子屏幕9101:

SAP ABAP实现类似于ME23N/MIGO的折叠屏幕开发_第20张图片

SAP ABAP实现类似于ME23N/MIGO的折叠屏幕开发_第21张图片

 SAP ABAP实现类似于ME23N/MIGO的折叠屏幕开发_第22张图片

5.继续创建每个TAB页对应的子屏幕:基本信息9201 和 付款信息9202

SAP ABAP实现类似于ME23N/MIGO的折叠屏幕开发_第23张图片

SAP ABAP实现类似于ME23N/MIGO的折叠屏幕开发_第24张图片

6.抬头部分至此完成,继续创建明细部分子屏幕9102:

SAP ABAP实现类似于ME23N/MIGO的折叠屏幕开发_第25张图片

SAP ABAP实现类似于ME23N/MIGO的折叠屏幕开发_第26张图片

7.至此明细区域完成,继续创建详情区域子屏幕9103:

SAP ABAP实现类似于ME23N/MIGO的折叠屏幕开发_第27张图片

SAP ABAP实现类似于ME23N/MIGO的折叠屏幕开发_第28张图片

SAP ABAP实现类似于ME23N/MIGO的折叠屏幕开发_第29张图片 SAP ABAP实现类似于ME23N/MIGO的折叠屏幕开发_第30张图片

 8.继续创建每个TAB页对应的子屏幕:物料数据9301 和 交货计划9302 和采购订单历史9303

SAP ABAP实现类似于ME23N/MIGO的折叠屏幕开发_第31张图片

SAP ABAP实现类似于ME23N/MIGO的折叠屏幕开发_第32张图片 SAP ABAP实现类似于ME23N/MIGO的折叠屏幕开发_第33张图片

 9.最后还有一个跳转其他凭证的小屏幕9401:

SAP ABAP实现类似于ME23N/MIGO的折叠屏幕开发_第34张图片

 10.至此,所有屏幕均已开发完成,基本的屏幕折叠功能已经实现,后面自己可以再加亿点点细节,去完成比如双击明细、单击详情上方下拉list的Key值、单击前后明细切换按钮时,对详情区域进行更新的功能,以及编辑显示切换的功能,以及切换订单等功能。

补充几个小功能的实现:

1.GUI状态栏动态按钮的实现:

SAP ABAP实现类似于ME23N/MIGO的折叠屏幕开发_第35张图片

SAP ABAP实现类似于ME23N/MIGO的折叠屏幕开发_第36张图片

 SAP ABAP实现类似于ME23N/MIGO的折叠屏幕开发_第37张图片

 SAP ABAP实现类似于ME23N/MIGO的折叠屏幕开发_第38张图片

2.灰掉GUI状态的按钮,而不是隐藏掉,一般都是使用SET PF-STATUS 'XXXX' EXCLUDING FCODE_TAB的形式来排除按钮的,默认情况下,这种方式是隐藏掉按钮,而不是灰掉,如果需要灰掉GUI状态栏的按钮,需要对GUI状态栏做以下设置即可:

SAP ABAP实现类似于ME23N/MIGO的折叠屏幕开发_第39张图片

3.TABLE CONTROL的双击回应设置:

SAP ABAP实现类似于ME23N/MIGO的折叠屏幕开发_第40张图片

 SAP ABAP实现类似于ME23N/MIGO的折叠屏幕开发_第41张图片

使用  GET CURSOR LINE GV_CURSOR_LINE. 获取双击的行索引,如果需要获取双击的字段信息,可以使用附加项FIELD参数去获取 ,具体可以查看F1搜索帮助。

4.回车按钮响应码设置:

SAP ABAP实现类似于ME23N/MIGO的折叠屏幕开发_第42张图片

 以下附上完整代码:

主程序:

*&---------------------------------------------------------------------*
*& Report ZME23N_13065
*&---------------------------------------------------------------------*
*& 模拟开发ME23N可折叠屏幕
*&---------------------------------------------------------------------*
REPORT ZME23N_13065.

INCLUDE ZME23N_13065_TOP.

INCLUDE ZME23N_13065_SCR.

INCLUDE ZME23N_13065_FORM.

INCLUDE ZME23N_13065_PBO.

INCLUDE ZME23N_13065_PAI.

  数据定义部分:

*&---------------------------------------------------------------------*
*& 包含               ZME23N_13065_TOP
*&---------------------------------------------------------------------*
TYPES:
* 抬头
  BEGIN OF TY_HEAD,
    EBELN      TYPE EKKO-EBELN,                   "采购订单
    LIFNR      TYPE EKKO-LIFNR,                   "供应商
    BSART      TYPE EKKO-BSART,                   "订单类型
    AEDAT      TYPE EKKO-AEDAT,                   "凭证日期
    ZTERM      TYPE EKKO-ZTERM,                   "付款条件
    WAERS      TYPE EKKO-WAERS,                   "货币
    WKURS      TYPE EKKO-WKURS,                   "汇率
    EKORG      TYPE EKKO-EKORG,                   "采购组织
    EKGRP      TYPE EKKO-EKGRP,                   "采购组
    BUKRS      TYPE EKKO-BUKRS,                   "公司代码
    LIFNR_DESC TYPE CHAR50,                       "供应商描述
  END OF TY_HEAD,

* 明细
  BEGIN OF TY_ITEM,
    EBELN TYPE EKPO-EBELN,                        "采购订单
    EBELP TYPE EKPO-EBELP,                        "明细
    MATNR TYPE EKPO-MATNR,                        "物料号
    TXZ01 TYPE EKPO-TXZ01,                        "描述
    MENGE TYPE EKPO-MENGE,                        "数量
    MEINS TYPE EKPO-MEINS,                        "单位
    NETPR TYPE EKPO-NETPR,                        "金额
    WAERS TYPE EKKO-WAERS,                        "货币

    MATKL TYPE EKPO-MATKL,                        "物料组
    CHARG TYPE EKET-CHARG,                        "批次
    LICHA TYPE EKET-LICHA,                        "供应商批次
    CBOX  TYPE CBOX,                              "选择框
  END OF TY_ITEM,
  TY_TAB_ITEM TYPE STANDARD TABLE OF TY_ITEM,

* 明细-计划行
  BEGIN OF TY_ITEM_9302,
    EBELN TYPE EKPO-EBELN,                        "采购订单
    EBELP TYPE EKPO-EBELP,                        "订单明细
    ETENR TYPE EKET-ETENR,                        "计划行
    EINDT TYPE EKET-EINDT,                        "交货日期
    MENGE TYPE EKET-MENGE,                        "计划数量
    WEMNG TYPE EKET-WEMNG,                        "已交货
    BANFN TYPE EKET-BANFN,                        "采购申请
    BNFPO TYPE EKET-BNFPO,                        "采购申请明细
  END OF TY_ITEM_9302,
  TY_TAB_ITEM_9302 TYPE STANDARD TABLE OF TY_ITEM_9302,

* 采购订单历史
  TY_HISTORY       TYPE ZSME23N_13065_HISTORY,
  TY_TAB_HISTORY   TYPE STANDARD TABLE OF TY_HISTORY.

*全局变量
DATA:
  GS_HEAD        TYPE TY_HEAD,
  GT_ITEM        TYPE TY_TAB_ITEM,
  GS_ITEM        TYPE TY_ITEM,
  GS_ITEM_9301   TYPE TY_ITEM,
  GT_ITEM_9302   TYPE TY_TAB_ITEM_9302,
  GS_ITEM_9302   TYPE TY_ITEM_9302,
  GT_HISTORY     TYPE TY_TAB_HISTORY,
  GS_HISTORY     TYPE TY_HISTORY,
  GV_OK_CODE     TYPE SY-UCOMM,
  GV_SAVE_OK     TYPE SY-UCOMM,
  GV_CURSOR_LINE TYPE SY-LOOPC,
  GV_OTHER_ORDER TYPE EBELN.

*9000屏幕变量
DATA:
  GV_9000_MODE      TYPE SMP_DYNTXT,              "动态按钮
  GV_EDIT           TYPE CHAR1,                   "是否可以编辑
  GV_BSART_VRM_ID   TYPE VRM_ID,                  "屏幕字段名
  GT_BSART_VALUE    TYPE VRM_VALUES,              "字段KEY+VALUE
  GS_BSART_VALUE    TYPE VRM_VALUE,
  GV_9000_TITLE     TYPE STRING,                  "动态标题
  GV_SUBSCREEN_9000 TYPE SY-DYNNR.                "动态指定子屏幕区域

*9101屏幕变量
CONTROLS:
  9101_TAB TYPE TABSTRIP.

*9102屏幕变量
CONTROLS:
  TC_9102 TYPE TABLEVIEW USING SCREEN 9102.
DATA:
  GV_FILL_9102 TYPE I,
  GV_LINE_9102 TYPE I.

*9103屏幕变量
CONTROLS:
  9103_TAB TYPE TABSTRIP.
DATA:
  GV_9103_EBELP   TYPE STRING,                    "下拉框字段
  GV_EBELP_VRM_ID TYPE VRM_ID,                    "屏幕字段名
  GT_EBELP_VALUE  TYPE VRM_VALUES,                "字段KEY+VALUE
  GS_EBELP_VALUE  TYPE VRM_VALUE.

*9302屏幕变量
CONTROLS:
  TC_9302 TYPE TABLEVIEW USING SCREEN 9302.
DATA:
  GV_FILL_9302 TYPE I,
  GV_LINE_9302 TYPE I.

*9303屏幕变量
DATA:
  GV_CONTAINER        TYPE SCRFNAME VALUE '9303_ALV_AREA',
  GO_GRID             TYPE REF TO CL_GUI_ALV_GRID,
  GO_CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
  GS_LAYOUT_9303      TYPE LVC_S_LAYO.

 屏幕定义部分:

*&---------------------------------------------------------------------*
*& 包含               ZME23N_13065_SCR
*&---------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
  PARAMETERS:P_EBELN TYPE EKKO-EBELN OBLIGATORY.
SELECTION-SCREEN END OF BLOCK B1.

INITIALIZATION.
* 初始化选择屏幕
  PERFORM FRM_INIT_SCREEN.

START-OF-SELECTION.
* 初始化全局参数
  PERFORM FRM_INIT_PARA.

* 获取测试数据
  PERFORM FRM_GET_DATA.

* 数据展示
  PERFORM FRM_CALL_SCREEN.

子例程部分:

*&---------------------------------------------------------------------*
*& 包含               ZME23N_13065_FORM
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form FRM_INIT_PARA
*&---------------------------------------------------------------------*
*& 初始化全局参数
*&---------------------------------------------------------------------*
FORM FRM_INIT_PARA .
* 初始TAB页
  9101_TAB-ACTIVETAB = '9101_TAB1'.
  9103_TAB-ACTIVETAB = '9103_TAB1'.

* 初始状态(全部展开)
  GV_SUBSCREEN_9000 = '9001'.


* 初始模式(显示模式)
  GV_9000_MODE-ICON_ID   = ICON_CHANGE.
  GV_9000_MODE-TEXT      = TEXT-002.
  GV_9000_MODE-ICON_TEXT = | { TEXT-002 }|.       "更改

* 初始为不可编辑状态
  GV_EDIT = ''.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form FRM_GET_DATA
*&---------------------------------------------------------------------*
*& 获取测试数据
*&---------------------------------------------------------------------*
FORM FRM_GET_DATA .
* 清除全局变量
  PERFORM FRM_CLEAR_GLOBAL_DATA.

  DATA:
    LV_TABIX TYPE SY-TABIX VALUE 1,
    LV_INDEX TYPE I.

* 获取抬头数据
  SELECT SINGLE
         A~EBELN,                                 "采购订单
         A~LIFNR,                                 "供应商
         A~BSART,                                 "凭证类型
         A~AEDAT,                                 "凭证日期
         A~ZTERM,                                 "付款条件
         A~WAERS,                                 "货币
         A~WKURS,                                 "汇率
         A~EKORG,                                 "采购组织
         A~EKGRP,                                 "采购组
         A~BUKRS,                                 "公司代码
         C~NAME1 AS LIFNR_DESC                    "供应商描述
    INTO @GS_HEAD
    FROM EKKO AS A
   INNER JOIN T001 AS B
      ON A~BUKRS = B~BUKRS
    LEFT OUTER JOIN LFA1 AS C
      ON A~LIFNR = C~LIFNR
     AND C~SPRAS = B~SPRAS
   WHERE EBELN = @P_EBELN.

  GS_HEAD-LIFNR_DESC = |{ GS_HEAD-LIFNR } { GS_HEAD-LIFNR_DESC }|.

* 获取明细数据
  SELECT B~EBELN                                  "采购订单
         B~EBELP                                  "明细
         B~MATNR                                  "物料号
         B~TXZ01                                  "描述
         B~MENGE                                  "数量
         B~MEINS                                  "单位
         B~NETPR                                  "金额
         A~WAERS                                  "货币
         B~MATKL                                  "物料组
         C~CHARG                                  "批次
         C~LICHA                                  "供应商批次
    INTO TABLE GT_ITEM                            "选择框
    FROM EKPO AS B
   INNER JOIN EKKO AS A
      ON B~EBELN = A~EBELN
    LEFT OUTER JOIN EKET AS C
      ON B~EBELN = C~EBELN
     AND B~EBELP = C~EBELP
     AND C~ETENR = 1
   WHERE A~EBELN = P_EBELN.

  SORT GT_ITEM BY EBELN ASCENDING
                  EBELP ASCENDING.

* 采购订单类型
  SELECT BSART,
         BATXT
    INTO TABLE @DATA(LT_T161T)
    FROM T161T
   WHERE SPRAS = @SY-LANGU
     AND BSTYP = 'F'.

  SORT LT_T161T BY BSART ASCENDING.

  READ TABLE LT_T161T INTO DATA(LS_T161T)
    WITH KEY BSART = GS_HEAD-BSART
      BINARY SEARCH.
  IF SY-SUBRC = 0.
    GV_9000_TITLE = |{ LS_T161T-BATXT } { GS_HEAD-EBELN }|.
  ENDIF.

* 采购订单类型下拉list创建
  GV_BSART_VRM_ID = 'GS_HEAD-BSART'.

  LOOP AT LT_T161T INTO LS_T161T.
    GS_BSART_VALUE-KEY  = LS_T161T-BSART.
    GS_BSART_VALUE-TEXT = LS_T161T-BATXT.
    APPEND GS_BSART_VALUE TO GT_BSART_VALUE.
  ENDLOOP.

* 明细细节下拉list创建
  GV_EBELP_VRM_ID = 'GV_9103_EBELP'.

  LOOP AT GT_ITEM INTO DATA(LS_ITEM).
    ADD 1 TO LV_INDEX.
    GS_EBELP_VALUE-KEY  = LV_INDEX.
    GS_EBELP_VALUE-TEXT = |[{ LS_ITEM-EBELP }]{ LS_ITEM-TXZ01 }|.
    CONDENSE GS_EBELP_VALUE-KEY NO-GAPS.
    APPEND GS_EBELP_VALUE TO GT_EBELP_VALUE.
  ENDLOOP.

  GV_9103_EBELP = 1.

* 获取明细细节数据
  PERFORM FRM_GET_ITEM_DATA USING LV_TABIX.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form FRM_CALL_SCREEN
*&---------------------------------------------------------------------*
*& 数据展示
*&---------------------------------------------------------------------*
FORM FRM_CALL_SCREEN .
  CALL SCREEN 9000.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form FRM_MIDIFY_SCREEN
*&---------------------------------------------------------------------*
*& 更新屏幕是否可编辑,将所有可以更新的字段的屏幕属性GROUP1设为GP1
*&---------------------------------------------------------------------*
FORM FRM_MIDIFY_SCREEN .
  LOOP AT SCREEN.
    IF SCREEN-GROUP1 = 'GP1'.
      IF GV_EDIT = 'X'.
        SCREEN-INPUT = 1.
      ELSE.
        SCREEN-INPUT = 0.
      ENDIF.
      MODIFY SCREEN.
    ENDIF.
  ENDLOOP.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form FRM_CHANGE_MODE
*&---------------------------------------------------------------------*
*& 更新编辑模式
*&---------------------------------------------------------------------*
FORM FRM_CHANGE_MODE .
  IF GV_EDIT = 'X'.
    GV_EDIT = ''.

    GV_9000_MODE-ICON_ID   = ICON_CHANGE.
    GV_9000_MODE-TEXT      = TEXT-002.
    GV_9000_MODE-ICON_TEXT = | { TEXT-002 }|.     "更改
  ELSE.
    GV_EDIT = 'X'.

    GV_9000_MODE-ICON_ID   = ICON_DISPLAY.
    GV_9000_MODE-TEXT      = TEXT-003.
    GV_9000_MODE-ICON_TEXT = | { TEXT-003 }|.     "显示
  ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form FRM_GET_ITEM_DETAIL
*&---------------------------------------------------------------------*
*& 获取项目详情数据
*&---------------------------------------------------------------------*
FORM FRM_GET_ITEM_DETAIL .
  CLEAR:
    GT_ITEM_9302,
    GS_ITEM_9302,
    GT_HISTORY.

  DATA:
    LV_TABIX TYPE SY-TABIX.

  LV_TABIX = TC_9102-TOP_LINE + GV_CURSOR_LINE - 1.

* 获取明细数据
  PERFORM FRM_GET_ITEM_DATA USING LV_TABIX.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form FRM_INIT_SCREEN
*&---------------------------------------------------------------------*
*& 初始化选择屏幕
*&---------------------------------------------------------------------*
FORM FRM_INIT_SCREEN .
  P_EBELN = '4500000604'.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form FRM_GET_CURSOR
*&---------------------------------------------------------------------*
*& 获取双击行索引
*&---------------------------------------------------------------------*
FORM FRM_GET_CURSOR .
  CLEAR GV_CURSOR_LINE.
  GET CURSOR LINE GV_CURSOR_LINE.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form FRM_GET_ITEM_DATA
*&---------------------------------------------------------------------*
*& 获取明细数据
*&---------------------------------------------------------------------*
*&      --> UV_TABIX  索引
*&---------------------------------------------------------------------*
FORM FRM_GET_ITEM_DATA  USING UV_TABIX.

  CLEAR:
    GS_ITEM_9301,
    GT_HISTORY.

  READ TABLE GT_ITEM INTO GS_ITEM_9301 INDEX UV_TABIX.

  GV_9103_EBELP = UV_TABIX.

  SELECT EBELN                                    "采购订单
         EBELP                                    "订单明细
         ETENR                                    "计划行
         EINDT                                    "交货日期
         MENGE                                    "计划数量
         WEMNG                                    "已交货
         BANFN                                    "采购申请
         BNFPO                                    "采购申请明细
    INTO TABLE GT_ITEM_9302
    FROM EKET
   WHERE EBELN = GS_ITEM_9301-EBELN
     AND EBELP = GS_ITEM_9301-EBELP.

  SELECT VGART_MKPF                               "交易事件类型
         MBLNR                                    "物料凭证
         MJAHR                                    "物料凭证年份
         ZEILE                                    "物料凭证明细
         BWART                                    "移动类型
         BUDAT_MKPF                               "过账日期
         MENGE                                    "数量
         MEINS                                    "单位
         WAERS                                    "货币
         DMBTR                                    "金额
         EBELN                                    "采购订单
         EBELP                                    "采购订单明细
    INTO TABLE GT_HISTORY
    FROM MSEG
   WHERE EBELN = GS_ITEM_9301-EBELN
     AND EBELP = GS_ITEM_9301-EBELP.

  SORT GT_HISTORY BY VGART_MKPF ASCENDING
                     BWART      ASCENDING
                     MBLNR      ASCENDING
                     ZEILE      ASCENDING.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form FRM_CLEAR_GLOBAL_DATA
*&---------------------------------------------------------------------*
*& 清除全局变量
*&---------------------------------------------------------------------*
FORM FRM_CLEAR_GLOBAL_DATA .
  CLEAR:
    GS_HEAD,
    GT_ITEM,
    GS_ITEM,
    GS_ITEM_9301,
    GT_ITEM_9302,
    GS_ITEM_9302,
    GT_HISTORY,
    GS_HISTORY,
    GT_EBELP_VALUE,
    GT_BSART_VALUE.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form FRM_PROCESS_FCODE
*&---------------------------------------------------------------------*
*& 处理翻页按钮
*&---------------------------------------------------------------------*
*&      --> UV_SIGN
*&---------------------------------------------------------------------*
FORM FRM_PROCESS_FCODE  USING VALUE(UV_SIGN).
  DATA:
    LV_TABIX TYPE SY-TABIX.

  CASE UV_SIGN.
    WHEN '-'.
      LV_TABIX = GV_9103_EBELP - 1.
    WHEN '+'.
      LV_TABIX = GV_9103_EBELP + 1.
    WHEN OTHERS.
  ENDCASE.

  READ TABLE GT_ITEM TRANSPORTING NO FIELDS INDEX LV_TABIX.
  IF SY-SUBRC = 0.
*   获取明细数据
    PERFORM FRM_GET_ITEM_DATA USING LV_TABIX.
  ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form FRM_GET_OTHER_ORDER
*&---------------------------------------------------------------------*
*& 获取其他订单数据
*&---------------------------------------------------------------------*
FORM FRM_GET_OTHER_ORDER .
  CALL SCREEN 9401 STARTING AT 10 1 ENDING AT 50 1.
ENDFORM.

所有屏幕的PBO部分:

*&---------------------------------------------------------------------*
*& 包含               ZME23N_13065_PBO
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Module STATUS_9101 OUTPUT
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
MODULE STATUS_9101 OUTPUT.
* SET PF-STATUS 'xxxxxxxx'.
* SET TITLEBAR 'xxx'.
ENDMODULE.
*&---------------------------------------------------------------------*
*& Module STATUS_9000 OUTPUT
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
MODULE STATUS_9000 OUTPUT.
  SET PF-STATUS 'STATUS_9000'.
  SET TITLEBAR 'TITLE_9000' WITH GV_9000_TITLE.
ENDMODULE.
*&---------------------------------------------------------------------*
*& Module SET_BSART OUTPUT
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
MODULE SET_BSART_9000 OUTPUT.
  CALL FUNCTION 'VRM_SET_VALUES'
    EXPORTING
      ID              = GV_BSART_VRM_ID
      VALUES          = GT_BSART_VALUE
    EXCEPTIONS
      ID_ILLEGAL_NAME = 1
      OTHERS          = 2.
  IF SY-SUBRC <> 0.
* Implement suitable error handling here
  ENDIF.
ENDMODULE.
*&---------------------------------------------------------------------*
*& Module MODIFY_SCREEN_9000 OUTPUT
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
MODULE MODIFY_SCREEN_9000 OUTPUT.
* 更新屏幕编辑状态
  PERFORM FRM_MIDIFY_SCREEN.
ENDMODULE.
*&---------------------------------------------------------------------*
*& Module MODIFY_SCREEN_EDIT OUTPUT
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
MODULE MODIFY_SCREEN_EDIT OUTPUT.
* 更新屏幕编辑状态
  PERFORM FRM_MIDIFY_SCREEN.
ENDMODULE.
*&---------------------------------------------------------------------*
*& Module STATUS_9102 OUTPUT
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
MODULE STATUS_9102 OUTPUT.
  TC_9102-LINES = LINES( GT_ITEM ).
ENDMODULE.
*&---------------------------------------------------------------------*
*& Module FILL_TABLE_CONTROL_9102 OUTPUT
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
MODULE FILL_TABLE_CONTROL_9102 OUTPUT.
  TRY.
      GS_ITEM = GT_ITEM[ TC_9102-CURRENT_LINE ].
    CATCH CX_SY_ITAB_LINE_NOT_FOUND.
      RETURN.
  ENDTRY.
ENDMODULE.
*&---------------------------------------------------------------------*
*& Module STATUS_9302 OUTPUT
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
MODULE STATUS_9302 OUTPUT.
  TC_9302-LINES = LINES( GT_ITEM_9302 ).
ENDMODULE.
*&---------------------------------------------------------------------*
*& Module FILL_TABLE_CONTROL_9302 OUTPUT
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
MODULE FILL_TABLE_CONTROL_9302 OUTPUT.
  TRY.
      GS_ITEM_9302 = GT_ITEM_9302[ TC_9302-CURRENT_LINE ].
    CATCH CX_SY_ITAB_LINE_NOT_FOUND.
      RETURN.
  ENDTRY.
ENDMODULE.
*&---------------------------------------------------------------------*
*& Module STATUS_9103 OUTPUT
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
MODULE STATUS_9103 OUTPUT.
*  PERFORM FRM_GET_ITEM_DETAIL.
ENDMODULE.
*&---------------------------------------------------------------------*
*& Module SET_EBELP_9103 OUTPUT
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
MODULE SET_EBELP_9103 OUTPUT.
  CALL FUNCTION 'VRM_SET_VALUES'
    EXPORTING
      ID              = GV_EBELP_VRM_ID
      VALUES          = GT_EBELP_VALUE
    EXCEPTIONS
      ID_ILLEGAL_NAME = 1
      OTHERS          = 2.
  IF SY-SUBRC <> 0.
* Implement suitable error handling here
  ENDIF.
ENDMODULE.
*&---------------------------------------------------------------------*
*& Module SHOW_HISTORY_DATA OUTPUT
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
MODULE SHOW_HISTORY_DATA OUTPUT.
  IF GO_CUSTOM_CONTAINER IS INITIAL.
    CREATE OBJECT GO_CUSTOM_CONTAINER
      EXPORTING
        CONTAINER_NAME = GV_CONTAINER.

    CREATE OBJECT GO_GRID
      EXPORTING
        I_PARENT = GO_CUSTOM_CONTAINER.

    CALL METHOD GO_GRID->SET_TABLE_FOR_FIRST_DISPLAY
      EXPORTING
        I_STRUCTURE_NAME = 'ZSME23N_13065_HISTORY'
        IS_LAYOUT        = GS_LAYOUT_9303
      CHANGING
        IT_OUTTAB        = GT_HISTORY.
  ELSE.
    CALL METHOD GO_GRID->REFRESH_TABLE_DISPLAY
*      EXPORTING
*        IS_STABLE      =
*        I_SOFT_REFRESH =
      EXCEPTIONS
        FINISHED = 1
        OTHERS   = 2.
    IF SY-SUBRC <> 0.
*     Implement suitable error handling here
    ENDIF.
  ENDIF.
ENDMODULE.
*&---------------------------------------------------------------------*
*& Module HIDE_SOME_TAB OUTPUT
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
MODULE HIDE_SOME_TAB OUTPUT.
  IF GT_HISTORY IS INITIAL.
    LOOP AT SCREEN.
      IF SCREEN-NAME = '9103_TAB3'.
        SCREEN-INVISIBLE = '1'.
        MODIFY SCREEN.
      ENDIF.
    ENDLOOP.
  ENDIF.
ENDMODULE.
*&---------------------------------------------------------------------*
*& Module STATUS_9401 OUTPUT
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
MODULE STATUS_9401 OUTPUT.
  SET PF-STATUS 'STATUS_9401'.
  SET TITLEBAR 'TITLE_9401'.
ENDMODULE.

所有屏幕的PAI部分:

*&---------------------------------------------------------------------*
*& 包含               ZME23N_13065_PAI
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*&      Module  CANCEL  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE CANCEL INPUT.
  LEAVE PROGRAM.
ENDMODULE.
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_9101  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_9101 INPUT.

ENDMODULE.
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_9000  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_9000 INPUT.
  GV_SAVE_OK = GV_OK_CODE.
  CLEAR GV_OK_CODE.

  CASE GV_SAVE_OK.
*   退出
    WHEN 'EXIT' OR 'BACK' OR 'CANCEL'.
      LEAVE TO SCREEN 0.
*   编辑/显示切换
    WHEN '9000_MODE'.
      PERFORM FRM_MIDIFY_SCREEN.
      PERFORM FRM_CHANGE_MODE.
*   获取其他订单数据
    WHEN '9000_OTHER'.
      PERFORM FRM_GET_OTHER_ORDER.
    WHEN OTHERS.
  ENDCASE.
ENDMODULE.
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_9001  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_9001 INPUT.
  CASE SY-UCOMM.
*   抬头关闭按钮
    WHEN '9001_CL_H'.
      GV_SUBSCREEN_9000 = '9002'.
*   明细关闭按钮
    WHEN '9001_CL_C'.
      GV_SUBSCREEN_9000 = '9005'.
*   详情关闭按钮
    WHEN '9001_CL_B'.
      GV_SUBSCREEN_9000 = '9006'.
    WHEN OTHERS.
  ENDCASE.
ENDMODULE.
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_9002  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_9002 INPUT.
  CASE GV_OK_CODE.
*   抬头展开按钮
    WHEN '9002_EX_H'.
      GV_SUBSCREEN_9000 = '9001'.
*   明细关闭按钮
    WHEN '9002_CL_C'.
      GV_SUBSCREEN_9000 = '9003'.
*   详情关闭按钮
    WHEN '9002_CL_B'.
      GV_SUBSCREEN_9000 = '9008'.
    WHEN OTHERS.
  ENDCASE.
ENDMODULE.
*&---------------------------------------------------------------------*
*&      Module  READ_TABLE_CONTROL_9102  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE READ_TABLE_CONTROL_9102 INPUT.
  GV_LINE_9102 = SY-LOOPC.
  MODIFY GT_ITEM FROM GS_ITEM INDEX TC_9102-CURRENT_LINE.
ENDMODULE.
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_9003  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_9003 INPUT.
  CASE GV_OK_CODE.
*   抬头展开按钮
    WHEN '9003_EX_H'.
      GV_SUBSCREEN_9000 = '9005'.
*   明细展开按钮
    WHEN '9003_EX_C'.
      GV_SUBSCREEN_9000 = '9002'.
*   详情关闭按钮
    WHEN '9003_CL_B'.
      GV_SUBSCREEN_9000 = '9004'.
    WHEN OTHERS.
  ENDCASE.
ENDMODULE.
*&---------------------------------------------------------------------*
*&      Module  READ_TABLE_CONTROL_9302  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE READ_TABLE_CONTROL_9302 INPUT.
  GV_LINE_9302 = SY-LOOPC.
  MODIFY GT_ITEM_9302 FROM GS_ITEM_9302 INDEX TC_9302-CURRENT_LINE.
ENDMODULE.
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_9102  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_9102 INPUT.
  CASE GV_OK_CODE.
    WHEN 'PICK'.
*     获取双击行索引
      PERFORM FRM_GET_CURSOR.
    WHEN ''.
    WHEN OTHERS.
  ENDCASE.
ENDMODULE.
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_9302  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_9302 INPUT.
  CASE SY-UCOMM.
*   双击明细行
    WHEN 'PICK'.
*     获取项目详情数据
      PERFORM FRM_GET_ITEM_DETAIL.
    WHEN ''.
    WHEN OTHERS.
  ENDCASE.
ENDMODULE.
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_9103  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_9103 INPUT.
  CASE GV_OK_CODE.
*   切换明细时
    WHEN '9103_EBELP'.
      PERFORM FRM_GET_ITEM_DATA USING GV_9103_EBELP.
*   单击前一行按钮时
    WHEN '9103_LAST'.
      PERFORM FRM_PROCESS_FCODE USING '-'.
*   单击后一行按钮时
    WHEN '9103_NEXT'.
      PERFORM FRM_PROCESS_FCODE USING '+'.
    WHEN OTHERS.
  ENDCASE.
ENDMODULE.
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_9004  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_9004 INPUT.
  CASE GV_OK_CODE.
*   抬头展开按钮
    WHEN '9004_EX_H'.
      GV_SUBSCREEN_9000 = '9007'.
*   明细展开按钮
    WHEN '9004_EX_C'.
      GV_SUBSCREEN_9000 = '9008'.
*   详情展开按钮
    WHEN '9004_EX_B'.
      GV_SUBSCREEN_9000 = '9003'.
    WHEN OTHERS.
  ENDCASE.
ENDMODULE.
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_9005  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_9005 INPUT.
  CASE GV_OK_CODE.
*   抬头关闭按钮
    WHEN '9005_CL_H'.
      GV_SUBSCREEN_9000 = '9003'.
*   明细展开按钮
    WHEN '9005_EX_C'.
      GV_SUBSCREEN_9000 = '9001'.
*   详情关闭按钮
    WHEN '9005_CL_B'.
      GV_SUBSCREEN_9000 = '9007'.
    WHEN OTHERS.
  ENDCASE.
ENDMODULE.
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_9006  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_9006 INPUT.
  CASE GV_OK_CODE.
*   抬头关闭按钮
    WHEN '9006_CL_H'.
      GV_SUBSCREEN_9000 = '9008'.
*   明细关闭按钮
    WHEN '9006_CL_C'.
      GV_SUBSCREEN_9000 = '9007'.
*   详情展开按钮
    WHEN '9006_EX_B'.
      GV_SUBSCREEN_9000 = '9001'.
    WHEN OTHERS.
  ENDCASE.
ENDMODULE.
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_9007  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_9007 INPUT.
  CASE GV_OK_CODE.
*   抬头关闭按钮
    WHEN '9007_CL_H'.
      GV_SUBSCREEN_9000 = '9004'.
*   明细展开按钮
    WHEN '9007_EX_C'.
      GV_SUBSCREEN_9000 = '9006'.
*   详情展开按钮
    WHEN '9007_EX_B'.
      GV_SUBSCREEN_9000 = '9005'.
    WHEN OTHERS.
  ENDCASE.
ENDMODULE.
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_9008  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_9008 INPUT.
  CASE GV_OK_CODE.
*   抬头展开按钮
    WHEN '9008_EX_H'.
      GV_SUBSCREEN_9000 = '9006'.
*   明细关闭按钮
    WHEN '9008_CL_C'.
      GV_SUBSCREEN_9000 = '9004'.
*   详情展开按钮
    WHEN '9008_EX_B'.
      GV_SUBSCREEN_9000 = '9002'.
    WHEN OTHERS.
  ENDCASE.
ENDMODULE.
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_9303  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_9303 INPUT.

ENDMODULE.
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_9401  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_9401 INPUT.
  GV_SAVE_OK = GV_OK_CODE.
  CLEAR GV_OK_CODE.

  CASE GV_SAVE_OK.
*   回车或者点击其他凭证按钮时
    WHEN '9401_OK' OR 'ENTER'.
      IF GV_OTHER_ORDER IS NOT INITIAL.
        P_EBELN = GV_OTHER_ORDER.
        PERFORM FRM_GET_DATA.
      ENDIF.
      LEAVE TO SCREEN 0.
*   关闭按钮
    WHEN '9401_EXIT'.
      LEAVE TO SCREEN 0.
    WHEN OTHERS.
  ENDCASE.
ENDMODULE.

你可能感兴趣的:(SAP技术小知识,sap,abap,erp,开发语言)