LedgerJournalEngine 和 LedgerJournalCheckPost

发布于 2024-11-26 11:54:32 字数 288 浏览 1 评论 0原文

我正在使用 C# 创建和发布 Dynamics AX Ledger 日记帐。

我想使用 AX 附带的两个帮助器类(

LedgerJournalEngine 和 LedgerJournalCheckPost)来验证我创建的日记帐。

我的问题是:

1.) 如何获得错误列表 ->这些课程或其他课程的优惠券?

2.) 您可以在 AX 交易中模拟 post 并将其回滚吗?

2-a.) 如果您回滚交易中的过账,AX 是否足够聪明,可以重复使用已回滚的凭证编号?

I am creating and posting Dynamics AX Ledger Journals from C#.

I want to use the two helper classes the come with AX,

LedgerJournalEngine and LedgerJournalCheckPost, to validate the journals I create.

My questions are:

1.) How do you get a list of errors -> voucher from either of these classes or some other class?

2.) Can you simulate a post inside of a AX transaction and roll it back?

2-a.) If you roll back a posting in a transaction will AX be smart enough to reuse the voucher numbers that got rolled back?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

柠北森屋 2024-12-03 11:54:32

您考虑过使用 AIF 吗?

如果您坚持直接调用 AX,最简单的方法是:

创建静态 X++ 方法并调用这些方法:

  1. 用于创建日记帐,
  2. 用于创建日记帐行,将字段作为
  3. 发布日记帐的参数,返回 infolog (作为字符串) )

让 AX 方法与分类帐过帐类进行管道连接。

过帐要么全有,要么全无(可能会将错误行转移到新日记帐)。
如果出现错误,优惠券号码将被重复使用。我猜想,这意味着凭证编号是在过帐时分配的,可以在日记帐名称上设置。

infolog 返回值可以转换为字符串以简化 C# 方面。

转换为字符串的X++代码:

client server static str infoCon2List(container c)
{
    TextBuffer t = new TextBuffer();
    str info;
    int i;
    int n;
    for (i = 1; i <= conlen(c); i += 2)
    {
        info = conpeek(c,i+1);
        n = strFind(info,'\t',strLen(info),-99999);
        t.appendText(strFmt('%1\t%2\t%3\n', conpeek(c,i), n > 1 ? strReplace(subStr(info,2,n-2), '\t', '\\') : '', substr(info,n+1,9999)));
    }
    return t.getText();
}

调用方式:

int e = infolog.num();
try
{
    doThePosting(...);
}
catch //anything
{
    exceptionTextFallThrough();
}
return Info::infoCon2List(infolog.copy(e+1,infolog.num()));

Have you considered using AIF?

The easy way if you insist on calling AX directly:

Create static X++ methods and call these:

  1. for creating a journal
  2. for creating a journal line, fields as parameters
  3. for posting a journal, return infolog (as a string)

Let the AX methods do the plumbing with the ledger posting classes.

The posting is all or nothing (with possible transfer of error lines to a new journal).
Voucher numbers are reused in case of error. This implies, I guess, that voucher numbers are allocated on posting, which can be set up on the journal name.

The infolog return value could be converted to a string to simplify the C# side.

X++ code to convert to string:

client server static str infoCon2List(container c)
{
    TextBuffer t = new TextBuffer();
    str info;
    int i;
    int n;
    for (i = 1; i <= conlen(c); i += 2)
    {
        info = conpeek(c,i+1);
        n = strFind(info,'\t',strLen(info),-99999);
        t.appendText(strFmt('%1\t%2\t%3\n', conpeek(c,i), n > 1 ? strReplace(subStr(info,2,n-2), '\t', '\\') : '', substr(info,n+1,9999)));
    }
    return t.getText();
}

The way to call it:

int e = infolog.num();
try
{
    doThePosting(...);
}
catch //anything
{
    exceptionTextFallThrough();
}
return Info::infoCon2List(infolog.copy(e+1,infolog.num()));
开始看清了 2024-12-03 11:54:32

我最终得到:

public static ERSImport_Errors PostJournal(int64 _journalRecID)
{
    LedgerJournalTable          ledgerJournaltable;
    LedgerJournalCheckPost      ledgerJournalCheckPost;
    LedgerJournalID             errorJournalID;
    LedgerJournalEngine         lje;
    ERSImport_Errors             errors;

    boolean                     ret = true;//True we posted this journalRecID
    LedgerJournalTrans          ledgerJournalTrans;
    ;

    errors = new ERSImport_Errors();
    select crosscompany ledgerjournaltable where ledgerjournaltable.RecId == _journalRecID;

    if(ledgerJournalTable == null)
        throw error("Could not find ledger journal table provided");

    changecompany(ledgerJournalTable.dataAreaId)
    {
        ledgerJournalCheckPost = LedgerJournalCheckPost::newLedgerJournalTable(ledgerJournalTable,NoYes::Yes,NoYes::No);
        lje = LedgerJournalEngine::construct(ledgerJournalTable.JournalType);
        lje.newJournalActive(ledgerJournalTable,true);
        ledgerJournalCheckPost.parmLedgerJournalEngine(lje);
        try
        {
            ledgerJournalCheckPost.run();
        }
        catch
        {
            while select ledgerJournalTrans where ledgerJournalTrans.JournalNum == ledgerJournalTable.JournalNum
            {
                if(lje.errorExists(ledgerJournalTrans.Voucher))
                {
                    errors.addError(lje.errorLog(ledgerJournalTrans.Voucher),ledgerJournalTrans.RecId);
                }
            }
        }
    }
    return errors;
}

I ended up with:

public static ERSImport_Errors PostJournal(int64 _journalRecID)
{
    LedgerJournalTable          ledgerJournaltable;
    LedgerJournalCheckPost      ledgerJournalCheckPost;
    LedgerJournalID             errorJournalID;
    LedgerJournalEngine         lje;
    ERSImport_Errors             errors;

    boolean                     ret = true;//True we posted this journalRecID
    LedgerJournalTrans          ledgerJournalTrans;
    ;

    errors = new ERSImport_Errors();
    select crosscompany ledgerjournaltable where ledgerjournaltable.RecId == _journalRecID;

    if(ledgerJournalTable == null)
        throw error("Could not find ledger journal table provided");

    changecompany(ledgerJournalTable.dataAreaId)
    {
        ledgerJournalCheckPost = LedgerJournalCheckPost::newLedgerJournalTable(ledgerJournalTable,NoYes::Yes,NoYes::No);
        lje = LedgerJournalEngine::construct(ledgerJournalTable.JournalType);
        lje.newJournalActive(ledgerJournalTable,true);
        ledgerJournalCheckPost.parmLedgerJournalEngine(lje);
        try
        {
            ledgerJournalCheckPost.run();
        }
        catch
        {
            while select ledgerJournalTrans where ledgerJournalTrans.JournalNum == ledgerJournalTable.JournalNum
            {
                if(lje.errorExists(ledgerJournalTrans.Voucher))
                {
                    errors.addError(lje.errorLog(ledgerJournalTrans.Voucher),ledgerJournalTrans.RecId);
                }
            }
        }
    }
    return errors;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文