Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Calaculate Interest Rate

Former Member
0 Likes
795

Hi All,

Can you please help me with this,

I have internal table like this

Payment Date Principal Amount

10/1/2009 2500

12/1/2009 500

12/31/2009 1500

02/28/2010 600

If I want know the Interest accured on 02/28/2010 then I need to calculate like this,

No_Days = from 10/1/2009 to 12/1/2009 = 62 Days

Principal Amt = 2500+500

IntAmt1 = PrincipalAmt * Intrest Rate*No_Days/360

And then

No_Days = from 12/1/2009 to 12/31/2009 = 31 Days

Principal Amt = 25005001500

IntAmt2 = PrincipalAmt * Intrest Rate*No_Days/360

And then

No_Days = from 12/31/2009 to 02/28/2010 = 60 Days

Principal Amt = 25005001500 + 600

IntAmt3 = PrincipalAmt * Intrest Rate*No_Days/360

Finally Accrued Interest should be Sum of IntAmt1 + IntAmt2 + IntAmt3.

Can you please help me how to do this.

Hi All,

Can you please help me with this,

I have internal table like this

Payment Date Principal Amount

10/1/2009 2500

12/1/2009 500

12/31/2009 1500

02/28/2010 600

If I want know the Interest accured on 02/28/2010 then I need to calculate like this,

No_Days = from 10/1/2009 to 12/1/2009 = 62 Days

Principal Amt = 2500+500

IntAmt1 = PrincipalAmt * Intrest Rate*No_Days/360

And then

No_Days = from 12/1/2009 to 12/31/2009 = 31 Days

Principal Amt = 25005001500

IntAmt2 = PrincipalAmt * Intrest Rate*No_Days/360

And then

No_Days = from 12/31/2009 to 02/28/2010 = 60 Days

Principal Amt = 25005001500 + 600

IntAmt3 = PrincipalAmt * Intrest Rate*No_Days/360

Finally Accrued Interest should be Sum of IntAmt1 + IntAmt2 + IntAmt3.

Can you please help me how to do this.

5 REPLIES 5
Read only

Former Member
0 Likes
734

gathering No_Days = from 10/1/2009 to 12/1/2009 = 62 Days

is the payment date?

Principal Amt = 2500+500

do you want to add the amounts if the payment date is in that range?

IntAmt1 = PrincipalAmt * Intrest Rate*No_Days/360

this is the calc to get the interest amount?

Read only

0 Likes
734

Yes that is Payment Date to get Number of Days. Yes I want to add based on Key Date that I give in this example 02/28/2010 so I need to do Interest Accurued for all paymetns dates happened before 02/28/2010.

Some times there will be just one payment with payment date or it could be several paymetns happened in this case we have 3 different payment dates before 02/28/2010.

The formula to calculate Intest Amount which is also called Accrued Interest with basic formula like this,

IntAmt1 = PrincipalAmt * Intrest Rate*No_Days/360

Thank you.

Read only

0 Likes
734

That seems like a fairly simple loop process with some variables thrown in for tracking. Do you have code that you've tried and doesn't work? Post it and someone might tell you what's wrong with it...

Read only

0 Likes
734

Here is my code,'

DATA: BEGIN OF ITAB1 OCCURS 0,

COMPANY_CODE TYPE Z4FICLOAN-COMPANY_CODE,

RFHA TYPE Z4FICLOAN-RFHA,

FLOWTYPE TYPE TRLS_FLOW_ALV-FLOWTYPE,

payment_DATE TYPE vtbsodoku-dstich,

ZNOMINAL_AMOUNT type Z4FICLOAN-NOMINAL_AMOUNT,

END OF ITAB1.

data itab2 like itab1 occurs 0 with header line.

DATA: BEGIN OF ITAB3 occurs 0 ,

NO_DAYS TYPE I,

NOMINAL_AMOUNT type Z4FICLOAN-NOMINAL_AMOUNT,

