Alfasith AX

Alfasith AX
اللَّهُمَّ انْفَعْنِي بِمَا عَلَّمْتَنِي، وَعَلِّمْنِي مَا يَنْفَعُنِي، وَزِدْنِي عِلْمًا

Wednesday, May 7, 2014

Code to create general journal in Dynamic AX

Hi,

static void CreateGLJournal(Args _args)
{
    AxLedgerJournalTable journalTable;
    AxLedgerJournalTrans journalTrans;
    DimensionDynamicAccount     offsetDimensions, bankaccount;
    DNIPMIPParameters   parameters;
    dimensionStorage    dimensionStorage;
    LedgerAccountContract   ledgerAccountContract;
    DimensionValue  dimvalue;
    LedgerDimensionAccount dimaccount, ledgeracc;
    LedgerJournalTable  ledgerJournalTable;
    LedgerJournalTrans  ledgerJournalTrans;
    DNIPMPfInvestmentLines  DNIPMPfInvestmentLines;
    DNIPMPfInvesmentTable   table;
   // "??CEU-000025";
    int i;
    ;
    i = 1;
    journalTable = new AxLedgerJournalTable();
    journalTrans = new AxLedgerJournalTrans();


    journalTable.parmJournalName("GenJrn");
    journalTable.save();
    select * from parameters;
    while(i<5)
    {
    journalTrans.parmJournalNum(journalTable.ledgerJournalTable().JournalNum);
    journalTrans.parmTransDate(systemDateGet());
    dimvalue = DimensionStorage::getMainAccountNumFromLedgerDimension(parameters.Payment);
    dimaccount = DimensionStorage::getDefaultAccountForMainAccountNum(dimvalue);
    ledgeracc = DimensionDefaultingService::serviceCreateLedgerDimension(dimaccount);
    journalTrans.parmAccountType(LedgerJournalACType::Ledger);
    journalTrans.parmLedgerDimension(ledgeracc);

    journalTrans.parmAmountCurDebit(2000);
    bankaccount = DimensionStorage::getDynamicAccount('USA OPER', LedgerJournalACType::Bank);
    journalTrans.parmOffsetLedgerDimension(bankaccount);
    journalTrans.parmOffsetAccountType(LedgerJournalACType::Bank );
    journalTrans.parmCurrencyCode("USD");
    //journalTrans.currentRecord().insert();
    journalTrans.save();
    i++;
    }

    info(strFmt("Journal %1 created", journalTable.ledgerJournalTable().JournalNum));

}

Regards,

No comments:

Post a Comment

How find size of recordsortedlist in D365/AX 2012

Hi, This is the continuity of the previous article where we are now getting the size of recordsortedlist . if(recordsortedlist.len() >1) ...