This is a very typical requirement in warehouse management – you need to pack a particular material into a handling unit via ABAP program. The solution is quite simple and précised if we follow the below steps.
1. Prerequisite: - we need to know the basic ABAP and working knowledge of Function module (how to use).
2. We need to execute the below Function Modules in the sequence as mentioned below in order to get the desired result.
Order of execution of Function Module will be: -
Function Module HU_PACKING_REFRESH: We call this function module before starting the packing process as it initializes all the SAP global tables – which is involved during the packing process.
Function Module HU_READ_DELIVERY_AND_INIT: We call this function module in order to populate the SAP global table which we going to use to generate HU (Handling Unit) and in packing material to Handling Unit.
It is very important to run this function module in order to fill the global tables as if you will not run this FM you not be able to generate HU at all according to the process mentioned in this document.
Please refer to below snapshot for import/export parameter –
Function Module V51P_FIND_HEADER: This Function Module is used to generate the HU related to packing material. Please refer to below snapshot for export/import parameters:
Function Module V51P_HU_CONTENS: This Function Module is used to populate the content for this generate HU and append to the SAP global table as well as the user defined internal table for further use. Please refer to below snapshot for export/import parameters:
Function Module HU_PACKING_AND_UNPACKING: This Function Module is used to pack the actual material to the Handling unit generated using packing material defined in the system. But before running the above function module you need to know the values that should be passed to Function Module using work area ls_pack_req.
Let's suppose we have only 1 material in the delivery and that material is getting packed in the generated HU and that we are packing material into HU then following values will work:-
Read lt_v51vp into ls_v51vp index 1.
MOVE-CORRESPONDING ls_v51vp TO ls_pack_req.
ls_pack_req-exidv = ls_vekpvb-exidv.
ls_pack_req-belnr = ls_v51vp-vbeln.
ls_pack_req-velin= '1'. “Packing Material into HU
ls_pack_req-quantity = '1'. “No. of material you want to pack into handling unit.
Please do note that - if we want to pack handling unit into handling unit, then please fill the ls_pack_req in the manner given below:-
wl_pack_req-venum = lv_venum_higher. “Higher Level Venum
wl_pack_req-exidv = lv_exidv_higher. “Higher Level HU
wl_pack_req-sub_hu_venum = ls_vekpvb-venum. “Lower level Venum
Note: - lv_venum_higher and lv_exidv_higher are not used or generated in this example before (in this tips), but you can generate them using the function module used in this example i.e. V51P_FIND_HEADER and V51P_HU_CONTENS but you need to take packing material different from the one already used to generate the lower level HU.
ls_vbkok_wa-vbeln = gv_delivery.
ls_vbkok_wa-packing_final = 'X'.
ls_vbkok_wa-vbeln_vl = gv_delivery.
Once these values are populated – we can call the FM HU_PACKING_AND_UNPACKING in the same manner and it will give you desired results.
Function Module WS_DELIVERY_UPDATE: We use this Function Module to save the delivery changes after HU processing. Please refer to below snapshot for export/import parameters: