This is sample Code to get opening balance for Ledger Main account in Ax 2012.

LedgerBalanceMainAccountAmounts ledgerBalance;
AmountMst opSum;
;
ledgerBalance = LedgerBalanceMainAccountAmounts::construct();
ledgerBalance.parmIncludeRegularPeriod(true);
ledgerBalance.parmIncludeOpeningPeriod(true);
ledgerBalance.parmIncludeClosingPeriod(false);
ledgerBalance.parmAccountingDateRange(mkDate(01,01,2000), mkDate(31,12,2017));
ledgerBalance.calculateBalance(MainAccount::findByMainAccountId(‘1123333’));
opSum = ledgerBalance.getAccountingCurrencyBalance();
info(num2str(opSum,10,2,1,1));

Leave Comment

Your email address will not be published. Required fields are marked *