简体   繁体   English

有没有办法改善这种动态轴更新工作

[英]Is there a way to improve this dynamics ax update job

I'm working on an AX 2009 installation. 我正在开发AX 2009安装。 The job is to update the WMSOrderTrans table. 工作是更新WMSOrderTrans表。 Here is what I have got so far: 这是我到目前为止所得到的:

WMSOrderTrans   wmsOrderTrans;
;

while select wmsOrderTrans
{
    if (wmsOrderTrans.BBBpackingSlipExists())
    {
        ttsBegin;
        wmsOrderTrans.selectForUpdate(true);
        wmsOrderTrans.BBBPackingSlipExists  =   NoYes::Yes;
        wmsOrderTrans.doUpdate();
        ttsCommit;
    }
}

The job takes about an hour to finish on the test system. 这项工作大约需要一个小时才能完成测试系统。 This makes me worry about the performance on the production system. 这让我担心生产系统的性能

At the moment the code has been written like this to have minimal locking issues (selectForUpdate is done for each row if it should be updated and is then immediatly committed). 目前,代码已经被编写为具有最小的锁定问题(如果应该更新并且然后立即提交,则为每一行执行selectForUpdate)。 The reason is, that users will be working on the system, when the job is running. 原因是,当作业运行时,用户将在系统上工作。

My question is, if there is a reasonable way to implement this job in a way with less transaction overhead. 我的问题是, 如果有一种合理的方式以较少的交易开销实现这项工作。

while select forUpdate ...

... does not seem to be an option, because it would lock the table until the job is finished. ...似乎不是一个选项,因为它会锁定表,直到作业完成。

Any input is appreciated. 任何输入都表示赞赏。


This is the code for the BBBPackingSlipExists method: 这是BBBPackingSlipExists方法的代码:

display boolean BBBpackingSlipExists()
    {
    InventDim               inventDimCur;
    InventDim               inventDimPackSlip;
    InventTrans             inventTransPackSlip;

    ;

    select firstonly RecId from inventTransPackSlip
        where inventTransPackSlip.InventTransId == this.inventTransId
            && (inventTransPackSlip.StatusIssue == StatusIssue::Deducted
                || inventTransPackSlip.StatusIssue == StatusIssue::Sold)
            && !inventTransPackSlip.PackingSlipReturned
        exists join inventDimCur
            where inventDimCur.inventDimId == this.inventDimId
        exists join inventDimPackSlip
            where inventDimPackSlip.inventDimId == inventTransPackSlip.inventDimId
                && inventDimCur.inventSerialId  == inventDimPackSlip.inventSerialId
    ;
if (inventTransPackSlip.RecId != 0 && this.isReserved)
{
    return true;
}
return false;

} }

This looks like a prime candidate to convert to set based logic , I'd go for something like this. 这看起来像是转换为基于集合逻辑的主要候选者,我会选择这样的东西。 Please note that the job isn't tested at all since I don't have a 2009 environment handy (this doesn't even compile on 2012) so if you need to change the code feel free to edit it into my answer. 请注意,作业没有经过测试,因为我没有2009环境(这在2012年甚至没有编译),所以如果你需要更改代码,请随意将其编辑到我的答案中。

Note that the isreserved check is built into the query as well as the exists joins from the packingslipexists method 请注意,isreserved check包含在查询中,以及packingslipexists方法中的exists连接

static void Job250(Args _args)
{
    WMSOrderTrans           wmsOrderTrans;
    InventDim               inventDimCur;
    InventDim               inventDimPackSlip;
    InventTrans             inventTransPackSlip;
    ;
    wmsOrderTrans.skipDatabaseLog(true);
    wmsOrderTrans.skipDataMethods(true);
    wmsOrderTrans.skipEvents(true);
    update_recordset wmsOrderTrans setting BBBPackingSlipExists  = NoYes::Yes
        where wmsOrderTrans.isReserved
        exists join inventTransPackSlip
        where inventTransPackSlip.InventTransId == wmsOrderTrans.inventTransId
          && (inventTransPackSlip.StatusIssue == StatusIssue::Deducted
           || inventTransPackSlip.StatusIssue == StatusIssue::Sold)
          && !inventTransPackSlip.PackingSlipReturned
        exists join inventDimCur
        where inventDimCur.inventDimId == wmsOrderTrans.inventDimId
        exists join inventDimPackSlip
        where inventDimPackSlip.inventDimId == inventTransPackSlip.inventDimId
           && inventDimCur.inventSerialId  == inventDimPackSlip.inventSerialId;       
}

See the documentation on update_recordset and why the skip* methods might be necessary 请参阅update_recordset上的文档以及为什么可能需要skip *方法

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM