1

我需要LedgerJournalTrans通过 x++ 代码创建一个 reord。

在调试时我发现该类LedgerJournalEngine_CustPayment用于启动表单

LedgerJournalEngine_CustPayment  = new LedgerJournalEngine_CustPayment(element)

然后

LedgerJournalEngine.initValue(LedgerJournalTrans);

在分配在数据源字段accountNum的方法处执行的方法之后也是如此。 modified()LedgerJournalTrans:AccountNumelement.accountNumModifiedPost();

在尝试通过代码实现相同目标时,我无法启动该类LedgerJournalEngine_CustPayment以及LedgerJournalTransCustPaym系统执行的其他方法。

请帮助..乔伊斯

4

1 回答 1

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");
}
于 2013-09-10T18:43:20.983 回答