在上WM后,存在SAP里没有上批次,有报表需求所有的物料凭证都需要一个批次号来跟踪采购订单的入库情况。
在从WM库存转移到其它库存时,使用MB1B 311来做工厂的库位移动。
可是SAP标准配置是没有上批次的物料填入批次信息后会警告,同时将批次字段信息删除掉。
解决办法是用ENCHANCE POINT 。
先查到错误肖M7 027所在程序。
MM07MFF0_FUSSZEILE_WA_PRUEFEN。
if mbefu-xchar is initial and not mseg-charg is initial.
perform. naco_ermitteln_v4(sapfm07m) using 'M7' '047'
mseg-matnr mseg-werks space space.
clear: mseg-charg, bild-charg.
endif.
perform. naco_ermitteln_v4(sapfm07m) using 'M7' '047'
mseg-matnr mseg-werks space space.
clear: mseg-charg, bild-charg.
endif.
可以看到弹出这个消息后把批次字段信息给删除了。
在这段代码之前有一个enhancement 120 ad_subcon_mm_sapmm07m. "active version 的增强点。
在这个增强点实现我们的需求。
SPAN {
font-family: "Courier New";
font-size: 10pt;
color: #000000;
background: #FFFFFF;
}
.L0S31 {
font-style. italic;
color: #808080;
}
.L0S32 {
color: #3399FF;
}
.L0S33 {
color: #4DA619;
}
.L0S52 {
color: #0000FF;
}
enhancement 372 zmb1b. "active version
*IF SY-TCODE EQ 'MB1B' AND ( mseg-BWART = '311' OR mseg-BWART = '312' ) AND MSEG-LGORT CA 'R'.
if sy-tcode eq 'MB1B' and ( mseg-bwart = '311' or mseg-bwart = '312' )
and ( mseg-lgort ca 'R' or mseg-umlgo ca 'R' ) and mbefu-xchar is initial.
*检查数量和批次是否在表ZTZ_WMTT_LOT中。
data: l_erfmg like mseg-erfmg.
data: l_serfmg(13) type c.
data: l_zshsl like ztz_wmtt_lot-zshsl."交货
data: l_zthsl like ztz_wmtt_lot-zthsl."退货
data: l_zrksl like ztz_wmtt_lot-zrksl."入库
data: l_msg(100) type c.
if mseg-lgort ca 'R'.
clear l_erfmg.
select single zshsl zthsl zrksl into (l_zshsl , l_zthsl , l_zrksl)
from ztz_wmtt_lot
where matnr = mseg-matnr and charg = bild-charg.
l_erfmg = l_zshsl - l_zthsl - l_zrksl.
move l_erfmg to l_serfmg.
if mseg-erfmg > l_erfmg.
concatenate '物料:' mseg-matnr+9(9) '批次:' bild-charg '只有' l_serfmg '可以做311' into l_msg.
message l_msg type 'E'.
exit.
endif.
endif.
if mseg-umlgo ca 'R'.
clear l_erfmg.
select single zshsl zthsl zrksl into (l_zshsl , l_zthsl , l_zrksl)
from ztz_wmtt_lot
where matnr = mseg-matnr and charg = bild-charg.
if sy-subrc ne 0.
concatenate '物料:' mseg-matnr+9(9) '批次:' bild-charg '不存在!' into l_msg.
message l_msg type 'E'.
exit.
endif.
endif.
if bild-charg is not initial or strlen( bild-charg ) > 0.
mseg-sgtxt = bild-charg.
mbefu-xchar = 'X'.
else.
message '批次不能为空' type 'E'.
endif.
else.
if sy-tcode eq 'MB1B' and ( mseg-bwart = '311' or mseg-bwart = '312' ).
mseg-sgtxt = bild-sgtxt.
endif.
endif.
endenhancement.
enhancement 372 zmb1b. "active version
*IF SY-TCODE EQ 'MB1B' AND ( mseg-BWART = '311' OR mseg-BWART = '312' ) AND MSEG-LGORT CA 'R'.
if sy-tcode eq 'MB1B' and ( mseg-bwart = '311' or mseg-bwart = '312' )
and ( mseg-lgort ca 'R' or mseg-umlgo ca 'R' ) and mbefu-xchar is initial.
*检查数量和批次是否在表ZTZ_WMTT_LOT中。
data: l_erfmg like mseg-erfmg.
data: l_serfmg(13) type c.
data: l_zshsl like ztz_wmtt_lot-zshsl."交货
data: l_zthsl like ztz_wmtt_lot-zthsl."退货
data: l_zrksl like ztz_wmtt_lot-zrksl."入库
data: l_msg(100) type c.
if mseg-lgort ca 'R'.
clear l_erfmg.
select single zshsl zthsl zrksl into (l_zshsl , l_zthsl , l_zrksl)
from ztz_wmtt_lot
where matnr = mseg-matnr and charg = bild-charg.
l_erfmg = l_zshsl - l_zthsl - l_zrksl.
move l_erfmg to l_serfmg.
if mseg-erfmg > l_erfmg.
concatenate '物料:' mseg-matnr+9(9) '批次:' bild-charg '只有' l_serfmg '可以做311' into l_msg.
message l_msg type 'E'.
exit.
endif.
endif.
if mseg-umlgo ca 'R'.
clear l_erfmg.
select single zshsl zthsl zrksl into (l_zshsl , l_zthsl , l_zrksl)
from ztz_wmtt_lot
where matnr = mseg-matnr and charg = bild-charg.
if sy-subrc ne 0.
concatenate '物料:' mseg-matnr+9(9) '批次:' bild-charg '不存在!' into l_msg.
message l_msg type 'E'.
exit.
endif.
endif.
if bild-charg is not initial or strlen( bild-charg ) > 0.
mseg-sgtxt = bild-charg.
mbefu-xchar = 'X'.
else.
message '批次不能为空' type 'E'.
endif.
else.
if sy-tcode eq 'MB1B' and ( mseg-bwart = '311' or mseg-bwart = '312' ).
mseg-sgtxt = bild-sgtxt.
endif.
endif.
endenhancement.
后面结果是文本中存了我们输入的批次字段中的信息。