Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Function Module for Unpacking a shipment

Former Member
0 Likes
7,589

I'm having complications finding the right module to unpack Handling Units from a shipment. Although PROCESS_HU_INBOUND_DLVRY is for deliveries I figured it may work for shipments. However, I can't quite verify this would actually work. I also tried Unpack_Handling_Unit and HU_packing_and_unpacking. I look forward to your responses.

Thanks in advance!

24 REPLIES 24
Read only

amit_khare
Active Contributor
0 Likes
5,232

Welcome to SDN.

Check if these helps -

BAPI_HU_UNPCK

UNPACK_HANDLING_UNIT

Regards,

Amit

Read only

Former Member
0 Likes
5,232

Hi Christoper Trucker,

Try this FM's :

BAPI_HU_UNPACK

MAP2I_BAPIITMUNPACK_TO_HUUNPAC

GET_UNPACK_HU

GET_UNPACK_MAT

GET_UNPACK_PACK

GET_UNPACK_SN

UNPACK_HANDLING_UNIT

HU_UNPACK

Thanks,

Greetson

Read only

Former Member
0 Likes
5,232

Hey experts,

I got the full results using 3 function modules in this order

1) RV_SHIPMENT_VIEW

2) HU_PACKING_AND_UNPACKING

3) HU_POST

HU_POST actually updates the header which is probably what I was missing. Thanks for your input!

regards,

Read only

0 Likes
5,232

Hi,

I need to unpack HU for RF Packing and unpacking

I need to know what parameters did u pass to pack or unpack the HU for the FM HU_PACKING_AND_UNPACKING.

Do we need to pass negative quantity while unpacking? but i m getting error saying qty not entered.

Please help me with this...

Read only

0 Likes
5,232

Hi!

Did you get to do packing/unpacking of a HU? In my case, I am able to pack but not to unpack the HU. Any sugestion of which bapi/FM would work?

If you need an example code for the packing, just let me know

Thanks in advance!

Nisha

Read only

0 Likes
5,232

Hello Nisha,

Can you please pass on to me the values that are to be passed onto the FM to pack HUs onto Shipment. I guess you have already done a similar scenario.

Coming onto deletion of HU from delivery, I did small recording for the same on VL02N - goto HU's screen and choose find HU from menu - give HU to be deleted and delete it and embedded this code in a RFC for using with our scanner solution.

Though i know that BDC's on enjoy transactions are least preferred but somehow after spending lot of time on identifying BAPI/RFC i had to do this.

Hope you can pass on to me the steps of logic which you have used for packing of HU's on shipment.

Thanks in advance,

Regards,

Lakshmi Narayana

Read only

0 Likes
5,232

Hi !

I'd need your help to unpack und the pack a delivery from a HU.

The HU is created within a shipment and the delivery is packed into the HU.

We then reveive the picking information from outside. when I then try to pick the batches,

I receive the following error:

"Quantity change not permitted; 30,000 TO are packed in shipment 0000001112" (VL354)

For me this seems to be ok, because with the picking i change the packed quantity.

so far, so good. then I tried to unpack the delivery with the BAPI:

BAPI_HU_UNPACK

There I receive the follwing error:

"Processing of HUs for selected objects not possible"

This is because my object code is "04" and this object type is not allowed.

Any idea or example how to unpack a delivery from my HU within my shipment ?

Read only

0 Likes
5,232

Hi Nisha, anyone,

Im having real problems packing using HU_PACKING_AND_UNPACKING.

See description of my issue below. Most grateful if anyone can provide me with any sample code that calls the full suite of function modules in right order to pack a delivery into a HU within a shipment, including how you set up the parameters. That would be so so great!

"I have a shipment that can be viewed via the VTxxN transactions. The shipment has several deliveries in it. I want to emulate the packing of the deliveries into HU's within VT02N (brown cardboard box icon) using a BAPI or fn module.

Im having difficulties with function module HU_PACKING_AND_UNPACKING which I thought was the one to use, but this fn module has a structure GS_HEADER51 which is populated when called from VT02N but of course its not populated when I test it or call from my code, and the contents of this structure are checked.

There are other BAPI's like BAPI_HU_PACK and BAPI_HU_CREATE but I dont believe these work with deliveries."

Read only

0 Likes
5,232

Hi Jon,

The procedure to use HU_PACKING_AND_UNPACKING is like below.

All the central functions of HU operations are based on data access from global memory. So

1. Identify all the HUs need to be packed and call the FM, HU_GET_HUS which puts the details of the HUs into Global memory for later processing.

