Skip to Content
0
Former Member
Sep 03, 2007 at 05:42 AM

regarding bapi

14 Views

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.