12-10-2007 8:05 PM
hello all,
I have a requirement where I need to use the BAPI "BAPI_GOODSMVT_CREATE" to post stock from unrestricted to QI (using batch movement 349). All I have is a material number and a batch number. Can you please help me in using this BAPI?
Thanks verymuch in advance...
-Venky
12-10-2007 8:07 PM
12-10-2007 9:57 PM
yes Rob..I was able to write the code but Iam getting the error
'Error in function Goods movement not possible with mvmt type 349'
here is my sample code
**************************************
tables: mchb, mard.
parameters: p_matnr like mchb-matnr,
p_werks like mchb-werks,
p_charg like mchb-charg,
p_lgort like mard-lgort.
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.
data: v_labst like mard-labst.
start-of-selection.
itab-material = p_matnr.
itab-plant = p_werks.
itab-batch = p_charg.
itab-stge_loc = p_lgort.
select single labst from mard
into v_labst
where matnr = p_matnr
and werks = p_werks
and lgort = p_lgort.
gmhead-pstng_date = sy-datum.
gmhead-doc_date = sy-datum.
gmhead-pr_uname = sy-uname.
gmcode-gm_code = '02'.
*loop at itab.
itab-move_type = '349'.
itab-mvt_ind = 'F'.
itab-entry_qnt = v_labst.
append itab.
*endloop.
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 in function', errmsg-message.
errflag = 'X'.
else.
write:/ errmsg-message.
endif.
endloop.
if errflag is initial.
commit work and wait.
if sy-subrc ne 0.
write:/ 'Error in updating'.
exit.
else.
write:/ mthead-mat_doc, mthead-doc_year.
perform upd_sta.
endif.
endif.
12-10-2007 10:02 PM
12-10-2007 10:08 PM
"Goods movement not possible with mvmt type 349"
This is the error mssg I found in the "return" table (errmsg-message) of the BAPI.
12-10-2007 10:11 PM
There will be a message id and number with the error. Can you see what these are?
Rob
12-10-2007 10:06 PM
If you were to do this online, which transaction (other than MIGO), would you use? Depending on that you will have to decide the GM_CODE. Not all goods movements are possible using this BAPI. Also some movement types are configured as automatic postings and you cannot use BAPI for such movements.
12-10-2007 10:13 PM
Also, 349 is not "unrestricted to QI", it is "blocked to QI". Check with your functional person to get the correct movement type or the requirement.
12-10-2007 10:14 PM
hi Venky,
this rather sounds like an application error. Are you sure that movement type 389 (or whatever this was...) can be used in your system?
Did you debug where this error is raised? This might help you to limit the root cause of your issue.
Regards
Wolfgang
12-11-2007 6:49 PM
I just found out that the movement type is actually 322 and not 349. The transaction they use id ZMIGO (copied from MIGO).
Can anyone please suggest me what would be the next step? Can I still use the same BAPI? or do u suggest me to go for a BDC?
Please let me know.
Thanks,
-Venky
12-11-2007 6:56 PM
12-11-2007 6:57 PM