while select sum does not work it

Hello Guys,

I have code blog down blog: I am trying to show sum amount off payback.amountcurInterest and Amountcur of payback table.

For Amountcur I should group by payback.CrdtShortLong(long or short)

if CrdtLinePayback).CrdtShortLong=short then it should sum up the related lines’

I should Write something like this on this code blog

LedgerTransJournal.AmountCurCredit +=paybackk.AmontcurInterest;it should sum up the Interest of payback’s table

if(payback.CrdtShortLong =CrdtShortLong:short) then

LedgerTransJournal.AmountCutcredit +=payback.amountcur it should sum up the amountcur of paybackk

aLso there is a case that ,in sametime I can have journal lines like short term and log term , I should show separetly their amount too

this is the code blog:

while select sum(AmountCur) from payback where payback.CrdtId == crdttable.CrdtId
{
ledgerJournalTrans.clear();
ledgerJournalTrans.Voucher = voucher;

ledgerJournalTrans = setLedgerJournalTransCommonField( voucher,
ledgerJournalTable.JournalNum,
currencyCode,
ledgerJournalName.TransactionTxtType
);
AmountCurDebit += Currency::amount(payback.BSMVInterest());
if(payback.BuzCrdtShortLong == CrdtShortLong::ShortTerm)
{

I wrote in here the both code but it did not work it.

AmountLongInterest += payback.BSMVInterest();
AmountLong += Currency::amount(payback.AmountCur + payback.BSMVInterest());

}
else
{
AmountShortInterest += payback.BSMVInterest();
AmountShort += Currency::amount(payback.AmountCur + payback.BSMVInterest());

}

ledgerJournalTrans.AmountCurDebit = Currency::amount(payback.BSMVInterest());
ledgerJournalTrans.AccountType = LedgerJournalACType::Ledger;
ledgerJournalTrans.CurrencyCode = CrdtTable.currencyCode;
ledgerJournalTrans.ExchRate = CrdtTable.ExchRate;

ledgerJournalTrans.insert();
}

Use group by. (something like below).

while select sum(AmountCur) from payback group by CrdtShortLong

where payback.CrdtId == crdttable.CrdtId

But what does this method has, you will get only the amount and the group by field value in payback buffer.

This will work if you use a group by on CrdtShortLong (as i mentioned above)

thank you so much kranthi it worked like always, can I ask something else you

I have a few knowledge about dimensions, they want me to bring the dimension from my crdttable’s from to the ledgerjournaltrans’s form; Dimension is an array and I need to bring the dimension[2]

I wrote something like tihs.

ledgerJournalTrans.Dimension[2] =crdtTable.dimension[2] on the code like this:

I should return the dimension of bank account’s Journal’s line and genreal ledger journal’s line on the ledgerjournalTrans form.

Basically I want to full the dimension when I create journal on my crdtTable form:

while select CrdtShortLong from payback group by CrdtShortLong where payback.CrdtId == crdttable.CrdtId

{

ledgerJournalTrans.clear();

ledgerJournalTrans.Voucher = voucher;

ledgerJournalTrans = setLedgerJournalTransCommonField( voucher,

ledgerJournalTable.JournalNum,

currencyCode,

ledgerJournalName.TransactionTxtType

);

//AmountCurDebit = Currency::amount(BuzCrdtTable.AmountCur);

ledgerJournalTrans.AmountCurCredit = payback.BuzCrdtShortLong == CrdtShortLong::ShortTerm ? AmountShort : AmountLong;//AmountCurDebit;

ledgerJournalTrans.AccountType = LedgerJournalACType::Ledger;

ledgerJournalTrans.CurrencyCode = CrdtTable.currencyCode;

ledgerJournalTrans.ExchRate = CrdtTable.ExchRate;

if(payback.CrdtShortLong == CrdtShortLong::ShortTerm)

{

BuzCrdtLedgerAccounts = CrdtLedgerAccounts::findInterest(BuzCrdtShortLong::ShortTerm,crdttable.CrdtGroupId,CrdtAccrueType::LoanUsage);

ledgerJournalTrans.AmountCurCredit = AmountLong;//////

}

else

{

BuzCrdtLedgerAccounts = CrdtLedgerAccounts::findInterest(CrdtShortLong::LongTerm,buzcrdttable.CrdtGroupId,CrdtAccrueType::LoanUsage);

ledgerJournalTrans.AmountCurCredit = AmountShort;/////

}

ledgerJournalTrans.AccountNum = CrdtLedgerAccounts.CrdtLedgerAccountOffSet;

//ledgerJournalTrans.AccountNum = payback.CrdtShortLong == CrdtShortLong::ShortTerm ?

// CrdtTable.CrdtCreditAccountShort : CrdtTable.CrdtCreditAccountLong;

ledgerJournalTrans.Dimension[2] =CrdtTable.Dimension[2];/////////

ledgerJournalTrans.insert();

}

Should I write on initvalue of ledgerJournalTrans table?

Yes you can. Have look at that method, it basically does some default value assignments.

Is that a custom field? There is only ledgerJournalTrans.DefaultDimesion in AX 2012.

yes custom field there is a dimension tab on both forms ,when I check the field Name dimension but its an array,so I need the bring the dimension[2] value to my ledger journaltrans form

its ax 2009,should I write a display for it? in ax 2009 which class or tables should I look for

For which field? Can you add more details?

I do not know How can I bring the dimension vale from vrdtTable form to ledgerjournaltransform in ax 2009 ,when I create new journal from crdTtABLE,its creates a journal in ledgerjournalTable tooo,I chose the dimension in crdtTable,I want to see the dimension in the ledgerjournalttrans tooo,my dimension table is called dimensions,and my dimension field is dimension[2] on both forms.

not display sorry I confused,I need to init the crdtTable’s dimensions to ledgerjournaltrans’s dimensions .

I am trying to bring Cost center dimensions

ledgerJournalTrans.Dimension[2] = crdtTable.Dimension[2];
In the above code example, 2 is the index of that dimension array element.