Skip to Content
avatar image
Former Member

Pack customer return delivery items with an existing HU - WS_DELIVERY_UPDATE

Hi,

i have a requirement to pack customer return delivery in a HU . The HU will be generated in a earlier session and saved (BAPI_HU_CREATE is used). i am using WS_DELIVERY_UPDATE to pick and pack the delivery with HU. During the call to the FM WS_DELIVERY_UPDATE, i am encountering error "planned HU xxxxx already exist in the system". Please share your input.

sample code:

CALL FUNCTION 'WS_DELIVERY_UPDATE'
EXPORTING
vbkok_wa = lwa_vbkok
synchron = 'X'
* NO_MESSAGES_UPDATE = ' '
* COMMIT = ' '
delivery = lwa_vbkok-vbeln
update_picking = 'X'
nicht_sperren = 'X'
if_confirm_central = 'X'
* IF_WMPP = ' '
* IF_GET_DELIVERY_BUFFERED = ' '
* IF_NO_GENERIC_SYSTEM_SERVICE = ' '
if_database_update = '1'
* IF_NO_INIT = ' '
* IF_NO_READ = ' '
if_error_messages_send_0 = 'X'
* IF_NO_BUFFER_REFRESH = ' '
* IT_PARTNER_UPDATE =
* IT_SERNR_UPDATE =
* IF_NO_REMOTE_CHG = ' '
if_no_mes_upd_pack = 'X'
* IF_LATE_DELIVERY_UPD = ' '
IMPORTING
ef_error_any_0 = lv_ef_error_any_0
ef_error_in_item_deletion_0 = lv_ef_in_item_deletion_0
ef_error_in_pod_update_0 = lv_ef_in_pod_update_0
ef_error_in_interface_0 = lv_ef_in_interface_0
ef_error_in_goods_issue_0 = lv_ef_in_goods_issue_0
ef_error_in_final_check_0 = lv_ef_in_final_check_0
ef_error_partner_update = lv_ef_partner_update
ef_error_sernr_update = lv_ef_sernr_update
TABLES
vbpok_tab = gt_vbpok
prot = gt_retprot
verko_tab = gt_verko
verpo_tab = gt_verpo
* VBSUPCON_TAB =
* IT_VERPO_SERNR =
* IT_PACKING =
* IT_PACKING_SERNR =
* IT_REPACK =
* IT_HANDLING_UNITS =
* IT_OBJECTS =
* ET_CREATED_HUS =
* TVPOD_TAB =
* IT_TMSTMP =
* IT_BAPIADDR1 =
* IT_TEXTL =
* IT_TEXTH =
* IT_AAC_ITEM_BLOCK =
* IT_HU_HEADER_EPC =
* IT_HU_ITEMS_EPC =

.

Thanks,

Tashi

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    avatar image
    Former Member
    Jul 20, 2017 at 06:49 PM

    resolved it. code below.

    populating the input structures and tables

    IF p_us_gv_del IS NOT INITIAL.
    *Confirming Picking Data from Delivery Header
    ch_lwa_vbkok-vbeln_vl = p_us_gv_del.
    ch_lwa_vbkok-vbeln = p_us_gv_del.
    ch_lwa_vbkok-wabuc = 'X'.
    ch_lwa_vbkok-wadat_ist = sy-datum.
    * ch_lwa_vbkok-spe_ret_hu_update_request = 'A'.
    ENDIF.
    *Get the delivery items from the table
    SELECT vbeln,posnr,matnr,werks,lgort,lfimg,meins
    INTO TABLE @DATA(lt_del_items)
    FROM lips
    WHERE vbeln = @p_us_gv_del.

    LOOP AT lt_del_items
    ASSIGNING FIELD-SYMBOL(<fs_del_items>).
    **********************************************************
    *Confirming Picking Data from Delivery Item*
    **********************************************************
    lwa_vbpok-vbeln_vl = <fs_del_items>-vbeln.
    lwa_vbpok-posnr_vl = <fs_del_items>-posnr.
    lwa_vbpok-posnn = <fs_del_items>-posnr.
    lwa_vbpok-vbeln = <fs_del_items>-vbeln.
    lwa_vbpok-vbtyp_n = 'T'.
    lwa_vbpok-pikmg = <fs_del_items>-lfimg.
    lwa_vbpok-lfimg = <fs_del_items>-lfimg.
    lwa_vbpok-lgmng = <fs_del_items>-lfimg.
    lwa_vbpok-meins = <fs_del_items>-meins.
    lwa_vbpok-ndifm = 0.
    * lwa_vbpok-taqui = 'X'.
    lwa_vbpok-werks = <fs_del_items>-werks.
    lwa_vbpok-lgort = <fs_del_items>-lgort.
    lwa_vbpok-matnr = <fs_del_items>-matnr.

    APPEND lwa_vbpok TO ch_gt_vbpok.

    ************************************************************
    *Handling-Unit Confirmation: Header Data
    ************************************************************
    CLEAR gs_hu_info.
    READ TABLE ut_hu_info INTO gs_hu_info
    WITH KEY posnr = <fs_del_items>-posnr
    BINARY SEARCH.
    IF sy-subrc = 0.
    lwa_verko-exidv = gs_hu_info-exidv.
    lwa_verko-exida = 'E'.
    lwa_verko-vhilm = 'ZRETURNPCKG'.
    * lwa_verko-status = '001'.
    * lwa_verko-spe_updkz = 'U'.
    APPEND lwa_verko TO gt_verko.

    ************************************************************
    *Handling Unit Confirmation: Content Data
    ************************************************************
    lwa_verpo-exidv_ob = gs_hu_info-exidv.
    lwa_verpo-exidv = gs_hu_info-exidv.
    lwa_verpo-velin = '1'.
    lwa_verpo-vbeln = p_us_gv_del.
    lwa_verpo-posnr = <fs_del_items>-posnr.
    lwa_verpo-tmeng = <fs_del_items>-lfimg.
    lwa_verpo-matnr = <fs_del_items>-matnr.
    lwa_verpo-werks = <fs_del_items>-werks.
    lwa_verpo-lgort = <fs_del_items>-lgort.
    APPEND lwa_verpo TO ch_gt_verpo.

    ***************************************************************
    *Pack information
    ***************************************************************
    ls_pack-desthu = gs_hu_info-exidv.
    ls_pack-quantity = <fs_del_items>-lfimg.
    ls_pack-meins = <fs_del_items>-meins.
    ls_pack-matnr = <fs_del_items>-matnr.
    ls_pack-werks = <fs_del_items>-werks.
    ls_pack-lgort = <fs_del_items>-lgort.
    ls_pack-vbeln_vl = <fs_del_items>-vbeln.
    ls_pack-posnr_vl = <fs_del_items>-posnr.
    ls_pack-object = '03'.
    ls_pack-objkey = <fs_del_items>-vbeln.
    APPEND ls_pack TO ch_gt_pack.

    *******************************************************************
    *Get HU details
    *******************************************************************
    SELECT SINGLE venum
    INTO @DATA(lv_venum)
    FROM vekp
    WHERE exidv = @gs_hu_info-exidv.

    ls_handling_units-top_hu_external = gs_hu_info-exidv.
    ls_handling_units-top_hu_internal = lv_venum.
    ls_handling_units-venum = lv_venum.
    ls_handling_units-rfbel = <fs_del_items>-vbeln.
    ls_handling_units-rfpos = <fs_del_items>-posnr.
    APPEND ls_handling_units TO ch_gt_handling_units.
    ENDIF.

    ENDLOOP.

    * its necessary to link the HU created during the scan
    *with the delivery which is created during the inventory creation
    *VEKP table

    CALL FUNCTION 'WS_DELIVERY_UPDATE'
    EXPORTING
    vbkok_wa = lwa_vbkok
    synchron = 'X'
    commit = 'X'
    delivery = lwa_vbkok-vbeln
    update_picking = 'X'
    nicht_sperren = space
    if_confirm_central = 'X'
    if_database_update = '1'
    if_error_messages_send_0 = 'X'
    if_no_mes_upd_pack = 'X'
    IMPORTING
    ef_error_any_0 = lv_ef_error_any_0
    ef_error_in_item_deletion_0 = lv_ef_in_item_deletion_0
    ef_error_in_pod_update_0 = lv_ef_in_pod_update_0
    ef_error_in_interface_0 = lv_ef_in_interface_0
    ef_error_in_goods_issue_0 = lv_ef_in_goods_issue_0
    ef_error_in_final_check_0 = lv_ef_in_final_check_0
    ef_error_partner_update = lv_ef_partner_update
    ef_error_sernr_update = lv_ef_sernr_update
    TABLES
    it_handling_units = gt_handling_units
    et_created_hus = gt_created_hus
    EXCEPTIONS
    error_message = 1
    OTHERS = 2.

    *pack the items of the delivery in the HU
    CALL FUNCTION 'WS_DELIVERY_UPDATE'
    EXPORTING
    vbkok_wa = lwa_vbkok
    synchron = 'X'
    * NO_MESSAGES_UPDATE = ' '
    * COMMIT = ' '
    delivery = lwa_vbkok-vbeln
    update_picking = space
    nicht_sperren = 'X'
    if_confirm_central = 'X'
    if_database_update = '1'
    if_error_messages_send_0 = 'X'
    if_no_mes_upd_pack = 'X'
    IMPORTING
    ef_error_any_0 = lv_ef_error_any_0
    ef_error_in_item_deletion_0 = lv_ef_in_item_deletion_0
    ef_error_in_pod_update_0 = lv_ef_in_pod_update_0
    ef_error_in_interface_0 = lv_ef_in_interface_0
    ef_error_in_goods_issue_0 = lv_ef_in_goods_issue_0
    ef_error_in_final_check_0 = lv_ef_in_final_check_0
    ef_error_partner_update = lv_ef_partner_update
    ef_error_sernr_update = lv_ef_sernr_update
    TABLES
    vbpok_tab = gt_vbpok
    prot = gt_retprot
    verko_tab = gt_verko
    verpo_tab = gt_verpo
    EXCEPTIONS
    error_message = 1
    OTHERS = 2.

    Add comment
    10|10000 characters needed characters exceeded