2. loop through the HUs and perform packing or unpacking using HU_PACKING_AND_UNPACKING

Sample Code:

Packing:

FORM repack_single_container USING pwa_unpacked_cont

TYPE zsd_dlvry_realoc.

  • Local data declarations

DATA: lwa_i_packing_item_hu TYPE packing_item_hu,

lwa_e_packing_item_hu TYPE packing_item_hu,

lwa_es_item TYPE vepovb,

lwa_header LIKE vekpvb,

lv_rcode TYPE sy-subrc,

lv_number TYPE vpobjkey,

lv_success TYPE c.

LOOP AT it_vekp INTO wa_vekp.

CLEAR: wa_vepo.

  • Get VEPO details

READ TABLE it_vepo INTO wa_vepo

WITH KEY unvel = wa_vekp-venum.

  • Fill the import structure for packing

CLEAR: lwa_i_packing_item_hu, lwa_e_packing_item_hu,

lv_rcode, lwa_es_item.

  • Fill the interface structure for Un-packing

lwa_i_packing_item_hu-venum = pwa_unpacked_cont-cont_venum.

lwa_i_packing_item_hu-vepos = wa_vepo-vepos.

lwa_i_packing_item_hu-velin = wa_vepo-velin.

lwa_i_packing_item_hu-sub_hu_venum = wa_vepo-venum.

lwa_i_packing_item_hu-quantity = '0'.

lwa_i_packing_item_hu-veanz = '1'.

  • Un-Pack the Truck/Container on shipment

CALL FUNCTION 'HU_PACKING_AND_UNPACKING'

EXPORTING

is_packing_request = lwa_i_packing_item_hu

IMPORTING

ef_rcode = lv_rcode

es_p_request = lwa_e_packing_item_hu

es_item = lwa_es_item

CHANGING

cs_header = lwa_header

EXCEPTIONS

missing_data = 1

hu_not_changeable = 2

not_possible = 3

customizing = 4

weight = 5

volume = 6

serial_nr = 7

fatal_error = 8

OTHERS = 9.

IF sy-subrc <> 0.

  • Clear the success flag

CLEAR: lv_success.

  • Error Message: Re-packing of bundle frm container failed

PERFORM append_errormessage USING 'E'

text-011

pwa_unpacked_cont-containerno

wa_vekp-exidv

pwa_unpacked_cont-tknum

''.

ELSE.

lv_success = 'X'.

ENDIF.

CLEAR: wa_vekp.

ENDLOOP.

  • If Un-pack of every bundle on Container/Truck is successful

IF lv_success = 'X'.

  • Commit the transaction

CALL FUNCTION 'HU_POST'

EXPORTING

if_synchron = 'X'

if_commit = 'X'

IMPORTING

ef_number = lv_number.

IF sy-subrc EQ 0.

DELETE it_unpacked_cont WHERE tknum = pwa_unpacked_cont-tknum

AND cont_venum =

pwa_unpacked_cont-cont_venum.

ENDIF.

ELSE.

  • Error Message: Repacking of bundle frm container failed

PERFORM append_errormessage USING 'E'

text-011

pwa_unpacked_cont-containerno

wa_vekp-exidv

pwa_unpacked_cont-tknum

''.

ENDIF.

ENDFORM. " repack_single_container

Unpack:

  • Local data declarations

DATA: lwa_i_packing_item_hu TYPE packing_item_hu,

lwa_e_packing_item_hu TYPE packing_item_hu,

lwa_vepo TYPE vepovb,

lwa_es_item TYPE vepovb,

lwa_header LIKE vekpvb,

lv_rcode TYPE sy-subrc,

lv_number TYPE vpobjkey,

lv_success TYPE c.

LOOP AT it_vekp INTO wa_vekp.

CLEAR: wa_vepo, lwa_vepo.

  • Get VEPO details

READ TABLE it_vepo INTO wa_vepo

WITH KEY venum = wa_vekp-venum.

READ TABLE it_vepo INTO lwa_vepo

WITH KEY unvel = wa_vekp-venum.

  • Fill the import structure for packing

CLEAR: lwa_i_packing_item_hu, lwa_e_packing_item_hu,

lv_rcode, lwa_es_item.

  • Fill the interface structure for Un-packing

lwa_i_packing_item_hu-venum = pwa_dlvry_realoc-cont_venum.

lwa_i_packing_item_hu-vepos = lwa_vepo-vepos.

lwa_i_packing_item_hu-velin = lwa_vepo-velin.

lwa_i_packing_item_hu-sub_hu_venum = wa_vepo-venum.

