我正在从 C# 创建和发布 Dynamics AX Ledger Journals。
我想使用 AX 附带的两个辅助类,
LedgerJournalEngine 和 LedgerJournalCheckPost,用于验证我创建的日志。
我的问题是:
1.)您如何从这些课程或其他课程中获得错误列表 -> 凭证?
2.) 你能在 AX 事务中模拟一个帖子并将其回滚吗?
2-a.) 如果您回滚事务中的过帐,AX 是否会足够聪明地重新使用回滚的凭证号?
我正在从 C# 创建和发布 Dynamics AX Ledger Journals。
我想使用 AX 附带的两个辅助类,
LedgerJournalEngine 和 LedgerJournalCheckPost,用于验证我创建的日志。
我的问题是:
1.)您如何从这些课程或其他课程中获得错误列表 -> 凭证?
2.) 你能在 AX 事务中模拟一个帖子并将其回滚吗?
2-a.) 如果您回滚事务中的过帐,AX 是否会足够聪明地重新使用回滚的凭证号?
我最终得到:
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;
}
您是否考虑过使用 AIF?
如果您坚持直接调用 AX 的简单方法:
创建静态 X++ 方法并调用这些方法:
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()));