使用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 = ...
点击下载文档
本文2024-09-16 21:56:35发表“eas cloud知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-eas-44916.html
您需要登录后才可以发表评论, 登录登录 或者 注册
最新文档
热门文章