ABAP:VL01N增强

VL01N增强:

VL01N保存前增强:


 

 



 

  METHOD if_ex_le_shp_delivery_proc~save_document_prepare.

    DATA:lt_cstack_tab TYPE sys_callst,
         lv_flag       TYPE char1.

    DATA:lv_delivery_update TYPE string.

    IMPORT lv_delivery_update TO lv_delivery_update FROM MEMORY ID 'ZDELIVERY_UPDATE'.
    lv_flag = lv_delivery_update.
    FREE MEMORY ID 'ZDELIVERY_UPDATE'.
*    ENDIF.
    IF sy-uname = 'BASIS2' AND
       ( ( ( sy-tcode EQ 'VL02N' OR
           sy-tcode EQ 'VL03N' ) AND
         ( sy-ucomm EQ 'WABU_T' OR
           sy-ucomm EQ 'SICH_T' ) ) OR
         lv_flag EQ 'X' ).
      LOOP AT ct_xlikp INTO DATA(ls_xlikp_stmp).

        "更新批次拆分后的增强字段
        LOOP AT ct_xlips INTO DATA(ls_xlips_stmp2) WHERE vbeln EQ ls_xlikp_stmp-vbeln
                                                     AND uecha IS NOT INITIAL.
          READ TABLE ct_xlips INTO DATA(ls_xlips_stmp)
                              WITH KEY  vbeln = ls_xlips_stmp2-vbeln
                                        posnr = ls_xlips_stmp2-uecha.
          IF sy-subrc EQ 0.
            ls_xlips_stmp2-zvbeln = ls_xlips_stmp-zvbeln.
            ls_xlips_stmp2-zposnr = ls_xlips_stmp-zposnr.
            ls_xlips_stmp2-zebeln = ls_xlips_stmp-zebeln.
            ls_xlips_stmp2-zebelp = ls_xlips_stmp-zebelp.

            MODIFY ct_xlips FROM ls_xlips_stmp2 TRANSPORTING zvbeln zposnr zebeln zebelp.
          ENDIF.

          CLEAR:ls_xlips_stmp2.
        ENDLOOP.
        CLEAR:ls_xlikp_stmp.
      ENDLOOP.
    ENDIF.

    IF sy-uname EQ 'BASIS2' AND
       ( ( sy-tcode EQ 'VL01N' OR
         sy-tcode EQ 'VL02N' OR
         sy-tcode EQ 'VL03N' ) OR
         lv_flag EQ 'X' ) .


      DATA(lt_lips) = ct_xlips[].
      DATA(ls_likp) = ct_xlikp.
      DATA:lv_lines      TYPE i,
           lv_menge_eket TYPE ekpo-menge,
           lv_menge_ekpo TYPE ekpo-menge,
           lv_menge      TYPE ekpo-menge,
           ls_zsdt043    TYPE zsdt043,
           lt_zsdt043    TYPE TABLE OF zsdt043.

      DATA:i_matnr  TYPE mara-matnr,
           i_in_me  TYPE mara-meins,
           i_out_me TYPE mara-meins,
           i_menge  TYPE ekpo-menge,
           e_menge  TYPE ekpo-menge,
           lv_num TYPE i.
      LOOP AT ct_xlikp INTO DATA(ls_xlikp) WHERE updkz NE 'D'.
        READ TABLE ct_xlips INTO DATA(ls_lips2) WITH KEY vbeln = ls_xlikp-vbeln.
        IF sy-subrc EQ 0.

          "获取订单类型
          SELECT SINGLE auart
            INTO @DATA(lv_auart)
            FROM vbak
           WHERE vbeln EQ @ls_lips2-vgbel.

          "获取交易路线
          SELECT COUNT(*)
            INTO lv_lines
            FROM zsdt041
           WHERE auart EQ lv_auart
             AND objtype = 'SO'.
          IF lv_lines > 1.
            MESSAGE '订单类型有多条交易路线' TYPE 'E'.
          ELSEIF lv_lines = 1.
            CLEAR:lv_auart,lv_lines.
            LOOP AT ct_xlips INTO DATA(ls_lips) WHERE updkz NE 'D' AND
                                                       vbeln EQ ls_xlikp-vbeln.
              "如果出柜交货单不为空,检查交货单参考销售订单行
              IF ls_xlikp-lifex IS NOT INITIAL.
                SELECT COUNT(*)
                  FROM ztsd004_i_01
                 WHERE zctreq EQ ls_xlikp-lifex
                   AND vbeln1 EQ ls_lips-vgbel
                   AND posnr1 EQ ls_lips-vgpos
                   AND matnr  EQ ls_lips-matnr.

                IF sy-subrc NE 0.
                  MESSAGE ls_lips-posnr &&':交货单参考销售订单及行与出柜通知单不一致,请检查!' TYPE 'E'.
                ELSE.
                  SELECT SINGLE vbeln posnr ebeln ebelp
                    FROM ztsd004_i_01
                    INTO ( ls_lips-zvbeln,
                           ls_lips-zposnr,
                           ls_lips-zebeln,
                           ls_lips-zebelp )
                   WHERE zctreq EQ ls_xlikp-lifex
                     AND vbeln1 EQ ls_lips-vgbel
                     AND posnr1 EQ ls_lips-vgpos.
                  MODIFY ct_xlips FROM ls_lips.
                ENDIF.
              ELSE.

                IF ls_lips-zvbeln IS INITIAL AND
                   ls_lips-zposnr IS INITIAL AND
                   ls_lips-zebeln IS INITIAL AND
                   ls_lips-zebelp IS INITIAL.
                  "查询对应的采购订单
                  SELECT a~ebeln,a~ebelp
                    FROM ekpo AS a
                   INNER JOIN ekko AS b
                      ON a~ebeln = b~ebeln
                    INTO TABLE @DATA(lt_ekko)
                   WHERE submi EQ @ls_lips-vgbel
                     AND matnr EQ @ls_lips-matnr
                     AND a~loekz EQ ''.

                  "根据采购订单查询采购订单计划行数据
                  IF lt_ekko IS NOT INITIAL.
                    SELECT a~ebeln,a~ebelp,a~menge,a~wemng,b~meins
                      FROM eket AS a
                     INNER JOIN ekpo AS b
                        ON a~ebeln = b~ebeln
                       AND a~ebelp = b~ebelp
                      INTO TABLE @DATA(lt_eket)
                       FOR ALL ENTRIES IN @lt_ekko
                     WHERE a~ebeln = @lt_ekko-ebeln
                       AND a~ebelp = @lt_ekko-ebelp.
                  ENDIF.
                  "查询物料基本单位
                  SELECT SINGLE meins
                    INTO @DATA(lv_meins)
                    FROM mara
                   WHERE matnr = @ls_lips-matnr.

                  CLEAR:i_matnr,i_in_me,i_out_me,i_menge,e_menge,lv_menge_ekpo.
                  i_matnr = ls_lips-matnr.
                  i_in_me = ls_lips-meins.
                  i_out_me = lv_meins.
                  i_menge = ls_lips-lfimg.
                  "交货数量转换为基本单位
                  CALL FUNCTION 'MD_CONVERT_MATERIAL_UNIT'
                    EXPORTING
                      i_matnr              = i_matnr
                      i_in_me              = i_in_me
                      i_out_me             = i_out_me
                      i_menge              = i_menge
                    IMPORTING
                      e_menge              = e_menge
                    EXCEPTIONS
                      error_in_application = 1
                      error                = 2
                      OTHERS               = 3.
                  lv_menge_ekpo = e_menge.
                  LOOP AT lt_eket INTO DATA(ls_eket).
                    lv_menge = ls_eket-menge - ls_eket-wemng.
                    "剔除EKTE中已完成交货数量的行
                    IF ls_eket-menge - ls_eket-wemng = 0.
                      DELETE lt_eket.
                      EXIT.
                    ENDIF.
                    CLEAR:i_matnr,i_in_me,i_out_me,i_menge,e_menge,lv_menge_eket.
                    i_matnr = ls_lips-matnr.
                    i_in_me = ls_eket-meins.
                    i_out_me = lv_meins.
                    i_menge = lv_menge.

                    "EKET数量转换
                    CALL FUNCTION 'MD_CONVERT_MATERIAL_UNIT'
                      EXPORTING
                        i_matnr              = i_matnr
                        i_in_me              = i_in_me
                        i_out_me             = i_out_me
                        i_menge              = i_menge
                      IMPORTING
                        e_menge              = e_menge
                      EXCEPTIONS
                        error_in_application = 1
                        error                = 2
                        OTHERS               = 3.
                    lv_menge_eket = e_menge.
                    IF lv_menge_eket < lv_menge_ekpo.
                      DELETE lt_eket.
                    ENDIF.
                    CLEAR:ls_eket,lv_menge,lv_menge_eket.
                  ENDLOOP.

                  lv_num = lines( lt_eket ).

                  IF lv_num = 1.
                    READ TABLE lt_eket INTO ls_eket INDEX 1.
                    ls_lips-zebeln = ls_eket-ebeln.
                    ls_lips-zebelp = ls_eket-ebelp.

                    SELECT SINGLE vbeln
                      INTO ls_lips-zvbeln
                      FROM ekkn
                     WHERE ebeln = ls_eket-ebeln
                       AND ebelp = ls_eket-ebelp.

                    SELECT SINGLE vbelp
                      INTO ls_lips-zposnr
                      FROM ekkn
                     WHERE ebeln = ls_eket-ebeln
                       AND ebelp = ls_eket-ebelp.
                    MODIFY ct_xlips FROM ls_lips TRANSPORTING zvbeln zposnr zebeln zebelp.
                  ELSE.
                    MESSAGE ls_lips-posnr &&':SO2订单号、SO2行项目号、PO1订单号、PO1行项目号必填' TYPE 'E'.
                  ENDIF.
                ELSE.
                  IF ls_lips-zvbeln IS INITIAL OR
                     ls_lips-zposnr IS INITIAL OR
                     ls_lips-zebeln IS INITIAL OR
                     ls_lips-zebelp IS INITIAL.
                    MESSAGE ls_lips-posnr &&':SO2订单号、SO2行项目号、PO1订单号、PO1行项目号必须都为空或都有值' TYPE 'E'.
                  ELSE.
                    "校验参考销售订单是否和增强字段中PO汇总字段一致
                    SELECT SINGLE submi
                      INTO @DATA(lv_submi)
                      FROM ekko
                     WHERE ebeln = @ls_lips-zebeln.

                    IF ls_lips-vgbel NE lv_submi.
                      MESSAGE ls_lips-posnr &&':SO1号码与PO1不是对应关系!' TYPE 'E'.
                    ENDIF.

                    SELECT SINGLE matnr
                      INTO @DATA(lv_matnr)
                      FROM ekpo
                     WHERE ebeln EQ @ls_lips-zebeln
                       AND ebelp EQ @ls_lips-zebelp.

                    IF lv_matnr NE ls_lips-matnr.
                      MESSAGE ls_lips-posnr &&':采购订单及行号与交货物料不一致!' TYPE 'E'.
                    ENDIF.

                    SELECT SINGLE vbeln,vbelp
                      INTO @DATA(ls_ekkn)
                      FROM ekkn
                     WHERE ebeln = @ls_lips-zebeln
                       AND ebelp = @ls_lips-zebelp.

                    IF ls_ekkn-vbeln NE ls_lips-zvbeln OR
                       ls_ekkn-vbelp NE ls_lips-zposnr.
                      MESSAGE ls_lips-posnr &&':SO1号码与PO1不是对应关系!' TYPE 'E'.
                    ENDIF.
                    CLEAR:lv_submi,ls_ekkn.
                  ENDIF.
                ENDIF.
              ENDIF.
              CLEAR:ls_lips,lv_meins,lv_menge_ekpo,lt_ekko,lt_eket.
            ENDLOOP.
          ENDIF.
        ENDIF.
        CLEAR:ls_xlikp.
      ENDLOOP.
    ENDIF.

    IF sy-uname = 'BASIS2' AND
      ( ( ( sy-tcode EQ 'VL02N' OR
            sy-tcode EQ 'VL03N' ) AND
        sy-ucomm EQ 'WABU_T' ) OR
        lv_flag EQ 'X'  )
      .
      DATA:
            ls_xlips   LIKE LINE OF ct_xlips,
            ls_ylips   LIKE LINE OF ct_ylips,
            ls_zsdt045 TYPE zsdt045,
            lt_zsdt045 TYPE TABLE OF zsdt045,
            lv_posnr   TYPE posnr,
            lv_pstyv   TYPE pstyv.


      LOOP AT ct_xlikp INTO ls_xlikp.
        "校验交货单是否有后续单据未处理
        SELECT COUNT(*)
          FROM zsdt044
         WHERE zobjkey EQ ls_xlikp-vbeln
           AND ( objtype EQ 'GR' OR
                 objtype EQ 'PO' )
           AND fksto EQ ''.
        IF sy-subrc EQ 0.
          MESSAGE '交货单后续单据未处理,请先处理后续单据' TYPE 'E'.
        ENDIF.

        "校验订单类型是否有多条交易路线
        READ TABLE ct_xlips INTO ls_xlips WITH KEY vbeln = ls_xlikp-vbeln.
        IF sy-subrc EQ 0.
          "查询订单类型
          SELECT SINGLE auart
            INTO lv_auart
            FROM vbak
           WHERE vbeln EQ ls_xlips-vgbel.

          SELECT pstyv
            FROM lips
            INTO TABLE @DATA(lt_pstyv)
           WHERE vbeln EQ @ls_xlips-vbeln
             AND uecha EQ ''.

          LOOP AT lt_pstyv INTO DATA(ls_pstyv).
            IF ls_pstyv-pstyv EQ 'ZTAA'.
              lv_pstyv = 'ZTAA'.
              EXIT.
            ENDIF.
            CLEAR:ls_pstyv.
          ENDLOOP.

          IF lv_pstyv NE 'ZTAA'.
            lv_pstyv = ''.
          ENDIF.

          SELECT SINGLE vkorg
            INTO @DATA(lv_vkorg)
            FROM vbak
           WHERE vbeln EQ @ls_xlips-vgbel.

          SELECT *
            INTO TABLE @DATA(lt_zsdt041)
            FROM zsdt041
           WHERE auart EQ @lv_auart
             AND pstyv EQ @lv_pstyv
             AND objtype EQ 'GR'.
          CLEAR:lv_pstyv.
          lv_num = lines( lt_zsdt041 ).
          IF lv_num > 1.
            MESSAGE '订单类型有多条交易路线' TYPE 'E'.
          ELSE.
            READ TABLE lt_zsdt041 INTO DATA(ls_zsdt041) INDEX 1.
          ENDIF.
          CLEAR:lv_num,ls_xlips.
        ENDIF.

        LOOP AT ct_xlips INTO ls_xlips WHERE vbeln EQ ls_xlikp-vbeln.
          lv_posnr = lv_posnr + 10.
          IF ls_xlikp-lifex IS NOT INITIAL.
            SELECT SINGLE ebeln AS zebeln,
                          ebelp AS zebelp
              FROM ztsd004_i_01
              INTO @DATA(ls_ebeln)
             WHERE zctreq EQ @ls_xlikp-lifex
               AND vbeln1 EQ @ls_xlips-vgbel
               AND posnr1 EQ @ls_xlips-vgpos.
          ELSE.
            ls_ebeln-zebeln = ls_xlips-zebeln.
            ls_ebeln-zebelp = ls_xlips-zebelp.
          ENDIF.

          "过账日期
          ls_zsdt045-budat = ls_xlikp-wadat_ist.
          "交货单号
          ls_zsdt045-vbeln = ls_xlikp-vbeln.
          "交货单行项目
          ls_zsdt045-posnr = ls_xlips-posnr.
          "行项目
          ls_zsdt045-zposnr = lv_posnr.
          "物料
          ls_zsdt045-matnr = ls_xlips-matnr.
          "采购订单
          ls_zsdt045-ebeln = ls_ebeln-zebeln.
          "采购订单行项目
          ls_zsdt045-ebelp = ls_ebeln-zebelp.
          "行项目数量
          ls_zsdt045-menge = ls_xlips-lfimg.
          "数量单位
          ls_zsdt045-vrkme = ls_xlips-vrkme.
          "工厂
          ls_zsdt045-werks = ls_xlips-werks.
          "拆分的上层项目
          ls_zsdt045-uecha = ls_xlips-uecha.
          "时间戳
          ls_zsdt045-erdat = sy-datum.
          ls_zsdt045-erzet = sy-uzeit.
          ls_zsdt045-ernam = sy-uname.
          APPEND ls_zsdt045 TO lt_zsdt045.

          CLEAR:ls_xlips.
          CLEAR:ls_zsdt045.
        ENDLOOP.
        DATA:lv_batch TYPE char1.
        IF lv_flag EQ 'X'.
          lv_batch = 'X'.
        ENDIF.
        "&& 成品开关控制
        SELECT SINGLE * INTO @DATA(ls_zsdt050) FROM zsdt050 WHERE bukrs = @lv_vkorg AND objtype = 'DP'.
        IF ls_zsdt050-zbs <> 'N'.
          IF lt_zsdt045 IS NOT INITIAL AND
             ls_zsdt041-zrfcid IS NOT INITIAL .
            CALL FUNCTION 'ZMMFU013'
              EXPORTING
                iv_zjylx   = ls_zsdt041-zrfcid
                iv_batch   = lv_batch
              TABLES
                it_zsdt045 = lt_zsdt045[].
          ENDIF.
        ENDIF.
        CLEAR: ls_xlikp,lv_auart,lt_zsdt041,lv_posnr,ls_ebeln,lt_zsdt045.
      ENDLOOP.
    ENDIF.

    IF sy-uname EQ 'BASIS2' AND
       ( sy-ucomm EQ 'SICH_T' OR
         sy-ucomm EQ 'YES' ) AND
       ( sy-tcode EQ 'VL02N' OR
         sy-tcode EQ 'VL03N' ).
      DATA:ls_zsdt047 TYPE zsdt047,
           lt_zsdt047 TYPE TABLE OF zsdt047.

      LOOP AT ct_xlikp INTO ls_xlikp.
        CLEAR:lv_posnr.
        "查询ZSDT044数据
        SELECT SINGLE *
          INTO @DATA(ls_zsdt044)
          FROM zsdt044
         WHERE zobjkey EQ @ls_xlikp-vbeln
           AND objtype EQ 'SO'
           AND fksto EQ ''.

        "查询修改业务流程
        SELECT SINGLE *
          INTO @DATA(ls_zsdt046)
          FROM zsdt046
         WHERE zzrfcid EQ @ls_zsdt044-zrfcid.

        READ TABLE ct_xlips INTO ls_xlips WITH KEY vbeln = ls_xlikp-vbeln.
        IF sy-subrc EQ 0.
          "获取销售订单类别
          SELECT SINGLE *
            INTO @DATA(ls_vbak)
            FROM vbak
           WHERE vbeln EQ @ls_xlips-vgbel.

          "获取业务流程ID
          SELECT SINGLE *
            INTO ls_zsdt041
            FROM zsdt041
           WHERE auart = ls_vbak-auart
             AND objtype = 'SO'.
        ENDIF.
        "整个交货单删除
        IF ls_xlikp-updkz EQ 'D'.
          "整单删除
          ls_zsdt047-flag = 'X'.
          "交货单
          ls_zsdt047-vbeln = ls_xlips-vbeln.
          "销售订单
          ls_zsdt047-zvbeln3 = ls_xlips-vgbel.
          "行项目
          ls_zsdt047-zposnr = lv_posnr.
          "拒绝原因
          ls_zsdt047-abgru = ls_zsdt046-abgru.
          APPEND ls_zsdt047 TO lt_zsdt047.
          CLEAR:ls_zsdt047.
        ELSE.
          LOOP AT ct_xlips INTO ls_xlips WHERE uecha EQ ''.
            lv_posnr = lv_posnr + 10.
            "新增行
            IF ls_xlips-updkz EQ 'I'.
              SELECT SINGLE *
                FROM eket
                INTO @DATA(ls_eket2)
               WHERE ebeln EQ @ls_xlips-zebeln
                 AND ebelp EQ @ls_xlips-zebelp.
              IF ls_xlips-lfimg > ( ls_eket2-menge - ls_eket2-wemng ).
                MESSAGE ls_xlips-posnr &&':交货单数量大于采购订单未清数量,请核对!' TYPE 'E'.
              ENDIF.
              CLEAR:ls_eket2.
              IF ls_zsdt046-pstyv NE ls_xlips-pstyv.
                CLEAR:ls_xlips,ls_zsdt047.
                CONTINUE.
              ENDIF.
              "标记新增行
              ls_zsdt047-flag  = 'I'.
              "行项目数据
              "交货单
              ls_zsdt047-vbeln = ls_xlips-vbeln.
              "行项目
              ls_zsdt047-posnr = ls_xlips-posnr.
              "物料
              ls_zsdt047-matnr = ls_xlips-matnr.
              "行项目数量
              ls_zsdt047-menge = ls_xlips-lfimg.
              "单位
              ls_zsdt047-vrkme = ls_xlips-vrkme.
              "工厂
              ls_zsdt047-werks = ls_xlips-werks.
              "行项目定价日期
              ls_zsdt047-budat = ls_xlikp-wadat_ist.
              "条件类型
              ls_zsdt047-kschl = ls_zsdt041-kschl.
              "销售订单条件类型
              ls_zsdt047-zkschl = ls_zsdt041-zkschl.
              "交货单的外部标识
              ls_zsdt047-lifex = ls_xlikp-lifex.
              "SO2增强字段
              ls_zsdt047-zvbeln2 = ls_xlips-zvbeln.
              ls_zsdt047-zposnr2 = ls_xlips-zposnr.
              ls_zsdt047-zebeln2 = ls_xlips-zebeln.
              ls_zsdt047-zebelp2 = ls_xlips-zebelp.
              "销售订单
              ls_zsdt047-zvbeln3 = ls_xlips-vgbel.
              "销售订单行
              ls_zsdt047-zposnr3 = ls_xlips-vgpos.
              "行项目
              ls_zsdt047-zposnr = lv_posnr.
              "更新时间戳
              ls_zsdt047-erdat = sy-datum.
              ls_zsdt047-erzet = sy-uzeit.
              ls_zsdt047-ernam = sy-uname.
              APPEND ls_zsdt047 TO lt_zsdt047.
              CLEAR:ls_zsdt047.

            ELSEIF ls_xlips-updkz EQ 'D'.
              "交货单
              ls_zsdt047-vbeln = ls_xlips-vbeln.
              "标记删除行
              ls_zsdt047-flag = 'D'.
              "行项目
              ls_zsdt047-posnr = ls_xlips-posnr.
              "拒绝原因
              ls_zsdt047-abgru = ls_zsdt046-abgru.
              "
              ls_zsdt047-zposnr = lv_posnr.
              "更新时间戳
              ls_zsdt047-ernam = sy-uname.
              ls_zsdt047-erdat = sy-datum.
              ls_zsdt047-erzet = sy-uzeit.
              APPEND ls_zsdt047 TO lt_zsdt047.
              CLEAR:ls_zsdt047.
            ELSEIF ls_xlips-updkz EQ 'U'.
              "标记更新行
              ls_zsdt047-flag = 'U'.
              "交货单
              ls_zsdt047-vbeln = ls_xlips-vbeln.
              "行项目
              ls_zsdt047-posnr = ls_xlips-posnr.
              "数量
              ls_zsdt047-menge = ls_xlips-lfimg.

              LOOP AT ct_xlips INTO ls_lips WHERE uecha EQ ls_xlips-posnr.
                ls_zsdt047-menge = ls_zsdt047-menge + ls_lips-lfimg.
                CLEAR:ls_lips.
              ENDLOOP.

              SELECT SINGLE *
                FROM eket
                INTO ls_eket2
               WHERE ebeln EQ ls_xlips-zebeln
                 AND ebelp EQ ls_xlips-zebelp.
              IF ls_xlips-lfimg > ( ls_eket2-menge - ls_eket2-wemng ).
                MESSAGE ls_xlips-posnr &&':交货单数量大于采购订单未清数量,请核对!' TYPE 'E'.
              ENDIF.
              CLEAR:ls_eket2.
              "
              ls_zsdt047-zposnr = lv_posnr.
              "更新时间戳
              ls_zsdt047-ernam = sy-uname.
              ls_zsdt047-erdat = sy-datum.
              ls_zsdt047-erzet = sy-uzeit.
              APPEND ls_zsdt047 TO lt_zsdt047.
              CLEAR:ls_zsdt047.
            ENDIF.
            CLEAR:ls_xlips.
          ENDLOOP.
        ENDIF.

        CLEAR:ls_xlikp.
        IF lt_zsdt047 IS NOT INITIAL AND
           ls_zsdt046-zrfcid IS NOT INITIAL.

          CALL FUNCTION 'ZMMFU015'
            EXPORTING
              iv_zjylx   = ls_zsdt046-zrfcid
            TABLES
              it_zsdt047 = lt_zsdt047[].
        ENDIF.

      ENDLOOP.
    ENDIF.

  ENDMETHOD.

 


