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

ashok_kumar24
Contributor
0 Likes
1,208

Hello Experts,

Can some one help me with a sample abap program making use of the BAPI function BAPI_GOODSMVT_CREATE to generate Goods Receipts with reference to an outbound delivery.

what are the fields of the internal table i will need to populate and from which tables am i to fetch the relavent data.

Can anyone give me example code.

Thanks

Kumar

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
713

Check out the sample code in the below link

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

Regards,

Santosh

2 REPLIES 2
Read only

Former Member
0 Likes
714

Check out the sample code in the below link

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

Regards,

Santosh

Read only

Former Member
0 Likes
713

Hi Ashok,

Try this example..

************************************************************************

  • APPLICATION DATA DECLARATIONS

************************************************************************

  • Tables

  • Variables

data: v_ponum type ebeln,

v_poitem type ebelp,

v_count type i,

v_qty type mb_erfmg,

v_fail(1) type c,

v_fd(2) type c,

v_del type eloek,

v_orderqty type bstmg,

v_rcptqty type menge_d,

v_dnote(16) type c,

v_bd(16) type c.

data: bdcdata type table of bdcdata,

itab type table of bdcmsgcoll,

wa_bdcdata type bdcdata,

wa_itab type bdcmsgcoll,

l_error(1) type c,

l_qty(14) type c,

l_yy(4) type c,

l_mm(2) type c,

l_dd(2) type c,

l_date(10) type c,

l_success(1) type c,

l_opt type ctu_params,

zimex_mfbf,

l_sy-msgid like sy-msgid,

l_sy-msgty like sy-msgty,

l_sy-msgno like sy-msgno,

l_sy-msgv1 like sy-msgv1,

l_sy-msgv2 like sy-msgv2,

l_sy-msgv3 like sy-msgv3,

l_sy-msgv4 like sy-msgv4.

constants: c_bslash(1) type c value '/'.

.

  • Constants

  • Internal Table for BDC data

************************************************************************

  • START-OF-SELECTION

************************************************************************

start-of-selection.

data: l_header like BAPI2017_GM_HEAD_01,

l_code like BAPI2017_GM_CODE.

data: l_return like BAPIRET2 occurs 0 with header line.

data: l_item like BAPI2017_GM_ITEM_CREATE occurs 0 with header line.

refresh l_item.

clear: l_header,

l_code,

l_item,

l_return.

l_header-PSTNG_DATE = sy-datum.

l_code-GM_CODE = '04'.

l_item-MATERIAL = 'JDD1500L93B0'.

l_item-PLANT = '4194'.

l_item-STGE_LOC = '5496'.

l_item-BATCH = 'TR99999999'.

l_item-MOVE_TYPE = '411'.

l_item-SPEC_STOCK = 'K'.

l_item-VENDOR = '841517003'.

l_item-ENTRY_QNT = 1.

append l_item.

CALL FUNCTION 'BAPI_GOODSMVT_CREATE'

EXPORTING

goodsmvt_header = l_header

goodsmvt_code = l_code

  • TESTRUN = ' '

  • IMPORTING

  • GOODSMVT_HEADRET =

  • MATERIALDOCUMENT =

  • MATDOCUMENTYEAR =

tables

goodsmvt_item = l_item

  • GOODSMVT_SERIALNUMBER =

return = l_return

.

if l_return is initial.

refresh l_item.

clear: l_header,

l_code,

l_item,

l_return.

l_header-PSTNG_DATE = sy-datum.

l_code-GM_CODE = '04'.

l_item-MATERIAL = 'JDD1500L93B0'.

l_item-PLANT = '4194'.

l_item-STGE_LOC = '5496'.

l_item-BATCH = 'TR99999999'.

l_item-MOVE_TYPE = '309'.

l_item-ENTRY_QNT = 1.

l_item-MOVE_MAT = 'JDD1500L93B0'.

l_item-MOVE_PLANT = '4194'.

l_item-MOVE_STLOC = '5496'.

l_item-MOVE_BATCH = 'TR99999997'.

append l_item.

CALL FUNCTION 'BAPI_GOODSMVT_CREATE'

EXPORTING

goodsmvt_header = l_header

goodsmvt_code = l_code

  • TESTRUN = ' '

  • IMPORTING

  • GOODSMVT_HEADRET =

  • MATERIALDOCUMENT =

  • MATDOCUMENTYEAR =

tables

goodsmvt_item = l_item

  • GOODSMVT_SERIALNUMBER =

return = l_return

.

if l_return is initial.

commit work.

endif.

endif.

Please reward if useful and the close the query.