lwa_i_packing_item_hu-quantity = '0'.

lwa_i_packing_item_hu-veanz = '-1'.

  • Un-Pack the Truck/Container on shipment

CALL FUNCTION 'HU_PACKING_AND_UNPACKING'

EXPORTING

is_packing_request = lwa_i_packing_item_hu

IMPORTING

ef_rcode = lv_rcode

es_p_request = lwa_e_packing_item_hu

es_item = lwa_es_item

CHANGING

cs_header = lwa_header

EXCEPTIONS

missing_data = 1

hu_not_changeable = 2

not_possible = 3

customizing = 4

weight = 5

volume = 6

serial_nr = 7

fatal_error = 8

OTHERS = 9.

IF sy-subrc <> 0.

  • Clear the success flag

CLEAR: lv_success.

  • Error Message: Unpacking of bundle frm container failed

PERFORM append_errormessage USING 'E'

text-010

pwa_dlvry_realoc-containerno

wa_vekp-exidv

pwa_dlvry_realoc-tknum

''.

ELSE.

lv_success = 'X'.

ENDIF.

CLEAR: wa_vekp.

ENDLOOP.

  • If Un-pack of every bundle on Container/Truck is successful

IF lv_success = 'X'.

  • Delete the Container/Truck from shipment

PERFORM delete_truck_on_shipment

USING pwa_dlvry_realoc-containerid

pwa_dlvry_realoc-tknum

CHANGING lv_success.

IF lv_success = 'X'.

  • Commit the transaction

CALL FUNCTION 'HU_POST'

EXPORTING

if_synchron = 'X'

if_commit = 'X'

IMPORTING

ef_number = lv_number.

IF sy-subrc EQ 0.

wa_unpacked_cont-tknum = pwa_dlvry_realoc-tknum.

wa_unpacked_cont-cont_venum = pwa_dlvry_realoc-cont_venum.

wa_unpacked_cont-containerid = pwa_dlvry_realoc-containerid.

wa_unpacked_cont-containerno = pwa_dlvry_realoc-containerno.

APPEND wa_unpacked_cont TO it_unpacked_cont.

CLEAR: wa_unpacked_cont.

gv_cont_unpack_success = 'X'.

ENDIF.

ELSE.

CLEAR: gv_cont_unpack_success.

ENDIF.

ELSE.

CLEAR: gv_cont_unpack_success.

ENDIF.

Hope this helps you.

All the best

Read only

0 Likes
5,232

Hi,

The BAPI_HU_UNPACK works only if the HU is not attached to any delivery or shipment. i.e., to unpack a HU into material and batches only.

Use HU_PACKING_AND_UNPACKING for your purpose. Sample code i had already provided which unpacks all the HUs packed in a Container (another Higher level HU) which is put onto the shipment.

you can refer to the 3 steps mentioned by christopher in this same link for unpacking or repacking.

Sorry for the delayed reply but hope this helps,

All the best

Regards

Lakshmi Narayana

Read only

0 Likes
5,232

Hi Lakshmi,

Thanks so much for the reply. It is reassuring for me to know I was on the right track but was not using HU_GET_HUS, I was using V51P_FILL_GT and that is probably at the wrong "level".

I see you are using a Z table, does this contain your packed HUs that you want to "mirror" in the shipment document. If so this is what Im trying to achieve. I have a hierarchy of Hus in a Z table, with HU ids in the Z table. At the moment they do not exist as HUs in SAP and I was hoping the HU_PACKING_AND_UNPACKING would create the HU.

But perhaps not, and I feel I will have to call BAPI_HU_CREATE or something similar at first to create the HU so that when I call HU_GET_HUS it has something to fetch.

Lakshmi, I really appreciate the help and confirmation you have given me already, youve made a small team of abapers happy!

Have a great day,

Jon-Paul.

Read only

0 Likes
5,232

Hi,

Did you use BAPI_HU_CREATE to initially create the HU before you packed it? Did you set up both the header proposal and item proposal? I am doing this at the moment but coming across some issues with empty data fields - latest field it doesnt like is an empty ls_quan-alt field after performing check_opmng_gt_quantity.

When your code finishes, you do see your HU and packaging material on the top pane of the "pack material" tab dont you?

Did you ever encounter any commit or timing issues? I am using BAPI_TRANSACTION_COMMIT after every BAPI call, but if I just let my code run it gives back a bad subrc, but when I step through in debug it gets past a particular error - seems like a commit problem to me.

Thanks once again,

Jon-Paul.

Read only

0 Likes
5,232

Hi Jon,

