Microsoft Dynamics AX Support

This blog contains posts by the Microsoft Dynamics AX Support Teams Worldwide

Creating General Journals in AX 2012 in X++

Due to popular demand, below is example code that creates a general journal in 2012 using X++ code:

   
AxLedgerJournalTable header = new AxLedgerJournalTable();

AxLedgerJournalTrans trans = new AxLedgerJournalTrans();

container  ledgerDimensions, offsetDimensions;

   
header.parmJournalName(“GenJrn”);   
header.save();  

   
trans.parmAccountType(LedgerJournalACType::Ledger);   
trans.parmJournalNum(header.ledgerJournalTable().JournalNum);   
ledgerDimensions = [“131100-USA”,”131100″, 1, “COUNTRY”,”USA”];   
trans.parmLedgerDimension(AxdDimensionUtil::getLedgerAccountId(ledgerDimensions));   
trans.parmAmountCurDebit(230);   
offsetDimensions = [“0103-USA”,”0103″, 1, “COUNTRY”, “USA”];   
trans.parmOffsetLedgerDimension(AxdDimensionUtil::getLedgerAccountId(offsetDimensions));   
trans.save();