‎2007 Jul 17 11:04 AM
Hi,
I am testing BAPI Function module BAPI_GOODSMVT_CREATE in 4.7 Version.
I am getting an error like this.
-
LOBM_VFDAT: Value "00.00.0000" not found
-
When I am testing the same BAPI Function module in ECC 6.0, Its Working Fine.
Can anyone spot the Error.
Vijayanand.
‎2007 Jul 17 11:07 AM
Hi!
Please check your user's date format settings to be the same in both systems. You can change it in 4.7 if it leads to the problem.
System menu - User defaults - Own data
Regards
Tamá
‎2007 Jul 17 11:09 AM
Dear all
Bapi BAPI_GOODSMVT_CREATE could be used to post goods receipt against inbound delivery but in consequence no Delivery document flow is updated. This is official SAP explaination.
But there is solution to accomplish it. After posting goods movements you should update Inbound Delivery using fm SD_DELIVERY_UPDATE.
Check following coding:
&----
form process_0112.
clear post_status.
post_status-delivery = wa_likp-vbeln.
posting
perform post_goodsreceipt changing post_status.
perform post_delivery_hist changing post_status.
perform post_transferorder changing post_status.
reversal posting if necessary
perform reverse_goodsreceipt changing post_status.
perform reverse_delivery_hist changing post_status.
display message in case of error
perform issue_message changing post_status.
leave transaction
leave to transaction sy-tcode.
endform. " process_0112
&----
form post_goodsreceipt changing post_status structure post_status.
*----
DATA DECLARATION
*----
material document header
data: begin of it_head.
include structure bapi2017_gm_head_01.
data: end of it_head.
T158G special code
data: begin of it_code.
include structure bapi2017_gm_code.
data: end of it_code.
material document returned data
data: begin of it_rthead.
include structure bapi2017_gm_head_ret.
data: end of it_rthead.
material document items
data: begin of it_pos occurs 100.
include structure bapi2017_gm_item_create.
data: end of it_pos.
error table
data: begin of it_errmsg occurs 10.
include structure bapiret2.
data: end of it_errmsg.
return data
data: post_mat_doc type bapi2017_gm_head_ret-mat_doc,
post_doc_year type bapi2017_gm_head_ret-doc_year.
*----
FILL DATA
*----
material document header
it_head-pstng_date = sy-datum.
it_head-doc_date = sy-datum.
it_head-header_txt = 'RF'.
it_head-pr_uname = sy-uname.
T158G code
it_code-gm_code = '01'.
material document items
loop at it_lips into wa_lips where posnr <> space.
it_pos-mvt_ind = 'B'.
it_pos-deliv_numb_to_search = wa_lips-vbeln.
it_pos-deliv_item_to_search = wa_lips-posnr.
it_pos-po_number = wa_lips-vgbel.
it_pos-po_item = wa_lips-vgpos.
it_pos-move_type = '985'.
it_pos-entry_qnt = wa_lips-rv_lfimg.
append it_pos.
endloop.
*----
CALL BAPI
*----
refresh: it_errmsg.
call function 'BAPI_GOODSMVT_CREATE'
exporting
goodsmvt_header = it_head
goodsmvt_code = it_code
importing
materialdocument = post_mat_doc
matdocumentyear = post_doc_year
tables
goodsmvt_item = it_pos
return = it_errmsg.
check result
if post_mat_doc is initial.
post_status-post_mat_doc = space.
post_status-post_doc_year = space.
rollback work.
else.
post_status-post_mat_doc = post_mat_doc.
post_status-post_doc_year = post_doc_year.
commit work and wait.
endif.
endform. " post_goodsreceipt
&----
form post_delivery_hist changing post_status structure post_status.
*----
DATA DECLARATION
*----
data: it_vbfa like vbfa occurs 0,
wa_vbfa like vbfa.
*----
CHECK IF UPDATE DELIVERY IS ESSENTIAL
*----
check not post_status-post_mat_doc is initial
and not post_status-post_doc_year is initial.
*----
POPULATE TABLE
*----
loop at it_lips into wa_lips where posnr <> space.
clear wa_vbfa.
wa_vbfa-vbelv = wa_lips-vbeln.
wa_vbfa-posnv = wa_lips-posnr.
wa_vbfa-vbeln = post_status-post_mat_doc.
wa_vbfa-vbtyp_n = 'R'.
wa_vbfa-vbtyp_v = '7'.
wa_vbfa-plmin = '+'.
select single zeile waers menge dmbtr meins matnr bwart
from mseg
into (wa_vbfa-posnn, wa_vbfa-waers,
wa_vbfa-rfmng, wa_vbfa-rfwrt,
wa_vbfa-meins, wa_vbfa-matnr,
wa_vbfa-bwart)
where mblnr = post_status-post_mat_doc
and mjahr = post_status-post_doc_year
and ebeln = wa_lips-vgbel
and ebelp = wa_lips-vgpos.
append wa_vbfa to it_vbfa.
endloop.
*----
UPDATE DELIVERY
*----
data: begin of yvbfa occurs 0.
include structure vbfavb.
data: end of yvbfa.
data: begin of xvbfa occurs 0.
include structure vbfavb.
data: end of xvbfa.
data: begin of xvttk occurs 0.
include structure vttkvb.
data: end of xvttk.
sort it_vbfa by mandt vbelv posnv vbeln posnn vbtyp_n.
loop at it_vbfa into xvbfa.
xvbfa-rfmng_flt = xvbfa-rfmng.
xvbfa-updkz = 'I'.
append xvbfa.
at end of vbelv.
call function 'SD_DELIVERY_UPDATE'
exporting
i_vbtyp = '7'
nicht_sperren = 'Y'
no_imseg_refresh = 'X'
tables
zxvbfa = xvbfa
zyvbfa = yvbfa
zxvttk = xvttk
exceptions
others = 1.
if sy-subrc <> 0.
exit.
endif.
refresh xvbfa.
endat.
endloop.
check result
if sy-subrc <> 0.
post_status-post_deli_hist = 'R'.
rollback work.
else.
post_status-post_deli_hist = 'C'.
commit work and wait.
endif.
endform. " post_delivery_hist
<b>rewards point if useful.....</b>
regards..
Abhay.
‎2007 Jul 17 11:11 AM
Hi,
After posting goods movements you should update Inbound Delivery using fm SD_DELIVERY_UPDATE.
Check following coding:
&----
form process_0112.
clear post_status.
post_status-delivery = wa_likp-vbeln.
posting
perform post_goodsreceipt changing post_status.
perform post_delivery_hist changing post_status.
perform post_transferorder changing post_status.
reversal posting if necessary
perform reverse_goodsreceipt changing post_status.
perform reverse_delivery_hist changing post_status.
display message in case of error
perform issue_message changing post_status.
leave transaction
leave to transaction sy-tcode.
endform. " process_0112
&----
form post_goodsreceipt changing post_status structure post_status.
*----
DATA DECLARATION
*----
material document header
data: begin of it_head.
include structure bapi2017_gm_head_01.
data: end of it_head.
T158G special code
data: begin of it_code.
include structure bapi2017_gm_code.
data: end of it_code.
material document returned data
data: begin of it_rthead.
include structure bapi2017_gm_head_ret.
data: end of it_rthead.
material document items
data: begin of it_pos occurs 100.
include structure bapi2017_gm_item_create.
data: end of it_pos.
error table
data: begin of it_errmsg occurs 10.
include structure bapiret2.
data: end of it_errmsg.
return data
data: post_mat_doc type bapi2017_gm_head_ret-mat_doc,
post_doc_year type bapi2017_gm_head_ret-doc_year.
*----
FILL DATA
*----
material document header
it_head-pstng_date = sy-datum.
it_head-doc_date = sy-datum.
it_head-header_txt = 'RF'.
it_head-pr_uname = sy-uname.
T158G code
it_code-gm_code = '01'.
material document items
loop at it_lips into wa_lips where posnr <> space.
it_pos-mvt_ind = 'B'.
it_pos-deliv_numb_to_search = wa_lips-vbeln.
it_pos-deliv_item_to_search = wa_lips-posnr.
it_pos-po_number = wa_lips-vgbel.
it_pos-po_item = wa_lips-vgpos.
it_pos-move_type = '985'.
it_pos-entry_qnt = wa_lips-rv_lfimg.
append it_pos.
endloop.
*----
CALL BAPI
*----
refresh: it_errmsg.
call function 'BAPI_GOODSMVT_CREATE'
exporting
goodsmvt_header = it_head
goodsmvt_code = it_code
importing
materialdocument = post_mat_doc
matdocumentyear = post_doc_year
tables
goodsmvt_item = it_pos
return = it_errmsg.
check result
if post_mat_doc is initial.
post_status-post_mat_doc = space.
post_status-post_doc_year = space.
rollback work.
else.
post_status-post_mat_doc = post_mat_doc.
post_status-post_doc_year = post_doc_year.
commit work and wait.
endif.
endform. " post_goodsreceipt
&----
form post_delivery_hist changing post_status structure post_status.
*----
DATA DECLARATION
*----
data: it_vbfa like vbfa occurs 0,
wa_vbfa like vbfa.
*----
CHECK IF UPDATE DELIVERY IS ESSENTIAL
*----
check not post_status-post_mat_doc is initial
and not post_status-post_doc_year is initial.
*----
POPULATE TABLE
*----
loop at it_lips into wa_lips where posnr <> space.
clear wa_vbfa.
wa_vbfa-vbelv = wa_lips-vbeln.
wa_vbfa-posnv = wa_lips-posnr.
wa_vbfa-vbeln = post_status-post_mat_doc.
wa_vbfa-vbtyp_n = 'R'.
wa_vbfa-vbtyp_v = '7'.
wa_vbfa-plmin = '+'.
select single zeile waers menge dmbtr meins matnr bwart
from mseg
into (wa_vbfa-posnn, wa_vbfa-waers,
wa_vbfa-rfmng, wa_vbfa-rfwrt,
wa_vbfa-meins, wa_vbfa-matnr,
wa_vbfa-bwart)
where mblnr = post_status-post_mat_doc
and mjahr = post_status-post_doc_year
and ebeln = wa_lips-vgbel
and ebelp = wa_lips-vgpos.
append wa_vbfa to it_vbfa.
endloop.
*----
UPDATE DELIVERY
*----
data: begin of yvbfa occurs 0.
include structure vbfavb.
data: end of yvbfa.
data: begin of xvbfa occurs 0.
include structure vbfavb.
data: end of xvbfa.
data: begin of xvttk occurs 0.
include structure vttkvb.
data: end of xvttk.
sort it_vbfa by mandt vbelv posnv vbeln posnn vbtyp_n.
loop at it_vbfa into xvbfa.
xvbfa-rfmng_flt = xvbfa-rfmng.
xvbfa-updkz = 'I'.
append xvbfa.
at end of vbelv.
call function 'SD_DELIVERY_UPDATE'
exporting
i_vbtyp = '7'
nicht_sperren = 'Y'
no_imseg_refresh = 'X'
tables
zxvbfa = xvbfa
zyvbfa = yvbfa
zxvttk = xvttk
exceptions
others = 1.
if sy-subrc <> 0.
exit.
endif.
refresh xvbfa.
endat.
endloop.
check result
if sy-subrc <> 0.
post_status-post_deli_hist = 'R'.
rollback work.
else.
post_status-post_deli_hist = 'C'.
commit work and wait.
endif.
endform. " post_delivery_hist
check this link.... u will get all help from this code..
http://sap4.com/wiki/index.php?title=BAPI_GOODSMVT_CREATE&printable=yes
<b>Reward points</b>
Regards