‎2008 Jun 30 8:44 AM
Hi All,
plz tell me how to use bapi 'BAPI_GOODSMVT_CREATE' in program ?
Thanks in advance.
Deepak
‎2008 Jun 30 8:49 AM
See the following sample code
BAPI TO Upload Inventory Data
*
GMCODE Table T158G - 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
06 - MB11
*
Domain: KZBEW - Movement Indicator
Goods movement w/o reference
B - Goods movement for purchase order
F - Goods movement for production order
L - Goods movement for delivery note
K - Goods movement for kanban requirement (WM - internal only)
O - Subsequent adjustment of "material-provided" consumption
W - Subsequent adjustment of proportion/product unit material
*
TABLES: ZMM_GI_WIP,
zmmint_usr,
EKKO,
MSEG.
data: begin of gmhead.
include structure bapi2017_gm_head_01.
data: end of gmhead.
data: begin of gmcode.
include structure bapi2017_gm_code.
data: end of gmcode.
data: begin of mthead.
include structure bapi2017_gm_head_ret.
data: end of mthead.
data: begin of itab occurs 100.
include structure bapi2017_gm_item_create.
data: end of itab.
data: begin of errmsg occurs 10.
include structure bapiret2.
data: end of errmsg.
data: wmenge like iseg-menge,
errflag.
LOOP AT I_TAB.
gmhead-pstng_date = G_DATE.
gmhead-doc_date = sy-datum.
gmhead-pr_uname = sy-uname.
"01 - MB01 - Goods Receipts for Purchase Order
gmcode-gm_code = '03'.
refresh itab.
clear itab.
SORT I_MAIN BY SOL_DOCNO.
LOOP AT I_MAIN WHERE SOL_DOCNO = I_TAB-SOL_DOCNO.
itab-move_type = '291'.
itab-mvt_ind = ' '.
itab-plant = I_MAIN-WERKS.
itab-material = I_MAIN-MATNR.
itab-entry_qnt = I_MAIN-ERFMG.
itab-stge_loc = I_MAIN-LGOBE.
itab-ENTRY_UOM = I_MAIN-ERFME.
itab-TR_PART_BA = '12'.
append itab.
CLEAR: ITAB.
ENDLOOP.
if not itab[] is initial.
call function 'BAPI_GOODSMVT_CREATE'
exporting
goodsmvt_header = gmhead
goodsmvt_code = gmcode
* TESTRUN = ' '
IMPORTING
goodsmvt_headret = mthead
* MATERIALDOCUMENT =
MATDOCUMENTYEAR =
tables
goodsmvt_item = itab
GOODSMVT_SERIALNUMBER =
return = errmsg.
clear errflag.
loop at errmsg.
if errmsg-type eq 'E'.
write:/'Error', errmsg-message.
errflag = 'X'.
else.
write:/ errmsg-message.
endif.
endloop.
if errflag is initial.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT =
IMPORTING
RETURN =
.
commit work and wait.
if sy-subrc ne 0.
write:/ 'Error in updating'.
exit.
endif.
endif.
endif.
ENDIF.
ENDLOOP.
‎2008 Jun 30 8:45 AM
Check out the below related program
[Removed by the moderator.]
Regards,
Santosh
‎2008 Jun 30 8:49 AM
See the following sample code
BAPI TO Upload Inventory Data
*
GMCODE Table T158G - 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
06 - MB11
*
Domain: KZBEW - Movement Indicator
Goods movement w/o reference
B - Goods movement for purchase order
F - Goods movement for production order
L - Goods movement for delivery note
K - Goods movement for kanban requirement (WM - internal only)
O - Subsequent adjustment of "material-provided" consumption
W - Subsequent adjustment of proportion/product unit material
*
TABLES: ZMM_GI_WIP,
zmmint_usr,
EKKO,
MSEG.
data: begin of gmhead.
include structure bapi2017_gm_head_01.
data: end of gmhead.
data: begin of gmcode.
include structure bapi2017_gm_code.
data: end of gmcode.
data: begin of mthead.
include structure bapi2017_gm_head_ret.
data: end of mthead.
data: begin of itab occurs 100.
include structure bapi2017_gm_item_create.
data: end of itab.
data: begin of errmsg occurs 10.
include structure bapiret2.
data: end of errmsg.
data: wmenge like iseg-menge,
errflag.
LOOP AT I_TAB.
gmhead-pstng_date = G_DATE.
gmhead-doc_date = sy-datum.
gmhead-pr_uname = sy-uname.
"01 - MB01 - Goods Receipts for Purchase Order
gmcode-gm_code = '03'.
refresh itab.
clear itab.
SORT I_MAIN BY SOL_DOCNO.
LOOP AT I_MAIN WHERE SOL_DOCNO = I_TAB-SOL_DOCNO.
itab-move_type = '291'.
itab-mvt_ind = ' '.
itab-plant = I_MAIN-WERKS.
itab-material = I_MAIN-MATNR.
itab-entry_qnt = I_MAIN-ERFMG.
itab-stge_loc = I_MAIN-LGOBE.
itab-ENTRY_UOM = I_MAIN-ERFME.
itab-TR_PART_BA = '12'.
append itab.
CLEAR: ITAB.
ENDLOOP.
if not itab[] is initial.
call function 'BAPI_GOODSMVT_CREATE'
exporting
goodsmvt_header = gmhead
goodsmvt_code = gmcode
* TESTRUN = ' '
IMPORTING
goodsmvt_headret = mthead
* MATERIALDOCUMENT =
MATDOCUMENTYEAR =
tables
goodsmvt_item = itab
GOODSMVT_SERIALNUMBER =
return = errmsg.
clear errflag.
loop at errmsg.
if errmsg-type eq 'E'.
write:/'Error', errmsg-message.
errflag = 'X'.
else.
write:/ errmsg-message.
endif.
endloop.
if errflag is initial.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT =
IMPORTING
RETURN =
.
commit work and wait.
if sy-subrc ne 0.
write:/ 'Error in updating'.
exit.
endif.
endif.
endif.
ENDIF.
ENDLOOP.
‎2008 Jun 30 9:53 AM
Hi ,
You can use it like this way.
data: i_item TYPE STANDARD TABLE OF bapi2017_gm_item_create INITIAL SIZE 0,
i_return TYPE STANDARD TABLE OF bapiret2 INITIAL SIZE 0,
wa_header TYPE bapi2017_gm_head_01,
CONSTANTS: c_code TYPE bapi2017_gm_code VALUE '04',
Then populate WA_HEADER. then call the FM
CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
EXPORTING
goodsmvt_header = wa_header
goodsmvt_code = c_code
TABLES
goodsmvt_item = i_item
return = i_return.