抬头屏幕增强:

SE11 Append Structure 在交货单抬头增强需要在Likp中添加新结构

增强的结构的字段,我们一般已ZZ / YY开头。

SE80创建一个Function Group函数组:YDELIVER_HEAD(Deliver Header:customer Fields)
分别创建两个Function module:
Z_GET_DATA_DELI_HEAD(get values for screen)


 

PROCESS BEFORE OUTPUT.
  MODULE status_9001.
*
PROCESS AFTER INPUT.
* MODULE USER_COMMAND_9001.

"VL03设置不可输入
MODULE status_9001 OUTPUT.
  LOOP AT SCREEN.
    IF screen-name = 'ZSO2-ZVBELN' OR
       screen-name = 'ZSO2-ZPOSNR' OR
       screen-name = 'ZSO2-ZEBELN' OR
       screen-name = 'ZSO2-ZEBELP'.
      IF g_trtyp = 'A'.
        screen-input = '0'.
        MODIFY SCREEN.
      ENDIF.
    ENDIF.
  ENDLOOP.
ENDMODULE.

"TOP:
TABLES:zso2.
MOVE-CORRESPONDING zso2 TO cs_lips.

Z_SET_DATA_DELI_ITEM(set values for screen)


 

  MOVE-CORRESPONDING is_lips TO zso2.

  g_trtyp = i_trtyp.