END OF ITAB3.

if itab1-payment_date < SO_KDAT .

clear: l_count, Nominal_amount, I_RATE1, I_RATE2 , Z2NOMINAL_AMOUNT ,Z1NOMINAL_AMOUNT .

itab2[] = itab1[].

l_rfha = itab1-rfha.*

DESCRIBE TABLE ITAB2 LINES G_REC_CNT.

WHILE z_count <= 4.

If LV_DATUM is initial.

PAY_DATE = SO_KDAT.

Else.

PAY_DATE = LV_DATUM.

EndIf.

loop at itab2 where rfha = itab1-rfha and payment_date < PAY_DATE.

If LV_DATUM is initial.

PAY_DATE = SO_KDAT.

Else.

PAY_DATE = LV_DATUM.

EndIf.

if sy-tabix = 1.

LV_DATUM = itab2-payment_date.

endif.

if itab2-rfha = itab1-rfha and itab2-flowtype6(1) = ''.

Nominal_amount = nominal_amount + itab2-NOMINAL_AMOUNT.

elseif itab2-rfha = itab1-rfha and itab2-flowtype+6(1) = '-'.

Nominal_amount = nominal_amount - itab2-NOMINAL_AMOUNT.

endif.

CALL FUNCTION '/SDF/CMO_DATETIME_DIFFERENCE'

EXPORTING

DATE1 = LV_DATUM

DATE2 = PAY_DATE

IMPORTING

DATEDIFF = NO_DAYS.

NO_DAYS = NO_DAYS + 1.

ITAB3-NO_DAYS = NO_DAYS.

idx = sy-tabix.

  • ITAB3-ZNOMINAL_AMOUNT = NOMINAL_AMOUNT.

APPEND ITAB3.

DELETE ITAB2 where Payment_Date = LV_DATUM.

endloop.

z_count = z_count + 1.

ENDWHILE.

CALL FUNCTION 'BAPI_FTR_IRATE_GETDETAIL'

EXPORTING

COMPANYCODE = itab1-company_code

FINANCIALTRANSACTION = itab1-rfha

IMPORTING

RETURNIRATE = lwa_RETURNIRATE

RETURNGENERALCONTRACTDATA = lwa_RETURNGENERALCONTRACTDATA

TABLES

RETURN = l_tab_return.

LOOP AT ITAB3.

I_DEC = lwa_RETURNIRATE-INTEREST_RATE / 100.

I_RATE = ITAB3-nominal_amount * I_DEC.

I_RATE1 = I_RATE * ITAB3-NO_DAYS / 360.

INT_RATE = INT_RATE + I_RATE1.

ENDLOOP.

Result is like this,

ITAB3 has No_Days but don't know how to add Nominal Amount.

Read only

0 Likes
734

Hi Thanvi,

It is a simple calculation with a cople of variables as said by brad bohn.

I am suggesting the below logic assuming all your data processed in the final internal table

*lt_final with 3 fields *

1.cust(customer)

2. date(payment date)

3. amt(payment amount)

for a particular customer

defined variables :

l_pdate(previous date)

l_cdate(current date)

l_key date = 20100228(your key date for the basis of interest calculatoin)

l_pamt(principal amount)

ir = interest rate

delete lt_final where date > l_keydate.

loop at lt_final into lw_final.

if sy-tabix = 1.

l_pdate = lw_final-date.

endif.

l_cdate = lw_final-date.

perform get_number_of_days changing l_days"(l_days = l_cdate-l_pdate///use fm)

l_pamt = l_pamt + lw_final-amt.

l_pamtdays = l_pamt*l_days."(amount multiplied by number of days)

l_int = l_pamtdays*ir/360."interest earnerd after each pmt date

l_tot_int = l_tot_int + l_int.

l_pdate = l_cdate.

at end of cust.

"handle variables clearing and reassignment

endat.

endloop.