Skip to Content

As I was working to create a program that would do the picking , creation of handling units , packing of HU’s , unpacking of HU’s  , delivery/picking Quantity
update , I found it rather very difficult to execute the Bapi’s that were provided or use the function modules that I found while debugging the standard.

 

The Function Modules that I found while debugging the standard, would not work when executed stand alone, it required another FM that would help in buffering the data to global values.

Also after referring, the OSS 581282 Note,it clearly says that BAPI_HU_CREATE,BAPI_HU_DELETE,BAPI_HU_PACK,BAPI_HU_REPACK, BAPI_HU_UNPACK do not make updates on delivery and hence cannot be used for packing and also In the same way it is not possible to pack
deliveries with function modules of function group V51E (HU_CREATE_ITEM, HU_CREATE_ONE_HU,HU_DELETE_HU, HU_REPACK, HU_UNPACK).

Hence there is a way that I have used a FM to do various scenarios related to the delivery and I hope that it might help you all in future.

  1. Picking and Packing Materials to Handling
    Units

We can use FM WS_DELIVERY_UPDATE to update the picking quantity in order to complete the delivery and also to pack the materials to Unique Handling Units created.

 

In table lt_hvbpok various details need to be added to the table, specially keeping in mind the following fields

        lt_hvbpok-vbeln_vl = delivery no.
       lt_hvbpok-posnr_vl = delivery item.
        lt_hvbpok-posnn    = delivery item.
        lt_hvbpok-vbeln    = delivery no.
        lt_hvbpok-vbtyp_n  = ‘Q’.
        lt_hvbpok-pikmg    = Qty to be picked.
        lt_hvbpok-lfimg    = Qty to be picked.
        lt_hvbpok-lgmng    = Qty to be picked.
        lt_hvbpok-meins    = Qty to be picked unit.
        lt_hvbpok-ndifm    = 0.
        lt_hvbpok-taqui    = ‘X’.
        lt_hvbpok-werks    = Plant.
        lt_hvbpok-lgort    = Storage Location.
        lt_hvbpok-matnr    = material.
           

    

If you need to pack the materials to specific handling units, they can be created by using FM BAPI_HU_CREATE. Once the External Ids are created you could use the following FM to attach materials  to these handling units. The following fields need to be taken care of.

lst_verko-exidv =   external handling unit id.

(This can be multiple as one delivery can have n no if handling units)

lst_verpo-exidv_ob = HU external id.
               lst_verpo-exidv    = HU external id.
               lst_verpo-velin    = ‘1’
               lst_verpo-vbeln    = delivery no.
               lst_verpo-tmeng    = material quantity to be packed.
               lst_verpo-matnr    = material no.
               lst_verpo-werks    = plant.
               lst_verpo-lgort    = storage location.

Example :

CALL FUNCTION ‘WS_DELIVERY_UPDATE’
     
EXPORTING
        vbkok_wa                   
= lst_vbkok
        synchron                   
= ‘X’
       
commit                      = ‘X’
        delivery                   
= Delivery no
        update_picking             
= ‘X’
        if_database_update         
= ‘1’
        nicht_sperren              
= ‘X’
        if_error_messages_send_0   
= ‘X’
     
IMPORTING
        ef_error_any_0             
= lw_ef_error_any
        ef_error_in_item_deletion_0
= lw_ef_error_in_item_deletion
        ef_error_in_pod_update_0   
= lw_ef_error_in_pod_update
        ef_error_in_interface_0    
= lw_ef_error_in_interface
        ef_error_in_goods_issue_0  
= lw_ef_error_in_goods_issue
        ef_error_in_final_check_0  
= lw_ef_error_in_final_check
        ef_error_partner_update    
= lw_ef_error_partner_update
        ef_error_sernr_update      
= lw_ef_error_sernr_update
     
TABLES
        vbpok_tab                  
= lt_hvbpok
        prot                       
= lt_prot
        verko_tab                  
= lt_verko
        verpo_tab                  
= lt_verpo.

2. Unpacking

Now once the materials are packed to the handling units, what if you need to unpack them and repack them to different handling units.

There are mainly 2 approaches.

  1. You could use the same FM  WS_DELIVERY_UPDATE and pass the table it_repack where the source and dest HU are according to the requirement. Source and Dest HU are nothing but External Handling Units.

So consider a case where M1 is packed to Handling Unit H1 and for
some reason you need to repack the material M1 to Handling unit H2. In that
case your source HU will be H1 and dest HU will be H2 with the material details
and its quantities.

  B. Second approach, which I took, as my program requirement required it, was to completely unpack the materials from the handling units, in this case we           can again use the same function module  WS_DELIVERY_UPDATE but here you need to send the quantity as –QTY. The minus plays a crucial
          role as otherwise ull keep wondering ways why this FM is not working.

So remember, pass the same values in table lt_verko and lt_verpo  as above but send the quantities with a ‘-‘sign. : D

3. Update table Vepo/Vekp for HU’s

The best way to work around this is to use the FM V51S_HU_UPDATE_DB.

In this FM you can create, delete or update entries in table vepo or vekp. Even if the there is change in qty, it can be encountered by calling this fm .Do not forget to use  commit in the end ;). You might get an error stating that one of the tables is not defined. For this programmatically you need to declare all the tables as below even if you are passing values only in one of the table.

           CALL FUNCTION ‘V51S_HU_UPDATE_DB’
             
EXPORTING
                it_hdr_insert
= lt_ins_vekp
                it_hdr_update
= lt_upd_vekp
                it_hdr_delete
= lt_del_vekp
                it_itm_insert
= lt_ins_vepo
                it_itm_update
= lt_upd_vepo
                it_itm_delete
= lt_del_vepo
                it_his_insert
= lt_his_ins
                it_his_update
= lt_his_upd
                it_his_delete
= lt_his_del.

4. Change in Delivery Qty of material for a delivery.

What If you need to update the delv qty and picking qty of a delivery , you could do so by passing the table vbpok_tab where the new delivery quantity and picking quantity needs to be passed.

    
lst_vbpok_tab-pikmg    = picking qty
      lst_vbpok_tab-lfimg    = Delivery qty.

5. Goods Issue

We can also do goods issue using the same FM. All we need to do is pass vbkok_wa structure and in that lst_vbkok-wabuc    = ‘X’ should be marked. Also
the table vbpok_tab needs to be populated.

CALL FUNCTION ‘WS_DELIVERY_UPDATE’
     
EXPORTING
        vbkok_wa                          
= lst_vbkok
        synchron                          
= ‘X’
*       NO_MESSAGES_UPDATE                 = ‘ ‘
       
commit                             = ‘X’
        delivery                          
= Delivery no
        update_picking                    
= ‘X’
        nicht_sperren                     
= ‘X’
        if_error_messages_send_0          
= ‘X’
     
TABLES
        vbpok_tab                         
= lt_hvbpok
        prot                              
= lt_prot.

So as you can see, one function module can help us in covering so many functionalities, all we need to do is know the right table that need to be passed !!

Good Luck!!

To report this post you need to login first.

5 Comments

You must be Logged on to comment or reply to a post.

  1. Pushyami Koka

    Hi Srijan,

     

    Thanks for the details !!

     

    I have a query. As per my requirement, if one HU contains some ‘N’ packed materials and I unpacked these materials. Now I want to pack these unpacked materials in to some other HU.

     

    Now the problem is our client doesnt want to hit the database with updated details until he press ‘SAVE’ button. So if we use WS_DELIVERY_UPDATE, does it store values in DB i.e. VEKP/VEPO tables  ?

    (0) 

Leave a Reply