创建一个Subscreen屏幕9000

画出屏幕增强需要的字段
在这里插入图片描述

输入*,点击Get From Program按钮,获取程序中所有的变量,选中想要的即可
别忘了激活全部元素


查找相应的BADI
查找方法请参考: SAP第三代增强BADI的实现方法及查找方式
Delivery Header level:LE_SHP_TAB_CUST_HEAD
Delivery Item level:LE_SHP_TAB_CUST_ITEM

这里Additional tab,我们只需要LE_SHP_TAB_CUST_HEAD

SE18 BADI实施
在这里插入图片描述


在BADI对象的方法中实现我们相应的代码
在这里插入图片描述
IF_EX_LE_SHP_TAB_CUST_HEAD~ACTIVATE_TAB_PAGE

  METHOD if_ex_le_shp_tab_cust_item~activate_tab_page.
    ef_caption = '交货单增强字段'.
    ef_program = 'SAPLZDELIVER_ITEM'.
    ef_position = 12.
    ef_dynpro = '9001'.
    cs_v50agl_cust = 'X'.
  ENDMETHOD.

 

IF_EX_LE_SHP_TAB_CUST_HEAD~TRANSFER_DATA_TO_SUBSCREEN

  METHOD if_ex_le_shp_tab_cust_item~transfer_data_to_subscreen.
    CALL FUNCTION 'Z_SET_DATA_DELI_ITEM'
      EXPORTING
        is_lips = is_lips
        i_trtyp = if_trtyp.
  ENDMETHOD.

 

IF_EX_LE_SHP_TAB_CUST_HEAD~TRANSFER_DATA_FROM_SUBSCREEN

DATA:ls_lips LIKE cs_lips.

    CALL FUNCTION 'Z_GET_DATA_DELI_ITEM'
      IMPORTING
        cs_lips = ls_lips.

    cs_lips-zvbeln = ls_lips-zvbeln.
    cs_lips-zposnr = ls_lips-zposnr.
    cs_lips-zebeln = ls_lips-zebeln.
    cs_lips-zebelp = ls_lips-zebelp.
    cs_v50agl_cust = 'X'.

激活代码,激活BADI对象
这里的FUNCTION的import/export为什么是CS_LIKP、IS_LIKP?能不能自己随便定义能?
当然不能,我们可以在Interface:IF_EX_LE_SHP_TAB_CUST_HEAD中Parameter中查找我们所需的传入、传出参数


VL02N测试
F4查找一个存在的交货单
在这里插入图片描述

这里就能查看我们增强的屏幕了
在这里插入图片描述



一代增强:SE38:MV50AFZ1

 

posted @ 2022-12-19 11:53  阿胖的阿多  阅读(1266)  评论(0编辑  收藏  举报