If you want to check opening balance for particular main account then you can check below code to get the same.
This is sample Code to get opening balance for Ledger Main account in Ax 2012.
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));