GitHub Guide Site

WS_DELIVERY_UPDATE_2.md

DATA:
ls_vbak_wa         TYPE vbak. " NOT strictly needed FOR WS_DELIVERY_UPDATE_2 directly but useful
DATA:
ls_vbkok_wa        TYPE vbok_wa, " Header DATA FOR delivery UPDATE
lt_prot            TYPE TABLE OF prot. " Return messages/log

DATA:
lt_handling_units_1 TYPE TABLE OF wshun_t. " Table FOR HUs IN WS_DELIVERY_UPDATE_2
DATA:
ls_handling_unit_1  TYPE wshun_t.

*&---------------------------------------------------------------------*
*& Start OF Selection
*&---------------------------------------------------------------------*
START-OF-SELECTION.

" Prepare VBKOK_WA (Delivery Header Control)
" This IS essential. We need TO specify the delivery number TO be updated.
ls_vbkok_wa-vbeln_vl = lv_delivery_number.
ls_vbkok_wa-vbtyp_vl = 'J'. " Delivery category (J FOR outbound delivery)
ls_vbkok_wa-updkz    = 'U'. " UPDATE indicator: U FOR UPDATE

" Prepare IT_HANDLING_UNITS_1 table
" This table holds the details OF the HUs TO be assigned OR changed.
CLEAR ls_handling_unit_1.
ls_handling_unit_1-exidv   = lv_hu_internal_num. " Internal HU Number (VENUM)
ls_handling_unit_1-rfbel   = lv_delivery_number. " Reference Delivery Number
ls_handling_unit_1-rfpos   = lv_delivery_item.   " Reference Delivery Item (Optional but good practice TO link TO item)
ls_handling_unit_1-kzpkz   = 'X'.                " 'X' TO pack/ASSIGN the HU
" IF you want TO unpack, SET kzpkz = SPACE.
" FOR other actions LIKE creating an HU via this FM, other FIELDS would be relevant.

APPEND ls_handling_unit_1 TO lt_handling_units_1.

" CALL the FUNCTION MODULE
CALL FUNCTION 'WS_DELIVERY_UPDATE_2'
EXPORTING
i_vbeln_vl          = lv_delivery_number " Delivery Number
is_vbkok_wa         = ls_vbkok_wa        " Header Control DATA
i_synchron          = 'X'                " Synchronous UPDATE
i_commit            = 'X'                " Commit changes
i_ubukz             = ' '                " SET 'X' FOR Goods Issue IF needed
TABLES
it_handling_units_1 = lt_handling_units_1 " Table OF Handling Units
et_prot             = lt_prot.             " Return Messages/Log