Packing Program for Packing Material into HU (Handling Unit)

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: -
                           I. HU_PACKING_REFRESH
                           II. HU_READ_DELIVERY_AND_INIT
                           III. V51P_FIND_HEADER
                           IV. V51P_HU_CONTENS
                           V. HU_PACKING_AND_UNPACKING
                           VI. WS_DELIVERY_UPDATE

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 –

SAP Warehouse Management

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:

SAP Warehouse Management

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:

SAP Warehouse Management Tips

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-venum= ls_vekpvb-venum.

  ls_pack_req-exidv       = ls_vekpvb-exidv.

  ls_pack_req-altme= ls_v51vp-vrkme.

  ls_pack_req-meins= ls_v51vp-meins.

  ls_pack_req-belnr       = ls_v51vp-vbeln.

  ls_pack_req-posnr= ls_v51vp-posnr.

  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:

SAP Warehouse Management Tip

Author: Vivek Kumar


SAP ABAP Technical Consultant/Vistex Technical/CRM Technical Consultant More than 5 years of total IT industry experience encompassing skill set, roles and industry verticals. Experience involved with requirement designing in ERP domain as a technical consultant. Currently Working as ABAP team member. The functional module where provided technical solutions are Order to cash ( OTC/ Sales & Distribution), Procure to Plant ( PTP/Material Management and Production Planning ), Plant to Distribution (PTD/ Production Planning). Knowledge of ABAP Programming Techniques with different modules like Vistex and different functional module. Worked on Social CRM platform as CRM technical consultant and BRF+ Consultant for 1.5 years. Worked on DDIC, Report, Enhancement,screen design, Conversion, Function Module, Interface, Transaction Variant etc. Analyses of Functional Specification, Technical Specification and Unit Test Plan preparation. Experience of 1 implementation, 2 post implementation support, 1 Upgrade project and 2 continuous Enhancement Projects.

Module(s): ABAP, Basis, CRM