MM 物料可用性检查
测试函数:BAPI_MATERIAL_AVAILABILITY
测试实现:1 物料需求日期的可供数量
2 物料可用日期的提单占用量
测试参数:
IMP: PLANT VBBE-WERKS
MATERIAL VBBE-MATNR
UNIT VBBE-MEINS
CHECK_RULE T441R-PRREG(可用性检查规则 后台配置)
STGE_LOC VBBE-LGORT
BATCH VBBE-CHARG
CUSTOMER VBBE-KUNNR
DOC_NUMBER VBBE-VBELN
ITM_NUMBER VBBE-POSNR
WBS_ELEM VBBE-PSPEL
STOCK_IND VBBE-SOBKZ
DEC_FOR_ROUNDING 小数位
DEC_FOR_ROUNDING_X 激活小数位
READ_ATP_LOCK 可用性检查的控制标识(A B C D K固定值)
READ_ATP_LOCK_X 激活控制标识
EXP: ENDLEADTME 补货提前期的截止日期
AV_QTY_PLT 工厂层次的可用数量
DIALOGFLAG 标志 (X = 不可用, N = 无检查)
RETURN BAPI返回值
TABLES: BAPIWMDVS 输入表 其中REQ_DATE字段为物料可与可用期VBBE-MBDAT
BAPIWMDVE 输出表 其中COM_DATE COM_QTY字段为需求日期的可供数量
测试程序:
1 传入P_WERKS P_MATNR P_MEINS P_PRREG P_LGORT值,可以得到需求日期的可供数量值
2 传入以上值,再加上订单和订单上的物料可用期值(输入表中),得到可供日期=物料可用期的可供量值,
在VBBE中取到订单类型为'J'的物料的可能性检查的确认数量VMENG的值汇总,即为物料的承诺量,
判断可供量='9,999,999,999.000'时,则承诺量-该订单的VBBE-VMENG值=提单占用量。
************************************************************
TABLES: VBBE, "销售需求:单独记录
T441R. "用于检查规则的价值表
DATA: G_ENDLEADTME LIKE BAPICM61M-WZTER,
G_AV_QTY_PLT LIKE BAPICM61V-WKBST,
G_DIALOGFLAG LIKE BAPICM61V-DIAFL.
DATA: BEGIN OF TAB_G_INTAB OCCURS 0.
INCLUDE STRUCTURE BAPIWMDVS.
DATA: END OF TAB_G_INTAB.
DATA: BEGIN OF TAB_G_OUTTAB OCCURS 0.
INCLUDE STRUCTURE BAPIWMDVE.
DATA: END OF TAB_G_OUTTAB.
DATA: TAB_G_RETURN TYPE TABLE OF BAPIRETURN WITH HEADER LINE.
PARAMETERS: P_WERKS LIKE VBBE-WERKS,
P_MATNR LIKE VBBE-MATNR,
P_MEINS LIKE VBBE-MEINS,
P_PRREG LIKE T441R-PRREG, "检查可用性检查的规则
P_LGORT LIKE VBBE-LGORT,
P_CHARG LIKE VBBE-CHARG,
P_VBELN LIKE VBBE-VBELN,
P_POSNR LIKE VBBE-POSNR,
P_MBDAT LIKE VBBE-MBDAT, "物料需求日期
P_KUNNR LIKE VBBE-KUNNR, "售达方
P_PSPEL LIKE VBBE-PSPEL, "WBS 要素
P_SOBKZ LIKE VBBE-SOBKZ, "特殊库存
P_ANDEC LIKE BAPICM61M-ANDEC, "要执行取整的小数地点编号
P_VFPST LIKE BAPICM61V-VFPST. "供可用性检查的控制标识(A B C D K)
DATA: P_ANDECX TYPE BAPIUPDATE, "在BAPI结构中更新字段的标记
P_VFPSTX TYPE BAPIUPDATE. "在BAPI结构中更新字段的标记
IF P_ANDEC IS NOT INITIAL.
P_ANDECX = 'X'.
ENDIF.
IF P_VFPST IS NOT INITIAL.
P_VFPSTX = 'X'.
ENDIF.
IF P_MBDAT IS NOT INITIAL.
TAB_G_INTAB-REQ_DATE = P_MBDAT.
APPEND TAB_G_INTAB.
ENDIF.
CALL FUNCTION 'BAPI_MATERIAL_AVAILABILITY'
EXPORTING
PLANT = P_WERKS
MATERIAL = P_MATNR
UNIT = P_MEINS
CHECK_RULE = P_PRREG
STGE_LOC = P_LGORT
* BATCH = P_CHARG
* CUSTOMER = P_KUNNR
* DOC_NUMBER = P_VBELN
* ITM_NUMBER = P_POSNR
* WBS_ELEM = P_PSPEL
* STOCK_IND = P_SOBKZ
* DEC_FOR_ROUNDING = P_ANDEC
* DEC_FOR_ROUNDING_X = P_ANDECX
* READ_ATP_LOCK = P_VFPST
* READ_ATP_LOCK_X = P_VFPSTX
IMPORTING
ENDLEADTME = G_ENDLEADTME
AV_QTY_PLT = G_AV_QTY_PLT
DIALOGFLAG = G_DIALOGFLAG
RETURN = TAB_G_RETURN
TABLES
WMDVSX = TAB_G_INTAB
WMDVEX = TAB_G_OUTTAB.
LOOP AT TAB_G_OUTTAB.
WRITE: / TAB_G_OUTTAB-COM_DATE,
TAB_G_OUTTAB-COM_QTY.
ENDLOOP.
************************************************************
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/22764754/viewspace-1028158/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/22764754/viewspace-1028158/