我需要在LedgerJournalTrans
到x ++代码中创建一个reord。
调试时我发现类LedgerJournalEngine_CustPayment
用于启动表单
LedgerJournalEngine_CustPayment = new LedgerJournalEngine_CustPayment(element)
以后
LedgerJournalEngine.initValue(LedgerJournalTrans);
在为accountNum
数据源字段modified()
的{{1}}方法执行的方法分配LedgerJournalTrans:AccountNum
后,还element.accountNumModifiedPost();
等。
尝试通过代码实现相同的功能时,我无法启动类LedgerJournalEngine_CustPayment
以及系统LedgerJournalTransCustPaym
形式的其他方法。
请帮忙.. 乔伊斯
答案 0 :(得分:1)
LedgerJournalEngine *类主要由表单用于在事件和数据源操作之前/之后执行工作和执行代码。你要做的是,完成所有必要的ledgerJournalTrans字段可能更有意义,然后做一个.insert()。以下是我编写的一些代码,它们会使用引擎执行您想要的操作:
static void Job81(Args _args)
{
LedgerJournalEngine_CustPayment ledgerJournalEngine;
LedgerJournalTable ledgerJournalTable;
LedgerJournalTrans ledgerJournalTrans;
NumberSeq numberSeq;
Voucher voucher;
;
// This just selects the header you are inserting into
select firstonly ledgerJournalTable where ledgerJournalTable.JournalNum == 'GB 0056226';
if (!ledgerJournalTable)
throw error ("Unable to find journal table record");
ledgerJournalTrans.initValue();
numberSeq = NumberSeq::newGetNumFromCode(ledgerJournalTable.VoucherSeries);
if (numberSeq)
{
ledgerJournalTrans.Voucher = numberSeq.num();
voucher = ledgerJournalTrans.Voucher;
}
ledgerJournalTrans.JournalNum = ledgerJournalTable.JournalNum;
ledgerJournalTrans.TransDate = SystemDateGet();
ledgerJournalTrans.AccountType = LedgerjournalACType::Cust;
ledgerJournalTrans.AccountNum = '100003';
ledgerJournalEngine = LedgerJournalEngine::construct(LedgerJournalType::CustPayment);
ledgerJournalEngine.newJournalActive(ledgerJournalTable);
ledgerJournalEngine.accountModified(ledgerJournalTrans);
ledgerJournalTrans.AmountCurCredit = 10;
ledgerJournalTrans.OffsetAccountType = ledgerJournalTable.OffsetAccountType;
ledgerJournalTrans.OffsetAccount = ledgerJournalTable.OffsetAccount;
ledgerJournalTrans.CurrencyCode = CompanyInfo::standardCurrency();
ledgerJournalEngine.currencyModified(ledgerJournalTrans);
ledgerJournalTrans.insert();
if (numberSeq && ledgerJournalTrans.Voucher == voucher)
{
numberSeq.used();
}
else
{
if (numberSeq)
numberSeq.abort();
}
info("Done");
}