Skip to Content
author's profile photo Former Member
Former Member

regarding bapi

hi experts when ever i use this bapi 'BAPI_GOODSMVT_CREATE' under loop it is not working why

here the code which i m using:

  • BAPI header data.

GM_HEADER-PSTNG_DATE = SY-DATUM.

GM_HEADER-DOC_DATE = SY-DATUM.

*Goods receipt for production order

GM_CODE-GM_CODE = '03'. " MB1A

  • Write '261' movement to table

CLEAR GM_ITEM.

MOVE '700000000102' TO GM_ITEM-ORDERID.

MOVE '261' TO GM_ITEM-MOVE_TYPE .

MOVE '000000003000000195' TO GM_ITEM-MATERIAL.

MOVE '1' TO GM_ITEM-ENTRY_QNT.

MOVE '6000' TO GM_ITEM-PLANT.

MOVE 'WFC1' TO GM_ITEM-STGE_LOC.

MOVE '1000007735' TO GM_ITEM-BATCH.

APPEND GM_ITEM.

clear GM_ITEM.

MOVE '700000000102' TO GM_ITEM-ORDERID.

MOVE '261' TO GM_ITEM-MOVE_TYPE .

MOVE '000000003000000193' TO GM_ITEM-MATERIAL.

MOVE '1' TO GM_ITEM-ENTRY_QNT.

MOVE '6000' TO GM_ITEM-PLANT.

MOVE 'LBF1' TO GM_ITEM-STGE_LOC.

MOVE '1000007730' TO GM_ITEM-BATCH.

APPEND GM_ITEM.

clear GM_ITEM.

loop at gm_item.

  • Call goods movement BAPI

CALL FUNCTION 'BAPI_GOODSMVT_CREATE'

EXPORTING

GOODSMVT_HEADER = GM_HEADER

GOODSMVT_CODE = gm_code

IMPORTING

GOODSMVT_HEADRET = GM_HEADRET

MATERIALDOCUMENT = GM_RETMTD

TABLES

GOODSMVT_ITEM = GM_ITEM

RETURN = GM_RETURN.

*IF NOT GM_RETMTD IS INITIAL.

  • COMMIT WORK AND WAIT.

  • CALL FUNCTION 'DEQUEUE_ALL'.

*ELSE.

  • COMMIT WORK AND WAIT.

  • CALL FUNCTION 'DEQUEUE_ALL'.

*ENDIF.

WRITE:/ GM_RETMTD.

CALL FUNCTION 'ENQUE_SLEEP'

EXPORTING

SECONDS = 10.

  • EXCEPTIONS

  • SYSTEM_FAILURE = 1

  • OTHERS = 2

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Posted on Sep 03, 2007 at 05:51 AM

    Hi,

    Check this

    IF NOT GM_RETMTD[] IS INITIAL.
     read table gm_return with key type = 'E'.
     if sy-subrc ne 0.
       call function 'BAPI_TRANSACTION_COMMIT'.
     endif.
    ENDIF.
    

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.