03-04-2006 9:59 AM
Hi All,
I am using the BAPI BAPI_GOODSMVT_CREATE in my program to create Material Document.
But, sometimes I get a message in ibapigm_ret saying 'You havent selected any items for the Material Document' <b>whereas the Material Document is actually getting created, but not available in bapigm_headret</b>.
Here is my code:
CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
EXPORTING
goodsmvt_header = bapigm_head
goodsmvt_code = bapigm_code
IMPORTING
goodsmvt_headret = bapigm_headret
TABLES
goodsmvt_item = ibapigm_item
return = ibapigm_ret.
*- Commit on Success
IF NOT bapigm_headret-mat_doc IS INITIAL.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT =
IMPORTING
RETURN =
.
Can anyone explain why this peculiar problem?
Regards,
Raj
03-04-2006 11:58 AM
Hi,
Ensure that you transfer the data in the same way as it is run in the database, for example,
Material number 18-figure with leading zeros
Batches with uppercase letters
03-04-2006 4:11 PM
Here is a sample code for bapi
Check your code with the same -
Populate header data
Posting date
x_goodsmvt_hdr-pstng_date = i_poitem-deldate.
Document date
x_goodsmvt_hdr-doc_date = i_pohdr-doc_date.
User Name
x_goodsmvt_hdr-pr_uname = i_pohdr-ernam.
User Name
x_goodsmvt_hdr-ref_doc_no = i_pohdr-pojde.
Bill of lading
x_goodsmvt_hdr-bill_of_lading = i_poitem-supp_so+0(16).
Purchase order number
i_goodsmvt_item-po_number = i_poitem-ebeln.
Line item number
i_goodsmvt_item-po_item = i_poitem-ebelp.
Plant
i_goodsmvt_item-plant = i_poitem-jdewerks.
Movement type
i_goodsmvt_item-move_type = p_movtype.
Movement indicator
i_goodsmvt_item-mvt_ind = c_mvt_ind.
GR quantity
if p_movtype = c_101.
i_goodsmvt_item-entry_qnt = i_poitem-menge.
endif.
GR UOM
i_goodsmvt_item-entry_uom = i_poitem-meins.
Storage location
i_goodsmvt_item-stge_loc = i_poitem-lgort.
Production date
i_goodsmvt_item-prod_date = i_pohdr-doc_date.
Delivery completion indicator
i_goodsmvt_item-no_more_gr = c_x.
Movement Reason
if p_movtype = c_122.
i_goodsmvt_item-move_reas = c_12.
endif.
clear i_mat_doc.
if p_movtype = c_102 or
p_movtype = c_122.
loop at i_mat_doc where ebeln = i_poitem-ebeln and
ebelp = i_poitem-ebelp.
i_goodsmvt_item-ref_doc = i_mat_doc-lfbnr.
i_goodsmvt_item-ref_doc_it = i_mat_doc-lfpos.
i_goodsmvt_item-ref_doc_yr = i_mat_doc-lfgja.
i_goodsmvt_item-entry_qnt = i_mat_doc-menge.
append i_goodsmvt_item.
endloop.
else.
append i_goodsmvt_item.
endif.
endloop.
call function 'BAPI_GOODSMVT_CREATE'
exporting
goodsmvt_header = x_goodsmvt_hdr
goodsmvt_code = x_mvt_code
importing
materialdocument = l_mat_doc
matdocumentyear = l_mat_doc_year
tables
goodsmvt_item = i_goodsmvt_item
return = i_bapireturn.