cancel
Showing results for 
Search instead for 
Did you mean: 

Repack of product stock from 1HU to another empty HU in EWM Development

former_member267445
Participant
0 Kudos
1,618

Hello Gurus,

Am new to EWM development. I have below requirement.

In system one HU called HU1 with product MAT1 having stock 10 KG. Another HU called HU2 with empty.

Now, I need to move the product MAT1 from HU1 to HU2(empty HU) and then need to empty HU1.

I am using the class /scwm/cl_wm_packing with repack_stock method by passing source HU(HU1) destination HU(HU2) and Stock GUID with quantity 10 KG. However am getting an error in repack_stock method stating that no HU items present. However I debug the method and I came to know there is one buffer internal table which is having HUitem in that there are no entries which is the reason why it is failing. But am not able to understand where those entries filling. The code where exactly it is failing is below

In FM /SCWM/HUITM_READ - 
* read exact item
IF NOT iv_guid_stock IS INITIAL.
READ TABLE go_hugm->gt_xhuitm INTO es_huitm
WITH KEY guid_parent = iv_guid_hu
guid_stock = iv_guid_stock
BINARY SEARCH.
IF NOT sy-subrc IS INITIAL.
READ TABLE go_hugm->gt_xhuhdr WITH KEY guid_hu = iv_guid_hu
ASSIGNING <huhdr> BINARY SEARCH.
IF sy-subrc IS INITIAL.
WRITE <huhdr>-huident TO sy-msgv1.
ENDIF.
MESSAGE i142(/scwm/hugeneral) WITH sy-msgv1 '3' RAISING no_item.
ENDIF.
RETURN.
ENDIF.

go_hugm->gt_xhuitm in this internal table there are no entries populated.

Can you please light me on the issue.

Thanks and Regards,

Muralikrishna Peravali

View Entire Topic
kaddamon
Newcomer
0 Kudos

Hi all,

I struggled with the same issue and a few trial-and-error attempts and way too many debugging sessions, I finally found a solution that worked for me.

Turns out, go_hugm->gt_xhuitm is a sneaky little buffer table here, which repack_stock( ) is reading from. Maybe it serves some mysterious purpose in certain cases. I certainly dont, and honestly, Id rather not think too much about it.

The problem is repack_stock( ) wont work if go_hugm->gt_xhuitm is empty or filled with wrong data. And no amount of cleanup magic will save us here.

But there is an easy fix: Just fill the buffer table yourself before calling repack_stock( ) by using the method get_hu( ) and you're good to go.

 

Hope that helps!

 

/scwm/cl_wm_packing=>get_instance( IMPORTING eo_instance = DATA(lo_pack) ).
lo_pack->init( […] ).

lo_pack->get_hu( […] ).  "get source-hu data to fill buffer
IF sy-subrc <> 0.
[…]    
ENDIF.

lo_pack->repack_stock( […] ) .
IF sy-subrc <> 0.
[…]
ENDIF.

lo_pack->save( […] ).
IF sy-subrc <> 0.
[…]    
ENDIF.