本文提供了关于直接调拨单保存时遇到“调入物料内码不属于当前调入组织”错误的处理方法。首先,建议检查系统标准功能和自定义单据转换规则,确认是否有扩展或修改导致的问题。若问题依旧,推荐配置转换插件处理跨组织的单据转换。对于无法直接通过BOS配置的公有云或私有云用户,建议使用BOS导出导入方式修改。文章还详细描述了如何修改插件节点和编写Python脚本来解决物料内码和组织不对应的问题,以及如何通过插件脚本调整调入物料的默认仓库赋值。
直接调拨单保存报错提示"调入物料内码不属于当前调入组织,请检查数据来源"的排查处理
一、如果是系统标准功能,检查单据或者单据转换路线是否有做扩展修改
二、自定义单据转换规则,参考如下处理方式
【直接调拨单保存报错提示:调入物料内码不属于当前调入组织,请检查数据来源!】
三、自定义单据转换规则,若1、2的排查处理后下推保存还是报错,配置转换插件处理
公有云或者私有云用户无法登录服务器,本地BOS又没有对应组件可选择配置时,可采用BOS导出导入的方式处理(若非很清楚操作逻辑,谨慎使用)
【操作步骤】
1、SELECT * FROM T_META_CONVERTRULE WHERE FID = ' ' 导出对应单据转换xml文件
2、修改插件节点,加入转换插件
目标单是直接调拨单的插件:Kingdee.K3.SCM.App.Stock.ServicePlugIn.StockTransferDirectService.Convert2TransDirectBDSync
目标单是分布式调出单的插件:Kingdee.K3.SCM.App.Stock.ServicePlugIn.StockTransferOutService.Convert2TransOutBDSync
<Plugs> <PlugIn ElementType="0" ElementStyle="0"> <ClassName>Kingdee.K3.SCM.App.Stock.ServicePlugIn.StockTransferDirectService.Convert2TransDirectBDSync, Kingdee.K3.SCM.App.Stock.ServicePlugIn</ClassName> <OrderId>1</OrderId> </PlugIn> </Plugs>
3、保存修改,重新引入
4、清理系统缓存
四、添加插件后还是出现同样的报错,使用脚本处理
import clr clr.AddReference("System") clr.AddReference("Kingdee.BOS") clr.AddReference("Kingdee.BOS.Core") clr.AddReference("Kingdee.BOS.App") clr.AddReference('Kingdee.BOS.ServiceHelper') clr.AddReference('Kingdee.BOS.DataEntity') clr.AddReference("Kingdee.BOS.App.Core") clr.AddReference('Kingdee.BOS.ServiceHelper') clr.AddReference("Kingdee.BOS.Contracts") from System import * from System import StringComparison from Kingdee.BOS.Core.Metadata.ConvertElement.PlugIn.Args import * from Kingdee.BOS.App.Data import * from System.Collections.Generic import * from Kingdee.BOS.ServiceHelper import * from Kingdee.BOS.Core.Metadata import SelectorItemInfo from Kingdee.BOS.Core.SqlBuilder import QueryBuilderParemeter from Kingdee.BOS.Orm.DataEntity import * from Kingdee.BOS.Contracts import * from Kingdee.BOS.App.Core import * def AfterConvert(e): dataObjs = e.Result.FindByEntityKey("FBillHead") viewService = ViewService() matField = e.TargetBusinessInfo.GetField("FDestMaterialId") for obj in dataObjs: entrys = obj.DataEntity["TransferDirectEntry"] stockOrg = obj.DataEntity["StockOrgId"] for entry in entrys: material = entry["MaterialId"] if material is not None: p = QueryBuilderParemeter() p.FormId = "BD_MATERIAL" p.SelectItems = SelectorItemInfo.CreateItems("FMaterialId") p.FilterClauseWihtKey = '''FUSEORGID = {0} AND FMASTERID IN ({1})'''.format(stockOrg["Id"], material["msterID"]) dyObjs = QueryServiceHelper.GetDynamicObjectCollection(this.Context, p) if dyObjs.Count > 0: if dyObjs[0]["FMaterialId"] != 0: material = viewService.LoadSingle(this.Context, dyObjs[0]["FMaterialId"], matField.RefFormDynamicObjectType) entry["DestMaterialId_Id"] = dyObjs[0]["FMaterialId"] entry["DestMaterialId"] = material
五、物料的内码不属于当前调出组织,请检查数据来源
提示是调出物料内码问题,不同于以上3种,分析下来发现:上游单据明细物料使用组织为A,下推直接调拨单时,调出组织映射变更为B组织。业务上有这样的需求场景,BOS单据转换中单据转换也可以配置实现,但是物料内码由于组织不对应,在保存时校验无法通过,只能通过插件自行处理了,插件Kingdee.K3.SCM.App.Stock.ServicePlugIn.StockTransferDirectService.Convert2TransDirectBDSync也没必要做配置了
Python脚本变通实现调出调入物料内码的赋值调整:
import clr clr.AddReference("System") clr.AddReference("Kingdee.BOS") clr.AddReference("Kingdee.BOS.Core") clr.AddReference("Kingdee.BOS.App") clr.AddReference('Kingdee.BOS.ServiceHelper') clr.AddReference('Kingdee.BOS.DataEntity') clr.AddReference("Kingdee.BOS.App.Core") clr.AddReference('Kingdee.BOS.ServiceHelper') clr.AddReference("Kingdee.BOS.Contracts") from System import * from System import StringComparison from Kingdee.BOS.Core.Metadata.ConvertElement.PlugIn.Args import * from Kingdee.BOS.App.Data import * from System.Collections.Generic import * from Kingdee.BOS.ServiceHelper import * from Kingdee.BOS.Core.Metadata import SelectorItemInfo from Kingdee.BOS.Core.SqlBuilder import QueryBuilderParemeter from Kingdee.BOS.Orm.DataEntity import * from Kingdee.BOS.Contracts import * from Kingdee.BOS.App.Core import * def AfterConvert(e): dataObjs = e.Result.FindByEntityKey("FBillHead") viewService = ViewService() matField = e.TargetBusinessInfo.GetField("FMaterialId") for obj in dataObjs: entrys = obj.DataEntity["TransferDirectEntry"] stockOutOrg = obj.DataEntity["StockOutOrgId"] for entry in entrys: material = entry["MaterialId"] if material is not None: p = QueryBuilderParemeter() p.FormId = "BD_MATERIAL" p.SelectItems = SelectorItemInfo.CreateItems("FMaterialId") p.FilterClauseWihtKey = '''FUSEORGID = {0} AND FMASTERID IN ({1})'''.format(stockOutOrg["Id"], material["msterID"]) dyObjs = QueryServiceHelper.GetDynamicObjectCollection(this.Context, p) if dyObjs.Count > 0: if dyObjs[0]["FMaterialId"] != 0: material = viewService.LoadSingle(this.Context, dyObjs[0]["FMaterialId"], matField.RefFormDynamicObjectType) entry["MaterialId_Id"] = dyObjs[0]["FMaterialId"] entry["MaterialId"] = material
5、下推直接调拨单,调入仓库默认赋值为调入物料的默认仓库
1、字段关系映射:调入仓库 = 调入物料.调入仓库(不生效)
2、表单服务策略,计算定义公式值到指定列:调入仓库 = 调入物料.调入仓库(不生效)
3、使用插件脚本赋值
# 下推直接调拨单,调入仓库赋值为调入物料设置的默认仓库 import clr clr.AddReference("System") clr.AddReference("Kingdee.BOS") clr.AddReference("Kingdee.BOS.Core") clr.AddReference("Kingdee.BOS.App") clr.AddReference('Kingdee.BOS.ServiceHelper') clr.AddReference('Kingdee.BOS.DataEntity') clr.AddReference("Kingdee.BOS.App.Core") clr.AddReference('Kingdee.BOS.ServiceHelper') clr.AddReference("Kingdee.BOS.Contracts") from System import * from System import StringComparison from Kingdee.BOS.Core.Metadata.ConvertElement.PlugIn.Args import * from Kingdee.BOS.App.Data import * from System.Collections.Generic import * from Kingdee.BOS.ServiceHelper import * from Kingdee.BOS.Core.Metadata import SelectorItemInfo from Kingdee.BOS.Core.SqlBuilder import QueryBuilderParemeter from Kingdee.BOS.Orm.DataEntity import * from Kingdee.BOS.Contracts import * from Kingdee.BOS.App.Core import * def AfterConvert(e): dataObjs = e.Result.FindByEntityKey("FBillHead") viewService = ViewService() matField = e.TargetBusinessInfo.GetField("FDestStockId") for obj in dataObjs: entrys = obj.DataEntity["TransferDirectEntry"] stockOrg = obj.DataEntity["StockOrgId"] for entry in entrys: destmaterial = entry["DestMaterialId"] if destmaterial is not None: p = QueryBuilderParemeter() p.FormId = "BD_MATERIAL" p.SelectItems = SelectorItemInfo.CreateItems("FMaterialId") p.SelectItems = SelectorItemInfo.CreateItems("FStockId") p.FilterClauseWihtKey = '''FUSEORGID = {0} AND FMASTERID IN ({1})'''.format(stockOrg["Id"], destmaterial["msterID"]) dyObjs = QueryServiceHelper.GetDynamicObjectCollection(this.Context, p) if dyObjs.Count > 0: if dyObjs[0]["FStockId"] != 0: destStock = viewService.LoadSingle(this.Context, dyObjs[0]["FStockId"], matField.RefFormDynamicObjectType) entry["DestStockId_Id"] = dyObjs[0]["FStockId"] entry["DestStockId"] = destStock
插件配置及代码脚本.rar(1.29KB)
推荐阅读