sexta-feira, 19 de agosto de 2022

Delivery and Shipment handling units

 Business Requirement :

1.Creation of Delivery Handling unit for over packing and master cartons even if over packing is not required.
2 Creation of Shipment Handling Unit for boxes packed in Deliveries to allow receipt by HU# in the receiving plants.

Challenges : While creating shipment handling unit, all the delivery handling units are automatically attached to the shipment handling unit and they are deleted from deliveries when the BAPI (BAPI_HU_CREATE) is used. BAPI_HU_CREATE has the parameter LOWER_LEVEL_EXID is present in tables parameter (BAPIHUITEM), however after using this parameter to attach the delivery handling units to Shipment, these handling units are deleted from delivery.

Solution – In order to avoid above issue we had gone ahead of different approach and able to attach the delivery handling units to shipment with correct hierarchy. we need to call the below bapi’s in sequence to achieve the above functionality

head_proposal-hu_status_init = Pass 'A' ."Planned.
head_proposal-pack_mat = Pass Packaging Material
"Call the below function module to create an Unassigned HU object.
CALL FUNCTION 'BAPI_HU_CREATE'
EXPORTING
headerproposal = _head_proposal
IMPORTING
huheader = hu_header
hukey = hu_key
TABLES
return = return.
IF hu_key IS NOT INITIAL.
"Call the below function module to Commit the data
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'
IMPORTING
return = return.
" Assign to a Shipment
hu_header-pack_mat_object = '04'. "04-HU Type for Shipment
hu_header-pack_mat_obj_key = Shipment number "Shipment #
hu_header-lenght = Pass Pallet length
hu_header-width = Pass Pallet Width
hu_header-height = Pass Pallet Height
hu_header-total_wght = Pass Pallet weight
hu_header-unit_dim = Pass Pallet Uom for dimensions
hu_header-unit_of_wt = Pallet Uom
hu_header-max_unit_of_wght = Pallet Uom.
ENDIF.
"Call the below function module to assign the handling unit to shipment
CALL FUNCTION 'BAPI_HU_CHANGE_HEADER'
EXPORTING
hukey = hu_key
huchanged = hu_header
TABLES
return = change_return.
IF change_return[] IS INITIAL.
"Call the below function module to commit the data by assigning Shipment to Handling Unit
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'
IMPORTING
return = return.
" Get the Internal Handling unit based on external handling unit and prepare the handling unit numbers (Box_pallet_venum) which needsto be passed to below function module.
" The below function module is called for filling the global memory
CALL FUNCTION 'HU_GET_HUS'
EXPORTING
if_lock_hus = co_x
if_no_loop = co_x
it_venum = box_pallet_venum
EXCEPTIONS
hus_locked = 1
no_hu_found = 2
fatal_error = 3
OTHERS = 4.
"Each and every Internal handling unit (Boxes) to be attached to shipment and the below function module should be called in a loop.
packing_request-venum = Hu_header-hu_id.
packing_request-exidv = hu_key.
packing_request-velin = '3'.
packing_request-sub_hu_venum = vekp-venum.
packing_request-quantity = '1'.
Packing_request-veanz = '1'.
" The below function module is called to Repack the deliveries in the shipment which is required for hierarchy in shipment
CALL FUNCTION 'HU_PACKING_AND_UNPACKING'
EXPORTING
if_repack = 'X'
is_packing_request = packing_request
IMPORTING
ef_rcode = return_code
CHANGING
cs_header = cs_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 EQ 0.
" Call the below function module to commit the data by assigning Shipment to Handling Unit
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'
"If the Pallet packing is successful then only call the below function module
" The below function module commits the data to database.
CALL FUNCTION 'HU_POST'
EXPORTING
if_commit = 'X'
ENDIF.

Negative  results – ( when the Bapi  Function module (BAPI_HU_CREATE) is used and passing the parameter  LOWER_LEVEL_EXID), the output as follows

  1. Delivery handling units are correctly packed and the hierarchy is correct

2. However when we pack the  delivery boxes to shipment the hierarchy is off as shown below. The hierarchy should be ‘0’ for Shipment  handling unit,’1′ for delivery handling unit  and ‘2’ for material.

Positive results – ( when the Function modules are called in sequence as suggested in the blog)

1.The handling units for delivery are shown below which was successfully attached to delivery

2. HUPAST tcode for handling units with respect to delivery.

 

3. Handling units with respect to delivery shown below and the important element is the hierarchy (Shipment handling unit comes first , then delivery handling unit and then the packaging materials.

 

Note : The above usage of FM’S and Bapi’s needs to be called sequentially as shown above to achieve the functionality. The high level code is provided as solution

Source: https://blogs.sap.com/2017/08/17/delivery-and-shipment-handling-units/

Nenhum comentário:

Postar um comentário