采购订单行项目字段增强

1、在cmod中,添加MM06E005,涉及的组件是下图红框中的

采购订单行项目字段增强_第1张图片

采购订单行项目字段增强_第2张图片

2、字段增强:

  1. 在ci_ekpodb 中添加你要增强的字段 ,比如GYSWC ,激活;
  2. 在结构BAPI_TE_MEPOITEMX中的ci_ekpodbx 中添加 增强的字段名,类型

注意:如果在相关的结构中通过附加结构的方式 增强字段,是没有用的 ,我一开始是附加结构的方法在结构BAPI_TE_MEPOITEMX中增强该字段,结果是调用BAPI的时候,是写不进去值的。

 

3、双击 EXIT_SAPMM06E_016 ,进入然后转到全局数据,双击ZXM06TOP ,创建程序文件,定义全局变量

采购订单行项目字段增强_第3张图片

采购订单行项目字段增强_第4张图片

DATA edit_mode .

4、添加行项目的子屏幕。在程序SAPLXM06中添加屏幕0111,屏幕类型为子屏幕,自画屏幕不多说了,要注意的是

在屏幕上添加字段控件的时候,用结构EKPO_CI,不能用ekpo,否则是没有效果的;设置pbo,

采购订单行项目字段增强_第5张图片

MODULE SET_EDIT_MODE OUTPUT.
* SET PF-STATUS 'xxxxxxxx'.
* SET TITLEBAR 'xxx'.
  IF edit_mode = 'A'.
    LOOP AT SCREEN.
      screen-input = 0.
      MODIFY SCREEN.
    ENDLOOP.
  ENDIF.
ENDMODULE.

 

5、再次双击 EXIT_SAPMM06E_016 ,双击ZXM06U41创建文件,并添加代码

ekpo_ci-gyswc = i_ci_ekpo-gyswc.
edit_mode = i_aktyp.

6、双击 EXIT_SAPMM06E_018 ,双击 ZXM06U40 创建文件 ,并添加代码

  e_ci_ekpo-gyswc = ekpo_ci-gyswc.

7、调用bapi 修改采购订单,增强字段要通过 BAPI_TE_MEPOITEM 、BAPI_TE_MEPOITEMX两个结构实现

 

DATA:
        LV_EBELN TYPE EBELN,
        LT_RETURN TYPE TABLE OF BAPIRET2,
        LT_EXTENSIONIN TYPE TABLE OF BAPIPAREX,
        LS_RETURN TYPE BAPIRET2,
        LS_EXTENSIONIN TYPE BAPIPAREX,
        LS_MEPOITEM TYPE BAPI_TE_MEPOITEM,
        LS_MEPOITEMX TYPE BAPI_TE_MEPOITEMX .



  LV_EBELN = ps_POPROG-EBELN .
  LS_MEPOITEM-PO_ITEM = ps_POPROG-EBELP.
  LS_MEPOITEM-GYSWC = ps_POPROG-GYSWC.
  LS_EXTENSIONIN-structure = 'BAPI_TE_MEPOITEM'.
  LS_EXTENSIONIN-valuepart1 = LS_MEPOITEM.
  APPEND LS_EXTENSIONIN TO LT_EXTENSIONIN.

  LS_MEPOITEMX-PO_ITEM = ps_POPROG-EBELP.
  LS_MEPOITEMX-GYSWC = 'X'.
  LS_EXTENSIONIN-structure = 'BAPI_TE_MEPOITEMX'.
  LS_EXTENSIONIN-valuepart1 = LS_MEPOITEMX.
  APPEND LS_EXTENSIONIN TO LT_EXTENSIONIN.

  CALL FUNCTION 'BAPI_PO_CHANGE'
    EXPORTING
      PURCHASEORDER                = LV_EBELN
*     POHEADER                     = ls_POHEADER
*     POHEADERX                    = ls_POHEADERX
*     POADDRVENDOR                 =
*     TESTRUN                      =
*     MEMORY_UNCOMPLETE            =
*     MEMORY_COMPLETE              =
*     POEXPIMPHEADER               =
*     POEXPIMPHEADERX              =
*     VERSIONS                     =
*     NO_MESSAGING                 =
*     NO_MESSAGE_REQ               =
*     NO_AUTHORITY                 =
*     NO_PRICE_FROM_PO             =
*     PARK_UNCOMPLETE              =
*     PARK_COMPLETE                =
*   IMPORTING
*     EXPHEADER                    =
*     EXPPOEXPIMPHEADER            =
   TABLES
     RETURN                       = LT_RETURN
*     POITEM                       =  lt_POITEM
*     POITEMX                      = lt_POITEMX
*     POADDRDELIVERY               =
*     POSCHEDULE                   =
*     POSCHEDULEX                  =
*     POACCOUNT                    =
*     POACCOUNTPROFITSEGMENT       =
*     POACCOUNTX                   =
*     POCONDHEADER                 =
*     POCONDHEADERX                =
*     POCOND                       =
*     POCONDX                      =
*     POLIMITS                     =
*     POCONTRACTLIMITS             =
*     POSERVICES                   =
*     POSRVACCESSVALUES            =
*     POSERVICESTEXT               =
     EXTENSIONIN                  = LT_EXTENSIONIN
*     EXTENSIONOUT                 =
*     POEXPIMPITEM                 =
*     POEXPIMPITEMX                =
*     POTEXTHEADER                 =
*     POTEXTITEM                   =
*     ALLVERSIONS                  =
*     POPARTNER                    =
*     POCOMPONENTS                 =
*     POCOMPONENTSX                =
*     POSHIPPING                   =
*     POSHIPPINGX                  =
*     POSHIPPINGEXP                =
*     POHISTORY                    =
*     POHISTORY_TOTALS             =
*     POCONFIRMATION               =
*     SERIALNUMBER                 =
*     SERIALNUMBERX                =
*     INVPLANHEADER                =
*     INVPLANHEADERX               =
*     INVPLANITEM                  =
*     INVPLANITEMX                 =
*     POHISTORY_MA                 =
*     NFMETALLITMS                 =
            .


        DATA:
              LV_MSG TYPE STRING.

        READ TABLE LT_RETURN INTO LS_RETURN WITH KEY TYPE = 'E'."报错
        IF SY-SUBRC = 0.
           CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
          CONCATENATE '采购订单' ps_poprog-EBELN space ps_poprog-EBELP LS_RETURN-message INTO LV_MSG.
         MESSAGE LV_MSG TYPE 'E'.
         ELSE.
          CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
          EXPORTING
          WAIT          = 'X'.
        ENDIF.

 

你可能感兴趣的:(编程技术)