增、改生产订单组件BAPI BAPI_ALM_ORDER_MAINTAIN
阅读原文时间:2023年07月08日阅读:1

转载留存

IT_METHODS    LIKE    BAPI_ALM_ORDER_METHOD
处理方法,必选项,存储CREATE CREATETONOTIF CHANGE DELETE RELEASE TECHNICALCOMPLETE ATPCHECK CALCULATE SCHEDULE DELELTEDSEX ADD SAVE DIALOG TRACE这些处理动作。
IT_HEADER    LIKE    BAPI_ALM_ORDER_HEADERS_I
订单的header信息
IT_HEADER_UP    LIKE    BAPI_ALM_ORDER_HEADERS_UP
修改的订单的header信息,如果是对订单header的修改,需要将对应字段置X
IT_HEADER_SRV    LIKE    BAPI_ALM_ORDER_SRVDAT_E
对象服务信息
IT_HEADER_SRV_UP    LIKE    BAPI_ALM_ORDER_SRVDAT_UP
IT_USERSTATUS    LIKE    BAPI_ALM_ORDER_USRSTAT
用户状态信息
IT_PARTNER    LIKE    BAPI_ALM_ORDER_PARTN_MUL
合作伙伴信息
IT_PARTNER_UP    LIKE    BAPI_ALM_ORDER_PARTN_MUL_UP
IT_OPERATION    LIKE    BAPI_ALM_ORDER_OPERATION
工序信息
IT_OPERATION_UP    LIKE    BAPI_ALM_ORDER_OPERATION_UP
IT_RELATION    LIKE    BAPI_ALM_ORDER_RELATION
IT_RELATION_UP    LIKE    BAPI_ALM_ORDER_RELATION_UP
IT_COMPONENT    LIKE    BAPI_ALM_ORDER_COMPONENT
组件信息
IT_COMPONENT_UP    LIKE    BAPI_ALM_ORDER_COMPONENT_UP
IT_TEXT    LIKE    BAPI_ALM_TEXT
IT_TEXT_LINES    LIKE    BAPI_ALM_TEXT_LINES
EXTENSION_IN    LIKE    BAPIPAREX
RETURN    LIKE    BAPIRET2
返回消息
ET_NUMBERS    LIKE    BAPI_ALM_NUMBERS
返回订单编码信息

1、创建一个带工序的订单
  CLEAR IT_METHODS.
  IT_METHODS-REFNUMBER = '1'.”对应下面header表中相应行的数据
  IT_METHODS-OBJECTTYPE = 'HEADER'.”需要操作的对象类型
  IT_METHODS-METHOD = 'CREATE'.”相应动作
  IT_METHODS-OBJECTKEY = '%00000000001'.”PM订单号,我们用的系统内部给号,此处使用临时编码'%00000000001',bapi结束时,会返回真正的订单号
  APPEND IT_METHODS.
  CLEAR IT_METHODS.
  IT_METHODS-REFNUMBER = '1'.”对应下面OPERATION表中相应行的数据
  IT_METHODS-OBJECTTYPE = 'OPERATION'.”需要操作的对象类型
  IT_METHODS-METHOD = 'CREATE'.”相应动作
  IT_METHODS-OBJECTKEY = '%00000000001'.”PM订单号,我们用的系统内部给号,此处使用临时编码'%00000000001',bapi结束时,会返回真正的订单号
  APPEND IT_METHODS.”多个工序时,要加入多条数据,REFNUMBER 对应OPERATION的行数
  CLEAR IT_METHODS.
  IT_METHODS-METHOD = 'SAVE'.”最后要插入一个save或dialog方法,否则bapi会报错
  APPEND IT_METHODS.”IT_METHODS已经填充完毕

"填充header数据 
  IT_HEADER-ORDERID = '%00000000001'.”临时订单号
  IT_HEADER-ORDER_TYPE = 'PM11'..”订单类型
  IT_HEADER-EQUIPMENT = ‘JB200101’.
  IT_HEADER-SHORT_TEXT= 'PM ORDER TEXT'.
  ………
  APPEND IT_HEADER

"填充工序数据表
  IT_OPERATION-ACTIVITY = ‘0010’.”operation num
  IT_OPERATION-DESCRIPTION = ‘operation text’.
  IT_OPERATION-CONTROL_KEY = 'PM01'.”control key
APPEND IT_OPERATION."多个工序加入多条,要和IT_method对应。

CALL FUNCTION 'BAPI_ALM_ORDER_MAINTAIN'
    TABLES
      IT_METHODS             = IT_METHODS
      IT_HEADER              = IT_HEADER
*   IT_HEADER_UP           =
*   IT_HEADER_SRV          =
*   IT_HEADER_SRV_UP       =
*   IT_USERSTATUS          =
*   IT_PARTNER             =
*   IT_PARTNER_UP          =
      IT_OPERATION           = IT_OPERATION
*   IT_OPERATION_UP        =
*   IT_RELATION            =
*   IT_RELATION_UP         =
*   IT_COMPONENT           =
*   IT_COMPONENT_UP        =
*   IT_TEXT                =
*   IT_TEXT_LINES          =
*   EXTENSION_IN           =
   RETURN                 = RETURN
   ET_NUMBERS             = ET_NUMBERS
            .
然后判断RETURN中的消息,做BAPI_TRANSACTION_COMMIT或者BAPI_TRANSACTION_ROLLBACK,这样就创建了一个PM订单。

2、修改一个PM订单的组件信息。
  CLEAR IT_METHODS.
  IT_METHODS-REFNUMBER = '1'.
  IT_METHODS-OBJECTTYPE = 'COMPONENT'."
  IT_METHODS-METHOD = 'CHANGE'.
  IT_METHODS-OBJECTKEY = ‘90012343’.“订单号
  APPEND IT_METHODS.”如果修改多个组件,要加入多条
  CLEAR IT_METHODS.
  IT_METHODS-METHOD = 'SAVE'.
  APPEND IT_METHODS.
    CLEAR IT_COMPONENT.
    IT_COMPONENT-RESERV_NO = ‘18933‘.“预留号
    IT_COMPONENT-RES_ITEM = ’1‘.预留项目
    IT_COMPONENT-WITHDRAWN = 'X'.“最后发货标识,要修改这个字段
    APPEND IT_COMPONENT.”如果修改多个组件,要加入多条
    IT_COMPONENTUP-WITHDRAWN = 'X'.“最后发货标识,要修改哪个字段,需要在UP表中将该字段值为X
    APPEND IT_COMPONENTUP.”如果修改多个组件,要加入多条

  CALL FUNCTION 'BAPI_ALM_ORDER_MAINTAIN'
    TABLES
      IT_METHODS             = IT_METHODS
*     IT_HEADER              =
*     IT_HEADER_UP           =
*     IT_HEADER_SRV          =
*     IT_HEADER_SRV_UP       =
*     IT_USERSTATUS          =
*     IT_PARTNER             =
*     IT_PARTNER_UP          =
*     IT_OPERATION           =
*     IT_OPERATION_UP        =
*     IT_RELATION            =
*     IT_RELATION_UP         =
     IT_COMPONENT           = IT_COMPONENT
     IT_COMPONENT_UP        = IT_COMPONENTUP
*     IT_TEXT                =
*     IT_TEXT_LINES          =
*     EXTENSION_IN           =
     RETURN                 = RETURN
     ET_NUMBERS             = ET_NUMBERS
            .
然后做transaction commit或rollback操作就OK了

手机扫一扫

移动阅读更方便

阿里云服务器
腾讯云服务器
七牛云服务器

你可能感兴趣的文章