Dando uma navegada, achei o codigo abaixo e é uma alternativa a outros modelos já exibidos aqui.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
public void sampleLedgerTrans()
{
    Voucher                     voucher;
    LedgerVoucher               ledgerVoucher;
    LedgerVoucherObject         ledgerVoucherObject;
    LedgerVoucherTransObject    ledgerVoucherTransObject;
    LedgerJournalTransTxt       transTxt;
    Dimension                   dimension;
    AmountCur                   amount;
    Currency                    currencyCode;
    NumberSequenceCode          numberSequenceCode;
    ;
 
    //<-- Feed a proper number sequence code to 'numberSequenceCode' here
    ttsbegin;
    voucher             = NumberSeq::newGetNumFromCode(numberSequenceCode).num();
    ledgerVoucher       = LedgerVoucher::newLedgerPost(DetailSummary::Detail, SysModule::Ledger, numberSequenceCode);
 
    ledgerVoucherObject = LedgerVoucherObject::newVoucher(voucher, systemdateget(), SysModule::Ledger);
    ledgerVoucher.addVoucher(ledgerVoucherObject);
 
    //while (moreLines) <-- Loop to create all lines belonging to the current voucher (sum must balance)
    {
        ledgerVoucherTransObject = LedgerVoucherTransObject::newCreateTrans(ledgerVoucher.findLedgerVoucherObject(),
                                                                            ledgerPostingType::CustSettlement,  //<-- Use best for your situation
                                                                            ledgerAccount,                      //<-- Account to post to
                                                                            dimension,                          //<-- Financial dimensions to use
                                                                            currencyCode,                       //<-- Use currency corresponding to amount
                                                                            amount,                             //<-- Amount to post
                                                                            my.TableId,                         //<-- TableId referenced (if applicable)
                                                                            my.RecId,                           //<-- RecId referenced (if applicable)
                                                                            qty);                               //<-- A qty (if applicable)
 
        ledgerVoucherTransObject.parmTransTxt(transTxt); //<-- Use best for your situation
        ledgerVoucher.addTrans(ledgerVoucherTransObject);
    }
    ledgerVoucher.end();
    ttscommit;
}

[]s
Ricardo Pichler