Skip to Content
0
Former Member
Sep 03, 2007 at 08:27 AM

regarding bapi

11 Views

hi experts,

here i m using bapi the movement type '261' is for goods issue and '101' for goods receive ,no doubt for goods issue it is giving the document number but for goods receive it is giving error::

here the codes is:

*data declaration:

*BAPI Communication Structure: Material Document Header Data.

DATA: GM_HEADER TYPE BAPI2017_GM_HEAD_01.

*MMIM: New Key Assignment GM_CODE to Transaction of Inv. Mgmt.

DATA: GM_CODE TYPE BAPI2017_GM_CODE.

*MMIM: Output Structure For General FM To Post Goods Movement.

DATA: GM_HEADRET TYPE BAPI2017_GM_HEAD_RET.

*BAPI Communication Structure: Create Material Document Item

DATA: GM_ITEM TYPE TABLE OF

BAPI2017_GM_ITEM_CREATE WITH HEADER LINE.

*Return Parameter.

DATA: GM_RETURN TYPE BAPIRET2 OCCURS 0 WITH HEADER LINE.

DATA: GM_RETMTD TYPE BAPI2017_GM_HEAD_RET-MAT_DOC.

CLEAR: GM_RETURN, GM_RETMTD. REFRESH GM_RETURN.

  • 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 '700000000248' TO GM_ITEM-ORDERID.

MOVE '261' TO GM_ITEM-MOVE_TYPE .

MOVE '000000003000000172' TO GM_ITEM-MATERIAL.

MOVE '.01' TO GM_ITEM-ENTRY_QNT.

MOVE '6000' TO GM_ITEM-PLANT.

MOVE 'WFC1' TO GM_ITEM-STGE_LOC.

MOVE '1000006659' TO GM_ITEM-BATCH.

APPEND GM_ITEM.

clear GM_ITEM.

MOVE '700000000248' TO GM_ITEM-ORDERID.

MOVE '261' TO GM_ITEM-MOVE_TYPE .

MOVE '000000003000000170' TO GM_ITEM-MATERIAL.

MOVE '.01' TO GM_ITEM-ENTRY_QNT.

MOVE '6000' TO GM_ITEM-PLANT.

MOVE 'WFC1' TO GM_ITEM-STGE_LOC.

*MOVE '1000007730' TO GM_ITEM-BATCH.

APPEND GM_ITEM.

clear GM_ITEM.

MOVE '700000000248' TO GM_ITEM-ORDERID.

MOVE '261' TO GM_ITEM-MOVE_TYPE .

MOVE '000000001000000429' TO GM_ITEM-MATERIAL.

MOVE '.01' TO GM_ITEM-ENTRY_QNT.

MOVE '6000' TO GM_ITEM-PLANT.

MOVE 'IFC1' TO GM_ITEM-STGE_LOC.

APPEND GM_ITEM.

clear GM_ITEM.

MOVE '700000000248' TO GM_ITEM-ORDERID.

MOVE '261' TO GM_ITEM-MOVE_TYPE .

MOVE '000000001000000430' TO GM_ITEM-MATERIAL.

MOVE '.01' TO GM_ITEM-ENTRY_QNT.

MOVE '6000' TO GM_ITEM-PLANT.

MOVE 'IFC1' TO GM_ITEM-STGE_LOC.

APPEND GM_ITEM.

clear GM_ITEM.

MOVE '700000000248' TO GM_ITEM-ORDERID.

MOVE '261' TO GM_ITEM-MOVE_TYPE .

MOVE '000000001000000431' TO GM_ITEM-MATERIAL.

MOVE '.01' TO GM_ITEM-ENTRY_QNT.

MOVE '6000' TO GM_ITEM-PLANT.

MOVE 'IFC1' TO GM_ITEM-STGE_LOC.

APPEND GM_ITEM.

clear GM_ITEM.

MOVE '700000000248' TO GM_ITEM-ORDERID.

MOVE '261' TO GM_ITEM-MOVE_TYPE .

MOVE '000000001000000432' TO GM_ITEM-MATERIAL.

MOVE '.01' TO GM_ITEM-ENTRY_QNT.

MOVE '6000' TO GM_ITEM-PLANT.

MOVE 'IFC1' TO GM_ITEM-STGE_LOC.

APPEND GM_ITEM.

clear 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.

LOOP AT GM_RETURN.

WRITE:/ GM_RETURN-MESSAGE.

ENDLOOP.

*logic for receiving raw materials:

refresh gm_item.

clear gm_item.

clear gm_code.

GM_CODE-GM_CODE = '02'.

MOVE '700000000248' TO GM_ITEM-ORDERID.

MOVE '101' TO GM_ITEM-MOVE_TYPE .

MOVE '000000003000000174' TO GM_ITEM-MATERIAL.

MOVE '2' TO GM_ITEM-ENTRY_QNT.

MOVE '6000' TO GM_ITEM-PLANT.

MOVE 'WFC1' TO GM_ITEM-STGE_LOC.

APPEND GM_ITEM.

clear 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.

LOOP AT GM_RETURN.

WRITE:/ GM_RETURN-MESSAGE.

ENDLOOP.

and the error is:

4900027986 (material docu/no for '261' which is rt)

<b>Update control of movement type is incorrect (entry 101 X X)..(error for '101).</b>

kindly help me short out the problem.....