在 X++ 中编程多线程批处理。由于某种原因没有工作?
代码非常简单。从“供应商详细信息”表单中,如果您转到“功能”>“更新 1099”,则用户希望对所有供应商完全开放,而不是手动执行此操作。我修改了基础 VendTax1099Update 类以扩展 RunBaseBatch,然后添加了一堆 parm 方法。我收到此错误,但任务存在吗?我做错了吗?
“无法创建依赖项,因为税务 1099 信息的任务供应商更新不存在。”
我将其设置为“addDependency”,因为当我尝试完全打开它时存在数据库锁。不确定是否有办法解决这些问题。
void run()
{
BatchHeader batchHeader;
VendTax1099Update vendTax1099Update;
VendTax1099Update vendTax1099UpdateOld;
VendTable vendTable;
boolean first = true;
;
/*
if (this.isInBatch())
{
*/
// Make sure there is a batch header
if (!batchHeader)
batchHeader = BatchHeader::construct(this.parmCurrentBatch().BatchJobId);
while select vendTable
where vendTable.Tax1099Reports == true &&
vendTable.Tax1099Box != ''
{
if (Tax1099Fields::exist(vendTable.Tax1099Box))
{
vendTax1099Update = new VendTax1099Update();
vendTax1099Update.parmFromDate(fromDate);
vendTax1099Update.parmToDate(toDate);
vendTax1099Update.parmRecalcAmounts(recalcAmounts);
vendTax1099Update.parmSetAll1099(setAll1099);
vendTax1099Update.parmBoxFor1099(vendTable.Tax1099Box);
vendTax1099Update.parmVendorNum(vendTable.AccountNum);
if (first)
{
batchHeader.addRuntimeTask(vendTax1099Update, this.parmCurrentBatch().RecId);
first = false;
}
else
{
if (vendTax1099UpdateOld)
batchHeader.addDependency(vendTax1099Update, vendTax1099UpdateOld, BatchDependencyStatus::FinishedOrError);
}
vendTax1099UpdateOld = vendTax1099Update;
}
else
error (strfmt("Unable to process %1 because %2 was not found in Tax1099Fields", vendTable.AccountNum, vendTable.Tax1099Box));
}
/*
}
*/
if (batchHeader)
batchHeader.save();
}
Code is pretty straight forward. From the Vendor Details form, if you go Functions>Update 1099, a user wants to do this wide open on all of the vendors instead of manually doing it. I modified the base VendTax1099Update class to extend RunBaseBatch, then added a bunch of parm methods. I'm getting this error, but the task exists? Am I doing it wrong?
"The dependency could not be created because task Vendor update of tax 1099 information does not exist."
I made it "addDependency" because there were DB locks when I tried to run it wide open. Not sure if there is a way to fix those.
void run()
{
BatchHeader batchHeader;
VendTax1099Update vendTax1099Update;
VendTax1099Update vendTax1099UpdateOld;
VendTable vendTable;
boolean first = true;
;
/*
if (this.isInBatch())
{
*/
// Make sure there is a batch header
if (!batchHeader)
batchHeader = BatchHeader::construct(this.parmCurrentBatch().BatchJobId);
while select vendTable
where vendTable.Tax1099Reports == true &&
vendTable.Tax1099Box != ''
{
if (Tax1099Fields::exist(vendTable.Tax1099Box))
{
vendTax1099Update = new VendTax1099Update();
vendTax1099Update.parmFromDate(fromDate);
vendTax1099Update.parmToDate(toDate);
vendTax1099Update.parmRecalcAmounts(recalcAmounts);
vendTax1099Update.parmSetAll1099(setAll1099);
vendTax1099Update.parmBoxFor1099(vendTable.Tax1099Box);
vendTax1099Update.parmVendorNum(vendTable.AccountNum);
if (first)
{
batchHeader.addRuntimeTask(vendTax1099Update, this.parmCurrentBatch().RecId);
first = false;
}
else
{
if (vendTax1099UpdateOld)
batchHeader.addDependency(vendTax1099Update, vendTax1099UpdateOld, BatchDependencyStatus::FinishedOrError);
}
vendTax1099UpdateOld = vendTax1099Update;
}
else
error (strfmt("Unable to process %1 because %2 was not found in Tax1099Fields", vendTable.AccountNum, vendTable.Tax1099Box));
}
/*
}
*/
if (batchHeader)
batchHeader.save();
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我已经为此绞尽脑汁了几个小时,当然,在发布几分钟后,我在意识到我可以进入batchHeader.addDependency()方法后解决了这个问题。
结果你必须添加任务,然后设置依赖关系。我认为设置依赖关系也同时添加了任务。更正后的代码如下:
I've been racking my brain for a couple hours on this and of course minutes after posting I figure the issue out after realizing I can step into the batchHeader.addDependency() method.
Turns out you have to add the task, then set the dependency. I thought setting the dependency was also adding the task in the same swoop. The corrected bit of code is this: