Monday, September 10, 2012

How to create General Journal in AX 2012 by X++ code


With following code we can create general journal with default dimention and ledger Account
just change default values according to youe system data and simply run the job


static void Demo_CreateGLJrl(Args _args)
{
    AxLedgerJournalTable   axLedgerJournalTable ;
    AxLedgerJournalTrans   axLedgerJournalTrans;
    container            accPattern;
    container            offSetPattern;
    container            dimPattern1;
    ;
    axLedgerJournalTable = new AxLedgerJournalTable();
    axLedgerJournalTrans = new AxLedgerJournalTrans();
    dimPattern1 = [1,"Department", "000"];
    axLedgerJournalTable.parmDefaultDimension(AxdDimensionUtil::getDimensionAttributeValueSetId(dimPattern1));
    axLedgerJournalTable.parmJournalName("GenJrn");
    axLedgerJournalTable.save();
    axLedgerJournalTrans.parmJournalNum(axLedgerJournalTable.ledgerJournalTable().JournalNum);
    axLedgerJournalTrans.parmTransDate(systemDateGet());
    axLedgerJournalTrans.parmAccountType(LedgerJournalACType::Ledger);
    accPattern = ["420100", "420100", 0];
    axLedgerJournalTrans.parmLedgerDimension(AxdDimensionUtil::getLedgerAccountId(accPattern));
    offSetPattern = ["420200", "420200", 0];
    axLedgerJournalTrans.parmOffsetAccountType(LedgerJournalACType:: Ledger );
    axLedgerJournalTrans.parmOffsetLedgerDimension(AxdDimensionUtil::getLedgerAccountId( offSetPattern));
    axLedgerJournalTrans.save();
    info(strFmt("Journal %1 created with finential Dimension %2", axLedgerJournalTable.ledgerJournalTable().JournalNum,axLedgerJournalTable.ledgerJournalTable().DefaultDimension));
}

3 comments:

  1. hi
    how create more lines in the same journal

    ReplyDelete
  2. This example is for one line. how to for several lines

    ReplyDelete