HU_CREATE_GOODS_MOVEMENT example ;
DATA : lv_posted TYPE sysubrc,
ls_mess TYPE huitem_messages ,
lt_mess TYPE huitem_messages_t WITH HEADER LINE,
ls_emkpf TYPE emkpf ,
lt_move_to TYPE hum_data_move_to_t,
lt_exidv TYPE hum_exidv_t WITH HEADER LINE,
ls_move_to TYPE hum_data_move_to,
ls_hu_items TYPE hum_humseg,
lv_venum TYPE vekp-venum,
gv_temp_message TYPE string.
DATA : lt_vepo TYPE TABLE OF vepo WITH HEADER LINE.
lv_venum = '100000012'. " Internal HU Number
SELECT * FROM vepo INTO TABLE lt_vepo
WHERE venum = lv_venum.
IF sy-subrc NE 0.
MESSAGE 'Please enter a valid HU !' TYPE 'I'.
EXIT.
ENDIF.
LOOP AT lt_vepo.
*** Move
ls_move_to-huwbevent = '0010'. " Process Indicator
ls_move_to-matnr = '01010101'. " Material Number
ls_move_to-lgort = lt_vepo-lgort. "
ls_move_to-grund = '0004'. " Fixed Reason
ls_move_to-bwart = '309'. " Movement Type
ls_hu_items-venum = lt_vepo-venum.
ls_hu_items-vepos = lt_vepo-vepos.
APPEND ls_hu_items TO ls_move_to-hu_items.
APPEND ls_move_to TO lt_move_to.
ENDLOOP.
*** Refresh
CALL FUNCTION 'HU_PACKING_REFRESH'.
PERFORM refresh_change_stock(saplv51e).
*** Call Function
CALL FUNCTION 'HU_CREATE_GOODS_MOVEMENT'
EXPORTING
* if_event = lv_event
if_simulate = ' '
if_commit = ' '
* if_tcode = 'MOBIL'
it_move_to = lt_move_to[]
it_external_id = lt_exidv[]
IMPORTING
ef_posted = lv_posted
es_message = ls_mess
et_messages = lt_mess[]
es_emkpf = ls_emkpf.
*** Check Result
IF NOT lv_posted = 1.
ROLLBACK WORK.
CALL FUNCTION 'HU_PACKING_REFRESH'.
CALL FUNCTION 'SERIAL_INTTAB_REFRESH'.
MESSAGE 'Problem occured!' TYPE 'I'.
ELSE.
COMMIT WORK AND WAIT.
CONCATENATE ls_emkpf-mblnr
ls_emkpf-mjahr
' document created!'
INTO gv_temp_message SEPARATED BY ' '.
MESSAGE gv_temp_message TYPE 'I'.
ENDIF.
Wednesday, April 25, 2012
Get Handling Unit Items From Delivery
By the help of the code snippet below , you can get handling units related with specified delivery.
LT_HUS -> Handling Unit Headers -> VEKP
LT_HUPOS-> Handling Unit Items -> VEPO
DATA : i_delivery TYPE likp-vbeln.
DATA : is_object TYPE hum_object.
DATA : lt_hus TYPE hum_hu_header_t WITH HEADER LINE,
lt_hupos TYPE hum_hu_item_t WITH HEADER LINE,
lt_serialno TYPE vsep_t_rserob.
is_object-object = '03'.
is_object-objkey = i_delivery.
CALL FUNCTION 'HU_GET_HUS'
EXPORTING
if_lock_hus = 'X'
if_with_text = ' '
is_objects = is_object
IMPORTING
et_header = lt_hus[]
et_items = lt_hupos[]
et_item_serialno = lt_serialno
EXCEPTIONS
hus_locked = 1
no_hu_found = 2
fatal_error = 3
OTHERS = 4.
LT_HUS -> Handling Unit Headers -> VEKP
LT_HUPOS-> Handling Unit Items -> VEPO
DATA : i_delivery TYPE likp-vbeln.
DATA : is_object TYPE hum_object.
DATA : lt_hus TYPE hum_hu_header_t WITH HEADER LINE,
lt_hupos TYPE hum_hu_item_t WITH HEADER LINE,
lt_serialno TYPE vsep_t_rserob.
is_object-object = '03'.
is_object-objkey = i_delivery.
CALL FUNCTION 'HU_GET_HUS'
EXPORTING
if_lock_hus = 'X'
if_with_text = ' '
is_objects = is_object
IMPORTING
et_header = lt_hus[]
et_items = lt_hupos[]
et_item_serialno = lt_serialno
EXCEPTIONS
hus_locked = 1
no_hu_found = 2
fatal_error = 3
OTHERS = 4.
Subscribe to:
Posts (Atom)