Did you use BAPI_HU_CREATE to initially create the HU before you packed it?

Yes We did.

Did you set up both the header proposal and item proposal? I am doing this at the moment but coming across some issues with empty data fields - latest field it doesnt like is an empty ls_quan-alt field after performing check_opmng_gt_quantity.

*Yes. we are populating both Header & Item Proposal for HU that will be packed, However we create another HU (container into which we pack the above created HUs) for which we pass only Header Proposal *

When your code finishes, you do see your HU and packaging material on the top pane of the "pack material" tab dont you?

Yes. Please Note that we have defined HUs in 2 categories.

1. Bundle - HU which will (having material an auxillary parts) be packed into

2. Container - HU (which will not have any material but can hold another HU) which can hold the Bundles

In our Scenario, we create containers(HU) on shipment and then pack bundles(HU) onto them.

So we use BAPI to create first category HUs (bundles) and use the following code to create second category of HUs (Container) like in below code

    • Fill the interface parameters for Truck/Container Creation*

lwa_headerproposal-ext_id_hu_2 = pwa_dlvry_realoc-containerno.

lwa_headerproposal-pack_mat = pwa_dlvry_realoc-vhilm.

    • Create the Truck/Container with given regitration number*

CALL FUNCTION 'BAPI_HU_CREATE'

EXPORTING

headerproposal = lwa_headerproposal

IMPORTING

huheader = lwa_huheader

hukey = lv_hukey

TABLES

return = lit_return.

IF NOT lv_hukey IS INITIAL.

    • Apply conversion exit*

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = lv_hukey

IMPORTING

output = gv_container.

    • Commit the transaction*

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = 'X'.

    • Fill the shipment details*

lwa_huchanged-hu_exid = gv_container.

lwa_huchanged-pack_mat_object = '04'.

lwa_huchanged-pack_mat_obj_key = wa_newshipments-tknum.

    • Call the FM to assign truck/container to shipment*

CALL FUNCTION 'BAPI_HU_CHANGE_HEADER'

EXPORTING

hukey = lv_hukey

huchanged = lwa_huchanged

IMPORTING

huheader = lwa_huheader

TABLES

return = lit_return.

IF lit_return[] IS INITIAL.

    • Commit the transaction*

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = 'X'.

ENDIF.

ENDIF.

Now, the second category HU (Container created using above code) appears on the top pane of the packing tab and the first category of HU (bundle) will be in the lower level of pane.

Now, we use HU_PACKING_AND_UNPACKING to pack the first category HU (bundle) into Second category (container) and after successful operation the Bundle goes off from lower pane.

Did you ever encounter any commit or timing issues? I am using BAPI_TRANSACTION_COMMIT after every BAPI call, but if I just let my code run it gives back a bad subrc, but when I step through in debug it gets past a particular error - seems like a commit problem to me.

No Commit Issues faced.

Hope this clarifies some of your queries.

All the Best

Regards,

Lakshmi Narayana

Read only

0 Likes
5,232

Hi Lakshmi,

Hope you are well! Just about finished this but great if you can let me know the following:

When you created your HU bundle did you populate itemproposal and what type did you use? Did you add the quantity here, or did you wait until the packing stage to specify your packed quantity?

Im creating the initial HU with type 1 and specifying quantity when calling BAPI_HU_CREATE, but when I come to pack this and specifying VELIN as type 1 I have to specify quantity and thus the quantity doubles up.

Are you using VELIN type 1 (material type) or 2 (auxiliary) when packing the bundle onto the container?

Unfortunately your code listed for packing is your unpacking code I think, as you specify quantity of 0.

Your help much appreciated.

Kind regards,

Jon-Paul.

Read only

0 Likes
5,232

Hi Jon,

While Packing Bundle onto Container, following are the values that we are passing

  • Fill the interface structure for Packing

lwa_i_packing_item_hu-venum = lv_cont_venum.

lwa_i_packing_item_hu-vepos = lv_vepos.

lwa_i_packing_item_hu-velin = '3'.

lwa_i_packing_item_hu-sub_hu_venum = wa_vepo-venum.

lwa_i_packing_item_hu-quantity = '1'.

lwa_i_packing_item_hu-veanz = '1'.

Remember you have already created a HU via BAPI_HU_CREATE and now are trying to pack this so the quantity will be ONE (one bundle being packed) and NOT THE MATERIAL Qty in HU.

The only difference between packing and unpacking will be VEANZ indicator which will be "1" for packing and "-1" for Unpacking.

Yaah, you are right I gave you code for Unpacking and forgot to mention the above Point marked in Bold.

