EWM PRDI交货单取消
Posted 想发财的小夏
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了EWM PRDI交货单取消相关的知识,希望对你有一定的参考价值。
FUNCTION zewm01_006.
*"----------------------------------------------------------------------
*"*"本地接口:
*" IMPORTING
*" VALUE(LV_DOC_NO) TYPE VBELN_VL
*" EXPORTING
*" VALUE(EV_TYPE) TYPE BAPI_MTYPE
*" VALUE(EV_MSG) TYPE BAPI_MSG
*"----------------------------------------------------------------------
DEFINE set_msg.
ev_type = &1. " 状态
ev_msg = &2. " 消息
END-OF-DEFINITION.
DATA: lo_controller TYPE REF TO /scmb/cl_controller,
lo_dlvhd TYPE REF TO /scwm/cl_dlv_handler_adapter,
lo_sp_prd_inb TYPE REF TO /scwm/cl_sp_prd_inb,
lt_inkey_lock TYPE /scdl/t_sp_k_head,
lv_rejected TYPE boole_d,
lt_return_codes TYPE /scmb/t_sp_return_code,
lt_inkeys TYPE /scdl/t_sp_k_head,
ls_inkey_lock TYPE /scdl/s_sp_k_head,
lt_aspect TYPE /scwm/t_sp_a_head_prdi.
CLEAR: lv_rejected.
SELECT SINGLE docid
FROM /scdl/db_refdoc
INTO @DATA(lv_docid)
WHERE refdocno = @lv_doc_no
AND refdoccat = 'ERP'
AND doccat = 'PDI'.
SELECT COUNT(*)
FROM /scdl/db_proch_i
WHERE docid = @lv_docid.
IF sy-subrc NE 0.
set_msg 'E' '未查询到交货单号'.
lv_rejected = 'X'.
ENDIF.
IF lv_rejected NE 'X'.
APPEND VALUE #( docid = lv_docid ) TO lt_inkeys.
APPEND VALUE #( docid = lv_docid ) TO lt_inkey_lock.
" 初始化
CALL METHOD /scmb/cl_controller=>get_instance
RECEIVING
eo_controller = lo_controller.
CALL METHOD lo_controller->initialize
EXPORTING
io_tm = lo_controller.
CREATE OBJECT lo_dlvhd.
IF lo_sp_prd_inb IS NOT BOUND.
CREATE OBJECT lo_sp_prd_inb
EXPORTING
io_attribute_handler = lo_dlvhd
io_message_handler = lo_dlvhd
iv_mode = /scdl/cl_sp=>sc_mode_classic.
ENDIF.
" 交货单锁定
DO 30 TIMES.
CALL METHOD lo_sp_prd_inb->('LOCK')
EXPORTING
inkeys = lt_inkey_lock
aspect = '/SCWM/S_SP_A_HEAD'
lockmode = 'E'
IMPORTING
rejected = lv_rejected
return_codes = lt_return_codes.
IF lv_rejected IS INITIAL.
EXIT.
ELSE.
WAIT UP TO '0.1' SECONDS .
ENDIF.
ENDDO.
IF lv_rejected IS NOT INITIAL.
set_msg 'E' '交货单锁定失败'.
ENDIF.
ENDIF.
IF lv_rejected EQ ''.
" 处理
CALL METHOD lo_sp_prd_inb->('EXECUTE')
EXPORTING
aspect = '/SCWM/S_SP_A_HEAD'
inkeys = lt_inkeys
action = '/SCWM/ACT_REJECT_DELIVERY'
IMPORTING
outrecords = lt_aspect
rejected = lv_rejected
return_codes = lt_return_codes.
* Call SAVE method of service provider
CALL METHOD lo_sp_prd_inb->('SAVE')
EXPORTING
synchronously = abap_true
IMPORTING
rejected = lv_rejected.
CASE lv_rejected.
WHEN abap_false.
COMMIT WORK AND WAIT.
CALL METHOD lo_sp_prd_inb->('CLEANUP')
EXPORTING
reason = /scmb/if_sp_transaction=>sc_cleanup_commit.
set_msg 'S' '拒绝并保存成功'.
WHEN abap_true.
ROLLBACK WORK.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 INTO DATA(lv_msg).
CALL METHOD lo_sp_prd_inb->('CLEANUP')
EXPORTING
reason = /scmb/if_sp_transaction=>sc_cleanup_commit.
lv_msg = '取消失败,原因:' && lv_msg.
set_msg 'E' lv_msg.
ENDCASE.
ENDIF.
ENDFUNCTION.
以上是关于EWM PRDI交货单取消的主要内容,如果未能解决你的问题,请参考以下文章