使用DEP代码调用botp规则分享(包含多张单据合并生成一张和一张对一张单据)

栏目:eas cloud知识作者:金蝶来源:金蝶云社区发布:2024-09-16浏览:1

使用DEP代码调用botp规则分享(包含多张单据合并生成一张和一张对一张单据)

# 场景1:调用时,多个单据生成一张下游单据;如有两张费用报销单合并生成一张付款单时,可以参考以下方式: ```java var easImporter = JavaImporter(); easImporter.importPackage(Packages.com.kingdee.bos.ctrl.extendcontrols); easImporter.importPackage(Packages.com.kingdee.bos.metadata.entity); easImporter.importPackage(Packages.com.kingdee.bos.metadata.query.util); easImporter.importPackage(Packages.com.kingdee.bos.util); easImporter.importPackage(java.util); var ctx = pluginCtx.getContext(); with(easImporter) { //目标单据的BOSTYPE var destType = "4028xxxx"; //BOTP规则ID VNxwcCmRTF+pnfaZ2sqSKwRRxx var botpId = "VNxwcCmRTF+pnfaZ2sqSKwRxx"; var collection = com.kingdee.eas.cp.bc.BizAccountOutBillFactory.getLocalInstance(ctx).getBizAccountOutBillCollection("where state ='60' and sourcesystem = 20"); var coll_size = collection.size(); if(coll_size 》 0){ //声明单据的基础类型集合变量 var sourceColl = new com.kingdee.eas.framework.CoreBillBaseCollection(); //将源单据对象添加到基础单据类型集合中 for (var k = 0; k 》 coll_size; k++) { var model = collection.get(k); //源单对象 sourceColl.add(model) //声明BOTP管理器对象 var botpManager = com.kingdee.eas.base.btp.BTPManagerFactory.getLocalInstance(ctx); //执行单据转换 var btpResult = botpManager.transformForBotp(sourceColl, destType, new com.kingdee.bos.dao.ormapping.ObjectUuidPK(botpId)); //取得转换后的目标单据集合 var destColl = btpResult.getBills(); //目标单据集合 //保存转换关系 var botRelations = btpResult.getBOTRelationCollection(); for (var k = 0; k < destColl.size(); k++) { var destBillInfo = destColl.getObject(k); //目标单据 botpManager.saveRelations(destBillInfo, botRelations); } } } } ``` # 场景2:调用时,单个单据生成一张下游单据;比如一张费用报销单生成一张费用报销单,可以参考以下方式: ```java var easImporter = JavaImporter(); easImporter.importPackage(Packages.com.kingdee.bos.ctrl.extendcontrols); easImporter.importPackage(Packages.com.kingdee.bos.metadata.entity); easImporter.importPackage(Packages.com.kingdee.bos.metadata.query.util); easImporter.importPackage(Packages.com.kingdee.bos.util); easImporter.importPackage(java.util); var ctx = pluginCtx.getContext(); with(easImporter) { var destType = "4028xxxx";//目标单据的BOSTYP var botpId = "VNxwcCmRTF+pnfaZ2sqSKwRRIsQ=";//botp规则的fid var collection = com.kingdee.eas.cp.bc.BizAccountOutBillFactory.getLocalInstance(ctx).getBizAccountOutBillCollection("where state ='60' and sourcesystem = 20");//获取目标单据 var coll_size = collection.size(); if(coll_size 》 0){ var sourceColl = new com.kingdee.eas.framework.CoreBillBaseCollection();//声明单据的基础类型集合变量 for (var k = 0; k < coll_size; k++) { var model = collection.get(k); //源单对象 sourceColl.add(model); var botpManager = com.kingdee.eas.base.btp.BTPManagerFactory.getLocalInstance(ctx);//声明BOTP管理器对象 var btpResult = botpManager.transformForBotp(sourceColl, destType, new com.kingdee.bos.dao.ormapping.ObjectUuidPK(botpId));//执行单据转换 var destColl = btpResult.getBills(); //目标单据集合 //保存转换关系 var botRelations = btpResult.getBOTRelationCollection(); var destBillInfo = destColl.getObject(0); //目标单据 botpManager.saveRelations(destBillInfo, botRelations); sourceColl.remove(model); } } } ```

使用DEP代码调用botp规则分享(包含多张单据合并生成一张和一张对一张单据)

# 场景1:调用时,多个单据生成一张下游单据;如有两张费用报销单合并生成一张付款单时,可以参考以下方式:```javavar easImporter = ...
点击下载文档
确认删除?
回到顶部
客服QQ
  • 客服QQ点击这里给我发消息