function y_adjo. *"---------------------------------------------------------------------- *"*"Local Interface: *" IMPORTING *" REFERENCE(IV_DLV_NUM) TYPE STRING *"---------------------------------------------------------------------- data: lt_k_item type /scdl/t_sp_k_item ,lv_lfr type /scdl/dl_docid ,lv_qty type /scdl/db_proci_o-qty ,wa_k_item like line of lt_k_item ,ls_action type /scdl/s_sp_act_action ,ls_prcode type /scwm/dlv_prcode_add_str ,lo_prd_out type ref to /scdl/cl_sp_prd_out ,lt_a_item type /scdl/t_sp_a_item ,lv_rejected type boole_d ,lo_message_box type ref to /scdl/cl_sp_message_box ,lt_a_head type /scdl/t_sp_a_head ,lt_k_head type /scdl/t_sp_k_head ,wa_k_head like line of lt_k_head ,lt_return_codes type /scdl/t_sp_return_code. field-symbols: <fs_action_control>. ls_action-action_code = /scwm/if_dl_c=>sc_ac_prcode_add. create data ls_action-action_control type /scwm/dlv_prcode_add_str. * Lieferung select single docid into lv_lfr from /scdl/db_refdoc where refdocno eq iv_dlv_num and refdoccat eq 'ODR'. select docid into wa_k_item-docid from /scdl/db_proch_o where docno = '00000000000000000000000000000101423'. endselect. select itemid from /scdl/db_proci_o into wa_k_item-itemid where docno = '00000000000000000000000000000101423' and itemno = '0000000040'. endselect. if sy-subrc ne 0. message s038(/scdl/bo_action) display like 'E'. " Keine Lieferung gefunden endif. append wa_k_item to lt_k_item. if lo_prd_out is initial. create object lo_message_box. create object lo_prd_out exporting io_message_box = lo_message_box iv_mode = /scdl/cl_sp=>sc_mode_classic iv_doccat = /scdl/if_dl_doc_c=>sc_doccat_out_prd. endif. * Select Delivery wa_k_head-docid = wa_k_item-docid. append wa_k_head to lt_k_head. clear lv_rejected. refresh lt_return_codes. lo_prd_out->/scdl/if_sp1_aspect~select( exporting inkeys = lt_k_head aspect = /scdl/if_sp_c=>sc_asp_head importing outrecords = lt_a_head rejected = lv_rejected return_codes = lt_return_codes ). * Lieferung sperren clear lv_rejected. refresh lt_return_codes. lo_prd_out->lock( exporting inkeys = lt_k_head aspect = /scdl/if_sp_c=>sc_asp_head lockmode = /scdl/if_sp1_locking=>sc_exclusive_lock importing rejected = lv_rejected return_codes = lt_return_codes ). * check if any error occurred "mcr_fill_error 'Lock delivery failed'. * adjust delivery clear lv_rejected. refresh lt_return_codes. ls_action-action_code = /scwm/if_dl_c=>sc_ac_prcode_add. create data ls_action-action_control type /scwm/dlv_prcode_add_str. assign ls_action-action_control->* to <fs_action_control>. ls_prcode-prcode = 'O001'. ls_prcode-qty = -1. ls_prcode-uom = 'ST'. <fs_action_control> = ls_prcode. lo_prd_out->/scdl/if_sp1_action~execute( exporting aspect = /scdl/if_sp_c=>sc_asp_item inkeys = lt_k_item inparam = ls_action action = /scdl/if_sp_c=>sc_act_execute_action importing outrecords = lt_a_item rejected = lv_rejected return_codes = lt_return_codes ). * check if any error occurred if lv_rejected is not initial. " or line_exists( lt_return_codes[ failed = 'x'] ). " rollback work. " mcr_fill_error 'delivery qty adjust failed'. else. lo_prd_out->save( ). commit work and wait. " ls_odo-msgtxt = 'delivery qty adjust successfully'. endif. /scwm/cl_tm=>cleanup( ). endfunction.