SAP工单设置技术上已完成和取消技术上已完成
工单技术上已完成和撤销技术上已完成可以用事务代码CO02设置,如图:
调用系统函数实现:
1、技术上已完成
*&---------------------------------------------------------------------* *& FORM fm_order_teco *&---------------------------------------------------------------------* * CO02设置工单为技术上已完成 FORM fm_order_teco USING VALUE(p_aufnr). DATA lt_orders TYPE TABLE OF bapi_order_key WITH HEADER LINE. DATA lt_return TYPE TABLE OF bapi_order_return WITH HEADER LINE. CLEAR:lt_orders,lt_orders[]. lt_orders-order_number = p_aufnr. APPEND lt_orders. CLEAR:lt_return,lt_return[]. CALL FUNCTION 'BAPI_PRODORD_COMPLETE_TECH' TABLES orders = lt_orders detail_return = lt_return. READ TABLE lt_return WITH KEY type = 'E'. IF sy-subrc = 0. CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'. ELSE. CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' EXPORTING wait = 'X'. ENDIF. ENDFORM.
2、撤销技术上已完成
*&---------------------------------------------------------------------* *& FORM fm_order_unteco *&---------------------------------------------------------------------* * CO02设置工单取消技术上已完成,相关表JEST,TJ02T FORM fm_order_unteco USING VALUE(p_aufnr). DATA gt_jstat TYPE jstat OCCURS 0 WITH HEADER LINE. DATA iv_objnr TYPE aufk-objnr. CLEAR:gt_jstat,gt_jstat[]. gt_jstat-stat = 'I0002'. "已释放 gt_jstat-inact = ''. APPEND gt_jstat. CLEAR gt_jstat. gt_jstat-stat = 'I0045'. "teco X代表不激活,不生效 gt_jstat-inact = 'X'. APPEND gt_jstat. SELECT SINGLE objnr INTO iv_objnr FROM aufk WHERE aufnr = p_aufnr. CALL FUNCTION 'STATUS_CHANGE_INTERN' EXPORTING client = sy-mandt objnr = iv_objnr TABLES status = gt_jstat EXCEPTIONS object_not_found = 1 status_inconsistent = 2 status_not_allowed = 3 OTHERS = 4. CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' EXPORTING wait = 'X'. ENDFORM.