Hello at all,
I hope you can help me with the following problem:
On the Internet, I found only sparse information on the subject, and when I did, it was often about incoming deliveries. Or solutions with not released BAPIs were suggested, which must not be used in my case. To make matters worse, it is not entirely clear to me which fields of the structures have to be filled in which situation.
I have already found the link https://answers.sap.com/questions/11484078/function-modules-to-unassign-hu-from-a-outbound-de.html, but unfortunately that does not help me either.
I am faced with the problem that packages, which have the GLA-HU status, are to be detached from an outgoing delivery. Either the packages have been delivered individually, or as sub-HUs of a top handling unit, or are pending delivery. In this case, the goods issue document has not yet been posted.
The aim is to post corresponding packages back to the warehouse with the original EXIDV and to physically store the goods. For this purpose, a target top handling unit was created in advance or one is reused for this purpose.
The package HUs should be transferred to the destination HU one by one until the source HU, if any, is empty. Otherwise the packages have no upper HU.
The warehouse is WM managed, but not EWM.
Unfortunately, I also do not understand at what point the VEPO-VBELN and VEPO-POSNR are filled with "correct" values. Partly these packages already have a delivery number, but I cannot find it in our system. In the HU history there is always an object with the number 01, which actually corresponds to an outgoing delivery. I have already tried the following:
1. V51P_DELETE_RELATIONSHIP
2. HU_POST
This was processed successfully for a corresponding package HU without any errors.
After that the following steps are processed
3. HU_PACKING_REFRESH
4. V51P_FILL_GT
5. HU_GET_HUS
6. V51P_FILL_GT
7. HU_PACKING_AND_UNPACKING
8. HU_POST
9. WS_DELIVERY_UPDATE
When executing HU_PACKING_AND_UNPACKING the following error occurs: HUGENERAL 089 "Handling Unit &1 wurde nicht gesperrt. Aktion abgebrochen" (Handling unit &1 was not blocked - action canceled).
The sample code follows below.
PS. The LIKP and LIPS data were determined for the package HU before, because the HU was already loaded and these data are added in addition to, Line of hum_hu_header_t and hum_hu_item_t, as parameters.
Is this procedure correct at all, or should I use the function module HU_DELETE_HUs after all? In which case I would probably have to generate the packages as new handling units to be able to execute BAPI_HU_PACK?
Thank you in advance!
DATA: ls_vbkok TYPE vbkok, lt_vbpok TYPE TABLE OF vbpok, lt_ws_delivery_update_prot TYPE STANDARD TABLE OF prott, ls_p_r TYPE vsep_s_pithu, ls_p_r_result TYPE vsep_s_pithu, ls_is_objects TYPE hum_object, lt_header_loaded TYPE hum_hu_header_t, lt_items_loaded TYPE hum_hu_item_t, lt_hus TYPE hum_exidv_t, ls_v51ko TYPE v51ko, lt_v51p TYPE vsep_t_v51vp, ls_v51p LIKE LINE OF lt_v51p. APPEND is_hu_header-exidv TO lt_hus. CALL FUNCTION 'HU_PACKING_REFRESH'. CALL FUNCTION 'V51P_FILL_GT' EXPORTING it_hus = lt_hus EXCEPTIONS error_message = 1 OTHERS = 4. DATA(lv_v51p_sysubrc) = sy-subrc. IF lv_v51p_sysubrc <> 0. " log + raise ENDIF. ls_is_objects-object = '01'. ls_is_objects-objkey = is_likp-vbeln. CALL FUNCTION 'HU_GET_HUS' EXPORTING if_lock_hus = 'X' is_objects = ls_is_objects IMPORTING et_header = lt_header_loaded et_items = lt_items_loaded. IF sy-subrc <> 0. " log + raise ENDIF. MOVE-CORRESPONDING is_likp TO ls_v51ko. LOOP AT it_lips ASSIGNING FIELD-SYMBOL(<ls_lips>). CLEAR: ls_v51p. MOVE-CORRESPONDING <ls_lips> TO ls_v51p. APPEND ls_v51p TO lt_v51p. ENDLOOP. CALL FUNCTION 'V51P_FILL_GT' EXPORTING is_v51ko = ls_v51ko it_v51vp = lt_v51p EXCEPTIONS error_message = 1 OTHERS = 4. lv_v51p_sysubrc = sy-subrc. IF lv_v51p_sysubrc <> 0. " log + raise ENDIF. LOOP AT it_hu_items ASSIGNING FIELD-SYMBOL(<ls_hu_item>) WHERE venum = is_hu_header-venum. CLEAR ls_p_r. MOVE-CORRESPONDING is_hu_header TO ls_p_r. ls_p_r-belnr = is_likp-vbeln. ls_p_r-quantity = <ls_hu_item>-vemng. ls_p_r-meins = <ls_hu_item>-vemeh. CALL FUNCTION 'HU_PACKING_AND_UNPACKING' EXPORTING * if_repack = " Aufruf aus einem Umpackbaustein is_packing_request = ls_p_r " Position und Menge IMPORTING * ef_rcode = " 1,2 abw. Menge gew/vol 8: veltp 'C' es_p_request = ls_p_r_result " erweiterte Anforderungsstruktur * es_item = " Tabelle der erzeugen Positionen * CHANGING * cs_header = " nur f. Fkt. neu pro Teilmenge! * 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. " log + raise ENDIF. CALL FUNCTION 'HU_POST' EXPORTING if_synchron = 'X' if_commit = 'X' is_object = ls_is_objects. IF sy-subrc <> 0. " log + raise ENDIF. ls_vbkok-vbeln_vl = is_likp-vbeln. ls_vbkok-vbtyp_vl = 'J'. ls_vbkok-packing_final = 'X'. CALL FUNCTION 'WS_DELIVERY_UPDATE' EXPORTING vbkok_wa = ls_vbkok synchron = 'X' commit = 'X' delivery = ls_vbkok-vbeln_vl nicht_sperren = 'X' if_get_delivery_buffered = 'X' if_no_generic_system_service = 'X' TABLES vbpok_tab = lt_vbpok prot = lt_ws_delivery_update_prot. DATA(lv_ws_del_update_sysubrc) = sy-subrc. IF lv_ws_del_update_sysubrc <> 0. " log + raise ENDIF. ENDLOOP.