本文介绍了LedgerJournalEngine和LedgerJournalCheckPost的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过C#创建和发布Dynamics AX分类帐日记帐.

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

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

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

LedgerJournalEngine和LedgerJournalCheckPost,以验证我创建的日记帐.

LedgerJournalEngine and LedgerJournalCheckPost, to validate the journals I create.

我的问题是:

1.)您如何从这些类别或某些其他类别中获取错误列表->凭证?

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

2.)您可以模拟AX事务内部的帖子并将其回滚吗?

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

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

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?

推荐答案

我最终得到了:

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;
}

这篇关于LedgerJournalEngine和LedgerJournalCheckPost的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 04:58