‎2008 Mar 27 1:02 AM
HI Frriends,
I am totally new to bapi .Rt now i have given a task that is goods should transfer from one plant to amother plant....using BAPI_GOODSMVT_CREATE. but i am getting a error ....the code which i have written is as follows:
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.
ALV .......................
..........................................
............................(Some coding)
FORM BAPI_GOODS_MVT.
gmhead-pstng_date = sy-datum.
gmhead-doc_date = sy-datum.
gmhead-pr_uname = sy-uname.
gmcode-gm_code = '04'. "04 - MB1B - Transfer Posting
loop at IT_FINAL.
itab-move_type = '301'.
itab-material = it_final-matnr.
itab-plant = it_final-f_werks .
itab-stge-loc = it final-f_lgort .
itab-plant = it_final-t_werks .
itab-stge-loc = it_final-t_lgort .
itab-entry-qnt = it_final-labst .
itab-move-reas = it_final-remark.
append itab.
endloop.
CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
EXPORTING
GOODSMVT_HEADER = gmhead
GOODSMVT_CODE = gmcode
TESTRUN = ' '
IMPORTING
GOODSMVT_HEADRET =
MATERIALDOCUMENT =
MATDOCUMENTYEAR =
TABLES
GOODSMVT_ITEM = itab
GOODSMVT_SERIALNUMBER =
RETURN = errmsg
.
clear errflag.
loop at errmsg.
if errmsg-type eq 'E'.
write:/'Error in function', errmsg-message.
errflag = 'X'.
else.
write:/ errmsg-message.
endif.
endloop.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.
endif.
endif.
ENDIF.
endloop.
i have pased the whole data in internal table that is it_final...the error i am getting as itab-stge-loc = it final-f_lgort .here asfield it is unknown...it is neither specifiend in table or data...can any one chk what is the error n give me the solution...
‎2008 Mar 27 7:01 AM
DATA : lrc TYPE sy-subrc,
lasnqty TYPE zmm001-qty ,
lasnqtycount TYPE zmm001-qty ,
lasnqtyrev TYPE zmm001-qty ,
lebeln TYPE ekpo-ebeln,
lebelp TYPE ekpo-ebelp,
lvbeln TYPE likp-vbeln,
lmblnr TYPE mseg-mblnr,
llgort TYPE mard-lgort,
lbox TYPE rv50a-verur_la.
DATA:l_matedoc LIKE mkpf-mblnr.
DATA: BEGIN OF it_result OCCURS 1000,
msg(220) TYPE c, "Error message
END OF it_result.
DATA:
itab_header LIKE bapi2017_gm_head_01 OCCURS 0 WITH HEADER LINE,
itab_code LIKE bapi2017_gm_code OCCURS 0 WITH HEADER LINE,
itab_item LIKE bapi2017_gm_item_create OCCURS 0 WITH HEADER LINE,
it_return LIKE bapiret2 OCCURS 0 WITH HEADER LINE.
itab_code-gm_code = '01'.
itab_header-doc_date = sy-datum.
itab_header-pstng_date = sy-datum.
itab_header-header_txt = itab-ASNNO.
itab_header-ref_doc_no = itab-ref_doc.
itab_item-material = itab-matnr.
itab_item-plant = itab-plant.
itab_item-stge_loc = p_lgort.
itab_item-batch = itab-batch.
itab_item-move_type = '101'.
itab_item-entry_qnt = itab-asnqty.
itab_item-entry_uom = itab-uom.
itab_item-vendor = itab-vendor.
itab_item-po_number = itab-ebeln.
itab_item-po_item = itab-ebelp.
itab_item-item_text = itab-vpn.
itab_item-mvt_ind = 'B'.
APPEND itab_item.
CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
EXPORTING
goodsmvt_header = itab_header
goodsmvt_code = itab_code
IMPORTING
materialdocument = l_matedoc "material document
TABLES
goodsmvt_item = itab_item
return = it_return.
COMMIT WORK.
WAIT UP TO 5 SECONDS.
Aove all is only for the reference.
George shi
‎2008 Mar 27 7:08 AM
Check the field name i think it should be itab-stge_loc not
itab-stge-loc
‎2008 Mar 28 3:03 AM
I see that you have two storage location one should be souce and the other should be destination. You have declared both fields similar.
Just Change STGE_LOC (second one from your internal table) to MOVE_STLOC. As this one should be a destination location which is MOVE_STLOC. I am sure it will solve the problem.
Thanks,
siddu