Retention while making payment to all contractors to be automated based on fixed percentage in ax4.0

Hi everybody

According to project on which we are working, in Accounts Payable module->Journals->Payments->Payment Journal there is a form which opens. The name of that form is “LedgerJournalTransVendPaym” in this form after putting a debit amount as shown in the below screen shot, retention amount should be calculated and displayed in the amount field as shown in the second screen shot.



here in this above form fields which are highlighted are added by me.

In first field which is at the bottom of the form as seen in the above screen shot, takes the value of percentage of retention by which retention amount is calculated.

The amount field which is at the top of the above form as highlighted is used to display the retention amount.

I wrote the code for doing the calculation as written below:

display AmountMST RetentionAmount()
AmountMST RetentionAmount;
LedgerJournalTrans tblLedgerJournalTrans;

RetentionAmount = (tblLedgerJournalTrans.AmountCurDebit * tblLedgerJournalTrans.RetentionAmt_IN)/100;
return RetentionAmount;

I added this code at the table level and also added a method in form level to call this table level method for calculating and displaying the retention amount in the highlighted field but still the amount is not getting displayed in that field.

Kindly help me with any code if it is required.