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

BAPI_GOODSMVT_CREATE

Former Member
0 Likes
1,646

Hi experrts,

I want to post a GR from workorder using above mentioned bapi. can anyone suggest me, which movement code i have to use and what are the mandatory values i have to pass to post the document sucessfully. If possible give me a example code.

with regards ,

James ...

Valuable answers will be rewarded .....

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,177

Try this code...

Here is some sample code from one of my programs, which does a 551 movement type. This should get you started. Just check the RETURN table for messages, they should tell you what you are missing.

  • Structures for BAPI

data: gm_header type bapi2017_gm_head_01.

data: gm_code type bapi2017_gm_code.

data: gm_headret type bapi2017_gm_head_ret.

data: gm_item type table of

bapi2017_gm_item_create with header line.

data: gm_return type bapiret2 occurs 0.

data: gm_retmtd type bapi2017_gm_head_ret-mat_doc.

clear: gm_return, gm_retmtd. refresh gm_return.

  • Setup BAPI header data.

gm_header-pstng_date = sy-datum.

gm_header-doc_date = sy-datum.

gm_code-gm_code = '06'. " MB11

  • Write 551 movement to table

clear gm_item.

move '551' to gm_item-move_type .

move '000000000040001234' to gm_item-material.

move '1' to gm_item-entry_qnt.

move 'EA' to gm_item-entry_uom.

move '0004' to gm_item-plant.

move '4000' to gm_item-stge_loc.

move '201' to gm_item-move_reas.

  • Determine cost center per plant

case xresb-werks.

when '0004'.

move '0000041430' to gm_item-costcenter.

when '0006'.

move '0000041630' to gm_item-costcenter.

when '0007'.

move '0000041731' to gm_item-costcenter.

when '0008'.

move '0000041830' to gm_item-costcenter.

endcase.

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

call function 'BAPI_TRANSACTION_COMMIT'

exporting

wait = 'X'.

Reward if helpful..

Regards

3 REPLIES 3
Read only

Former Member
0 Likes
1,178

Try this code...

Here is some sample code from one of my programs, which does a 551 movement type. This should get you started. Just check the RETURN table for messages, they should tell you what you are missing.

  • Structures for BAPI

data: gm_header type bapi2017_gm_head_01.

data: gm_code type bapi2017_gm_code.

data: gm_headret type bapi2017_gm_head_ret.

data: gm_item type table of

bapi2017_gm_item_create with header line.

data: gm_return type bapiret2 occurs 0.

data: gm_retmtd type bapi2017_gm_head_ret-mat_doc.

clear: gm_return, gm_retmtd. refresh gm_return.

  • Setup BAPI header data.

gm_header-pstng_date = sy-datum.

gm_header-doc_date = sy-datum.

gm_code-gm_code = '06'. " MB11

  • Write 551 movement to table

clear gm_item.

move '551' to gm_item-move_type .

move '000000000040001234' to gm_item-material.

move '1' to gm_item-entry_qnt.

move 'EA' to gm_item-entry_uom.

move '0004' to gm_item-plant.

move '4000' to gm_item-stge_loc.

move '201' to gm_item-move_reas.

  • Determine cost center per plant

case xresb-werks.

when '0004'.

move '0000041430' to gm_item-costcenter.

when '0006'.

move '0000041630' to gm_item-costcenter.

when '0007'.

move '0000041731' to gm_item-costcenter.

when '0008'.

move '0000041830' to gm_item-costcenter.

endcase.

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

call function 'BAPI_TRANSACTION_COMMIT'

exporting

wait = 'X'.

Reward if helpful..

Regards

Read only

0 Likes
1,177

Try Movment type as 101 ,I think it will work for Work order as well ..

Regards

Tushar

Read only

Former Member
0 Likes
1,177

hi

there are a lot of threads with sample code related to your question...pl search the forum

http://www.sap-img.com/abap/bapi-goodsmvt-create-to-post-goods-movement.htm

i believe gm_code should be 05 (Other goods receipts)...if manually done, then in what txn. code, it would be done, cross check this with the following or GMCODE Table T158G and give the gm_code

01 - MB01 - Goods Receipts for Purchase Order

  • 02 - MB31 - Goods Receipts for Prod Order

  • 03 - MB1A - Goods Issue

  • 04 - MB1B - Transfer Posting

  • 05 - MB1C - Enter Other Goods Receipt

if helpful, reward

Sathish. R