‎2006 Nov 10 3:18 PM
hi all! this time i need to use BAPI_GOODSMVT_CREATE to simulate trax MIGO using an order of purchase previously generated. Is this possible to use this BAPI? if it is Ok i would need that somebody passed some example to me that has worked. sincerely, thank you very much to all by the amiability. Sorry for my english!
rewarding points for help!
‎2006 Nov 10 3:53 PM
Try this out:
DATA: h_goodsmvt_header LIKE bapi2017_gm_head_01.
DATA: h_goodsmvt_code LIKE bapi2017_gm_code.
DATA: h_goodsmvt_item LIKE bapi2017_gm_item_create
OCCURS 0 WITH HEADER LINE.
DATA: h_goodsmvt_serialnumber LIKE bapi2017_gm_serialnumber
OCCURS 0 WITH HEADER LINE.
*Header data
h_goodsmvt_header-pstng_date = pstng_date.
h_goodsmvt_header-doc_date = doc_date.
h_goodsmvt_header-HEADER_TXT = Header text
h_goodsmvt_header-REF_DOC_NO = Ref Doc #
*GM_Code 01: Goods receipt for purchase order'.
h_goodsmvt_code = '01'.
Loop on Item materials
LOOP AT p_order_goodsmvt WHERE NOT material IS INITIAL.
h_goodsmvt_item-orderid = p_orderid.
h_goodsmvt_item-mvt_ind = p_order_goodsmvt-mvt_ind.
h_goodsmvt_item-move_type = p_order_goodsmvt-move_type.
h_goodsmvt_item-plant = p_plant.
h_goodsmvt_item-stge_loc = p_stge_loc.
h_goodsmvt_item-customer = p_order_goodsmvt-customer.
h_goodsmvt_item-PO_NUMBER = p_order_goodsmvt-PO_NUMBER.
h_goodsmvt_item-PO_ITEM = p_order_goodsmvt-PO_ITEM.
If the there is an amount in the Position text fill it into
amount_lc
if p_order_goodsmvt-item_text = '0.01'.
h_goodsmvt_item-amount_lc = p_order_goodsmvt-item_text.
endif.
h_goodsmvt_item-spec_stock = p_order_goodsmvt-spec_stock.
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
EXPORTING
input = p_order_goodsmvt-material
IMPORTING
output = h_goodsmvt_item-material
EXCEPTIONS
length_error = 1
OTHERS = 2.
if sy-subrc <> 0.
h_goodsmvt_item-material = p_order_goodsmvt-material.
endif.
h_goodsmvt_item-entry_qnt = p_order_goodsmvt-entry_qnt.
h_goodsmvt_item-entry_uom = p_order_goodsmvt-entry_uom.
h_goodsmvt_item-entry_uom_iso = p_order_goodsmvt-entry_uom_iso.
APPEND h_goodsmvt_item.
To populate the serial numbers in case the part is serialized
v_matitem = v_matitem + 1.
SHIFT p_order_goodsmvt-serialno LEFT DELETING LEADING '0'.
IF NOT p_order_goodsmvt-serialno IS INITIAL.
h_goodsmvt_serialnumber-matdoc_itm = v_matitem.
h_goodsmvt_serialnumber-serialno = p_order_goodsmvt-serialno.
append h_goodsmvt_serialnumber.
ENDIF.
ENDLOOP.
call function 'BAPI_GOODSMVT_CREATE'
exporting
goodsmvt_header = h_goodsmvt_header
goodsmvt_code = h_goodsmvt_code
tables
goodsmvt_item = h_goodsmvt_item
goodsmvt_serialnumber = h_goodsmvt_serialnumber
return = return_material.
if return_material[] is initial.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = h_x.
endif.
Hope this helps! Don't forget to gimme some points.
Regards
Sudheer
‎2006 Nov 10 3:57 PM
Hello Andrés.
Allowed functionality of bapi BAPI_GOODSMVT_CREATE is determined by parameter GOODSMVT_CODE. The values are:
01 -> MB01
02 -> MB31
03 -> MB1A
04 -> MB1B
05 -> MB1C
06 -> MB11
07 -> MB04
This is defined in table T158G.
If we believe in this, then you can't use the bapi for TX MIGO.
In others posts people recomends to use movement '101' with parameter GOODSMVT_CODE = '01'. This is useful if you want to create an order related movement. But if you want to create the movement related to other document type you'll have problems.
Hope this help you.
Ronald Picado.
Message was edited by:
Ronald Picado