Application Development and Automation 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: 
Read only

error when executing BAPI_GOODSMVT_CREATE

Former Member
0 Likes
594

Hi,

When i am running a BAPI(BAPI_GOODSMVT_CREATE) it is throwing an error.

error:The FM MB_CREATE_GOODS_MOVEMENT is called up for second time.After it was called up for the first time Commit work was not done.

But i called BAPI_Transaction commit after BAPI_GOODSMVT_CREATE but even then it was throwing error.

Helpful answer will be rewarded.

3 REPLIES 3
Read only

Former Member
0 Likes
495

May be commit work is not being called properly try

call function 'BAPI_GOODSMVT_CREATE'.

call function 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = 'X'

IMPORTING

return = i_return.

check i_return to find out what is the exact reason.

then call for 2nd time

call function 'BAPI_GOODSMVT_CREATE'.

anya

Read only

Former Member
0 Likes
495

Hi,

Refer the theard for sample code.

https://forums.sdn.sap.com/click.jspa?searchID=12059148&messageID=1383395

Regards

Kiran Sure

Read only

Former Member
0 Likes
495

Hi Prince,

Please try this way

call function 'BAPI_GOODSMVT_CREATE'
  exporting
    goodsmvt_header             = gmhead
    goodsmvt_code               = gmcode
*   TESTRUN                     = ' '
* IMPORTING
    goodsmvt_headret            = mthead
*   MATERIALDOCUMENT            =
*   MATDOCUMENTYEAR             =
  tables
    goodsmvt_item               = itab
*   GOODSMVT_SERIALNUMBER       =
    return                      = errmsg
          .
clear errflag.
loop at errmsg.
  if errmsg-type eq 'E'.
    write:/'Error in function', errmsg-message.
    errflag = 'X'.
  else.
    write:/ errmsg-message.
  endif.
endloop.

if errflag is initial.
  commit work and wait.
  if sy-subrc ne 0.
    write:/ 'Error in updating'.
    exit.
  else.
    write:/ mthead-mat_doc, mthead-doc_year.
    perform upd_sta.
  endif.
endif.

Best regards,

raam