Skip to Content
0
Former Member
Sep 03, 2007 at 12:04 PM

regarding bapi

18 Views

HI experts,

i m writing this codes for goods movement,,,,,,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 '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 'WFC1' TO GM_ITEM-STGE_LOC.

MOVE '1000007730' TO GM_ITEM-BATCH.

APPEND GM_ITEM.

clear GM_ITEM.

MOVE '700000000102' TO GM_ITEM-ORDERID.

MOVE '261' TO GM_ITEM-MOVE_TYPE .

MOVE '000000001000000389' TO GM_ITEM-MATERIAL.

MOVE '1' TO GM_ITEM-ENTRY_QNT.

MOVE '6000' TO GM_ITEM-PLANT.

MOVE 'FCRM' TO GM_ITEM-STGE_LOC.

APPEND GM_ITEM.

clear GM_ITEM.

MOVE '700000000102' TO GM_ITEM-ORDERID.

MOVE '261' TO GM_ITEM-MOVE_TYPE .

MOVE '000000001000000390' TO GM_ITEM-MATERIAL.

MOVE '1' TO GM_ITEM-ENTRY_QNT.

MOVE '6000' TO GM_ITEM-PLANT.

MOVE 'FCRM' TO GM_ITEM-STGE_LOC.

APPEND GM_ITEM.

clear GM_ITEM.

MOVE '700000000102' TO GM_ITEM-ORDERID.

MOVE '261' TO GM_ITEM-MOVE_TYPE .

MOVE '000000001000000391' TO GM_ITEM-MATERIAL.

MOVE '1' TO GM_ITEM-ENTRY_QNT.

MOVE '6000' TO GM_ITEM-PLANT.

MOVE 'FCRM' TO GM_ITEM-STGE_LOC.

APPEND GM_ITEM.

clear GM_ITEM.

MOVE '700000000102' TO GM_ITEM-ORDERID.

MOVE '261' TO GM_ITEM-MOVE_TYPE .

MOVE '000000001000000392' TO GM_ITEM-MATERIAL.

MOVE '1' TO GM_ITEM-ENTRY_QNT.

MOVE '6000' TO GM_ITEM-PLANT.

MOVE 'FCRM' 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 for hot alloy:

refresh gm_item.

clear gm_item.

clear gm_code.

GM_CODE-GM_CODE = '02'.

MOVE '700000000102' TO GM_ITEM-ORDERID.

MOVE '101' TO GM_ITEM-MOVE_TYPE .

MOVE '000000003000000196' TO GM_ITEM-MATERIAL.

MOVE '6' TO GM_ITEM-ENTRY_QNT.

MOVE '6000' TO GM_ITEM-PLANT.

MOVE 'WFC1' TO GM_ITEM-STGE_LOC.

move 'F' to gm_item-MVT_IND.

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-TYPE,GM_RETURN-LOG_NO,GM_RETURN-FIELD,

GM_RETURN-MESSAGE.

ENDLOOP.

when i execute my first bapi it is giving doc number for first '5' components with mvmnt type '261' and when i execute my second bapi it is giving doc number for finished product with mvmnt type '101 no doubt the goods movemnt are working fine after this i have to confirm the production order for these components plz help me how will i use this bapi 'BAPI_PRODORDCONF_CREATE_HDR' what parameter sud i pass and how....plz help me...