Do let me know if you still have any queries so that we can help you out..

All the best...

Regards,

Lakshmi Narayana.S

Read only

0 Likes
5,232

Hi Lakshmi,

Hope you are well.

Regards the packing, in your code did you refer or specify the deliveries you were packing at either the HU creation point (VPOBJ=01 outbound delivery), or at the packing point (did you pack the lowest level HU with no sub specified, but specified is_packing_request-belnr and is_packing_request-posnr)?

Or did you not specify the delivery at all?

Did you pack everything as handling units type 3 (and not material types as type 1)?

Kind regards,

Jon-Paul.

Read only

0 Likes
5,232

Hi Lakshmi,

The only way I seem to be able to get the materials on the lower pane of the packing screen to disappear is to use HU_PACKING_AND_UNPACKING, specifying the HU for the material and as HU type 1 - material type, with quantity of 1, with no sub HUs, and importantly, the delivery and delivery item. It removes the material from the lower pane as fully packed, but adds 1 extra quantity!

I guess this is because Ive used type 1 - material type, rather than HU type 3, but is I use type 3 the packing doesnt work as structure LS_VEKP does not get filled.

Kind regards,

Jon-Paul.

Read only

0 Likes
5,232

Great if you can help I so want to get this finally finished, so close!! lol

Read only

0 Likes
5,232

Hi,

Just to summarise what Im currently doing:

Step 1 - Create HU item type 1, pack_mat_object = 04 with key for shipment, to pack the material and packed quantity. This has itemproposal populated.

Step 2 - Create HU for containing HU, pack_mat_object = 04 with key for shipment. Itemproposal not populated.

At this point no delivery numbers have yet been specified.

Step 3 - Call fn module HU_GET_HUS to populate buffers

Step 4 - Call fn module HU_PACKING_AND_UNPACKING using just the HU from step 1 as the venum and exidv. No sub venum or exidv specified. Velin = 1. Quantity = 1. This has been the only way Ive been able to link the lowest level item to its associated delivery item shown in VT02N, and been the only way to get the entry on the lower pane of the packing screen to disappear as thus fully packed. However it adds an additional quantity of 1, as I suspect its because Im saying this is a material item, rather than a containing HU.

Step 5 - Call fn module HU_GET_HUS again to update the buffers

Step 6 - Call fn module HU_PACKING_AND_UNPACKING to pack the HU from step 1 into the handling HU from step 2.

The above works in that the packing hierarchy is correct, it packs HU's into the correct containing HUs, but as Ive had to do step 4 to link the lowest level HU from step 1 I get an extra packed quantity of 1! Not good.

If I dont do Step 4 the unpacked items on the lower pane of the packing screen dont disappear. If I dont do step 4 ths system seems to be able to determine the delivery, I guess from material and quantity etc, but the lower pane entries dont disappear.

Hope you can help, thanks again.

Read only

0 Likes
5,232

Hi Lakshmi,

I presume you are linking your packing to your deliveries somehow in your code, or is the system taking care of that.

I dont know if you are able, but grateful if you are able to send me your code to my addy in my profile so I can compare line for line with my own. I must be about 99% there, its frustrating! Fully understand if you are unable to.

Kind regards,

JP.

Read only

0 Likes
5,232

Hi Jon:

Could you post your code for packing ?

Thanks

Jenny

Read only

0 Likes
5,232

Hey Guys,

Using the Function module "HU_PACKING_AND_UNPACKING" for packing and unpacking were you able to get CHANGE HISTORY on the shipment document?

any input will be appreciated.

Thanks

JPK

Read only

0 Likes
5,232

Hi,

I am trying to Unpack a HU and pack that material into another HU in the outbound delivery, but facing a problem with this, can you send me the sample code which you done, so that i can check and use in my case..

Thanks,

Venakat.

Read only

0 Likes
5,232

While using the HU_Post function module in update task in the background, I am getting this failure

Runtime Errors SAPSQL_ARRAY_INSERT_DUPREC

Exception CX_SY_OPEN_SQL_DB

in code V51S_HU_UPDATE_DB

in line 61in this statement

IF NOT it_itm_insert IS INITIAL.

INSERT VEPO FROM TABLE it_itm_insert. <==== it dies here

ENDIF.

  • if the first two items are being split and then using the same HU this happens

  • then another material using its own HU * this is the scenario I get an abend.

however, if the material using its own HU goes first in sequence, then material thats needs two different line items but sam hu is next. then this scenario works.

I was wondering of anybody out there has experienced the same error. thanks in advance.