Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with BAPI BAPI_GOODSMVT_CREATE

Former Member
0 Kudos

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

2 REPLIES 2

kvenkatesh-in
Explorer
0 Kudos

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

0 Kudos

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.