SAP使用CO02可以增加工序,但是程序如何实现呢?在网上找了很多资料,结果无果,
有幸在外网找到了一个资料,只是提供一个函数,经测试,可以使用。大家可以借鉴
"添加前导零
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = iv_aufnr
IMPORTING
output = iv_aufnr.
DATA:lt_operation TYPE cose_t_operation,
ls_operation LIKE LINE OF lt_operation.
DATA:ls_return TYPE bapiret2.
"需要读取工序的行数,然后将工序写入到程序中去
ls_operation-OPERATION = '20'."因为我已经有10的工序,这里自增加10,所以是20,具体需要根据实际情况使用
ls_operation-control_key = 'BTR1'."控制码
ls_operation-work_center = '201008'."工作中心
ls_operation-work_center_x = 'X'.
ls_operation-short_text = '测试工序短文本'."短文本
ls_operation-short_text_x = 'X'.
APPEND ls_operation TO lt_operation.
CALL FUNCTION 'CO_SE_PRODORD_CHANGE'
EXPORTING
iv_order_number = iv_aufnr
* IS_HEADER =
* IT_HDR_USER_STATUS =
* IT_SEQUENCE =
it_operation = lt_operation
* IT_OPR_USER_STATUS =
* IT_PRT =
* IV_COMMIT =
IMPORTING
es_return = ls_return.
IF ls_return-type = 'E'.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
ENDIF.