ABAP EWM PRDI交货单过账
Posted 想发财的小夏
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ABAP EWM PRDI交货单过账相关的知识,希望对你有一定的参考价值。
/n/scwm/prdi 交货单过账
DATA: lo_sp_inb TYPE REF TO /scwm/cl_sp_prd_inb,
lo_adapter_handler TYPE REF TO /scwm/cl_dlv_handler_adapter,
ls_details TYPE /scmb/s_default_values_det,
ls_dynpro_data TYPE /scmb/s_dynpro_data,
ls_default_values TYPE /scmb/s_default_values,
lv_rejected TYPE boole_d,
lt_return_codes TYPE /scdl/t_sp_return_code,
ls_k_hu TYPE /scwm/s_sp_k_hu,
lt_k_hu TYPE /scwm/t_sp_k_hu,
lt_a_hu TYPE /scwm/t_sp_a_hu,
ls_docid TYPE /scwm/s_docid,
lt_docid TYPE /scwm/tt_docid,
ls_k_head TYPE /scdl/s_sp_k_head,
lt_k_head TYPE /scdl/t_sp_k_head,
ls_a_head TYPE /scdl/s_sp_a_head,
ls_q_head TYPE /scwm/s_sp_q_head,
lt_h_prdi TYPE /scwm/t_sp_a_head_prdi,
lv_return TYPE xsdboolean.
FREE: lt_k_head.
CLEAR ls_k_head.
FREE: lt_k_hu.
ls_k_hu-docid = gs_gr_01-docid .
ls_k_hu-huid = ps_gr_02-guid_hu.
APPEND ls_k_hu TO lt_k_hu.
ls_k_head-docid = gs_gr_01-docid .
APPEND ls_k_head TO lt_k_head.
ls_q_head-docno_id = gs_gr_01-docno.
TRY.
CREATE OBJECT lo_adapter_handler.
CREATE OBJECT lo_sp_inb
EXPORTING
iv_mode = /scdl/cl_sp=>sc_mode_classic
io_attribute_handler = lo_adapter_handler
io_message_handler = lo_adapter_handler.
ENDTRY.
ls_details-v_fieldname = 'LGNUM'.
ls_details-v_mandatory = abap_true.
ls_details-v_memoryid = '/SCWM/LGN'.
ls_details-v_no_dropdown = 'X'.
APPEND ls_details TO ls_default_values-t_details.
CLEAR ls_details.
ls_details-v_fieldname = 'RECEIVING_OFFICE'.
ls_details-v_no_dropdown = 'X'.
APPEND ls_details TO ls_default_values-t_details.
ls_details-v_fieldname = 'ENTITLED'.
ls_details-v_no_dropdown = 'X'.
APPEND ls_details TO ls_default_values-t_details.
ls_details-v_fieldname = 'HU_DISPLAY'.
APPEND ls_details TO ls_default_values-t_details.
ls_default_values-v_identifier = '/SCWM/PRDI'.
ls_default_values-v_values_structure = '/SCWM/S_SP_DEFAULT'.
ls_default_values-v_extended = abap_true.
SET PARAMETER ID '/SCWM/LGN' FIELD gs_rsrc-lgnum.
/scmb/cl_base=>set_process_data( io_attribute_handler = lo_adapter_handler->mo_attr_handler
io_service_provider = lo_sp_inb
io_message_handler = lo_adapter_handler->mo_msg_handler
is_dynpro_data = ls_dynpro_data
is_default_values = ls_default_values
iv_disable_standard_save = abap_true ).
CALL METHOD /scmb/cl_base=>end_of_initialization.
/scwm/cl_tm=>set_lgnum( gs_rsrc-lgnum ).
CALL METHOD lo_sp_inb->lock
EXPORTING
inkeys = lt_k_head
lockmode = /scdl/if_sp1_locking=>sc_exclusive_lock
aspect = /scwm/if_sp_c=>sc_asp_head
IMPORTING
rejected = lv_rejected
return_codes = lt_return_codes.
READ TABLE lt_return_codes TRANSPORTING NO FIELDS WITH KEY failed = abap_true.
IF sy-subrc = 0 OR lv_rejected = abap_true.
MESSAGE ID sy-msgid TYPE 'E' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 .
ENDIF.
CALL METHOD lo_sp_inb->/scmb/if_sp_query~execute
EXPORTING
inparam = ls_q_head
query = '/SCDL/QRY_HEAD'
IMPORTING
outrecords = lt_h_prdi
rejected = lv_rejected.
IF lv_rejected = abap_true.
MESSAGE ID sy-msgid TYPE 'E' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 .
ENDIF.
CALL METHOD lo_sp_inb->execute
EXPORTING
aspect = /scwm/if_sp_c=>sc_asp_hu
inkeys = lt_k_hu
action = /scwm/if_sp_c=>sc_act_hu_post_gm
relation = /scwm/if_sp_c=>sc_rel_head_to_hu
relation_inkey = ls_k_head
IMPORTING
outrecords = lt_a_hu
relation_outrecord = ls_a_head
rejected = lv_rejected
return_codes = lt_return_codes.
READ TABLE lt_return_codes TRANSPORTING NO FIELDS WITH KEY failed = abap_true.
IF sy-subrc = 0 OR lv_rejected = abap_true.
MESSAGE ID sy-msgid TYPE 'E' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 .
ENDIF.
CALL METHOD lo_sp_inb->/scmb/if_sp_transaction~save
IMPORTING
rejected = lv_rejected.
IF lv_rejected = abap_false.
COMMIT WORK AND WAIT.
CALL METHOD lo_sp_inb->/scmb/if_sp_transaction~cleanup
EXPORTING
reason = /scmb/if_sp_transaction=>sc_cleanup_commit.
CALL METHOD /scwm/cl_tm=>cleanup( ).
*******清空
CLEAR ps_gr_02.
" PERFORM disp_message USING 'ZEWM01' 'S' '000' '过账成功' '' '' ''.
ELSE.
ROLLBACK WORK.
CALL METHOD lo_sp_inb->/scmb/if_sp_transaction~cleanup
EXPORTING
reason = /scmb/if_sp_transaction=>sc_cleanup_end.
MESSAGE ID sy-msgid TYPE 'E' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 .
ENDIF.
以上是关于ABAP EWM PRDI交货单过账的主要内容,如果未能解决你的问题,请参考以下文章