NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

FORM wt_class .

DATA: gv_cpnodays TYPE i,
gv_ncdcompdays TYPE i.

CLEAR gv_cpnodays.
CLEAR: gv_start,gv_end,gv_days,gv_rate.
"" Start DAte
IF <fs_tpos>-trldate < p_date-low.
gv_start = p_date-low.
ELSE.
gv_start = <fs_tpos>-trldate.
ENDIF.
""Added for 15f by arpan on 27.06.2024 .
CLEAR : lt_sump , lv_15frate.
IF <fs_data>-zsgsart = '15F'.
LOOP AT gt_rate15f INTO DATA(ls_rate) WHERE dguel_kp LT p_date-low AND ranl = <fs_data>-zranl.
DATA(dalv_prevrate) = ls_rate-pkond.
lv_15frate = ls_rate-pkond.
EXIT.
ENDLOOP.

DATA(lv_mdays) = p_date-high - p_date-low + 1 .
LOOP AT gt_rate15f ASSIGNING FIELD-SYMBOL(<fs_r>) WHERE dguel_kp BETWEEN p_date-low AND p_date-high and ranl = <fs_data>-zranl.
IF sy-tabix = 1.
APPEND VALUE #( days = <fs_r>-dguel_kp - p_date-low + 1 rate = lv_15frate ) TO lt_sump.
lv_mdays = lv_mdays - ( <fs_r>-dguel_kp - p_date-low ).
ENDIF.
APPEND VALUE #( days = p_date-high - <fs_r>-dguel_kp rate = <fs_r>-pkond ) TO lt_sump.
lv_15frate = lv_15frate + <fs_r>-pkond .
ENDLOOP.
IF lt_sump IS NOT INITIAL.
TRY . lv_15frate = REDUCE #( INIT rat TYPE pkond FOR <fs_r1> IN lt_sump NEXT rat = rat + ( <fs_r1>-days * <fs_r1>-rate ) ) / lv_15frate . CATCH cx_sy_arithmetic_error . ENDTRY.
ENDIF.
ENDIF.
""Added for 15f by arpan on 27.06.2024 .

"" End Date
IF <fs_data>-zdelfz < p_date-high.
gv_end = <fs_data>-zdelfz.
TRY. gv_days = gv_end - gv_start . CATCH cx_sy_arithmetic_error. ENDTRY.
* ELSEIF <fs_data>-zsgsart = c_15f . "May require to uncomment logic for ending txn on month end date
* gv_end = <fs_data>-zdelfz.
* TRY. gv_days = gv_end - gv_start . CATCH cx_sy_arithmetic_error. ENDTRY.
ELSE.
gv_end = p_date-high.
"" No.of days
* IF <fs_data>-zsgsart EQ c_15b AND <fs_data>-zsfhaart EQ '310'. "diff days logic for 310 ncd compounding
* TRY. gv_days = gv_end - gv_start . CATCH cx_sy_arithmetic_error. ENDTRY.
* ELSE.
TRY. gv_days = gv_end - gv_start + 1. CATCH cx_sy_arithmetic_error. ENDTRY.
* ENDIF.
ENDIF.


gv_amt = <fs_tpos>-position_amt.

CASE <fs_tpos>-sign.
WHEN '-'.
TRY. gv_amt = gv_amt * -1. CATCH cx_sy_arithmetic_error. ENDTRY.
ENDCASE.
gs_wt-zrfha = <fs_data>-zrfha.


CASE <fs_data>-zsgsart.
WHEN c_15a OR c_15c. "CP
IF <fs_tpos>-zcategory = c_c08 OR <fs_tpos>-zcategory = c_c09.

IF <fs_tpos>-zcategory = c_c08.
"Weighted Amount
DATA(lv_wcamt) = abap_true.
DATA(lv_bamt) = gv_amt.
TRY. <fs_data>-wei_c = <fs_data>-wei_c + ( gv_amt * gv_days / gv_mdays ). CATCH cx_sy_arithmetic_error. ENDTRY.
TRY. gs_wt-zwei_c = <fs_data>-wei_c . CATCH cx_sy_arithmetic_error. ENDTRY.

ELSEIF <fs_tpos>-zcategory = c_c09.
gv_cpnodays = ( <fs_data>-zdelfz - <fs_tpos>-trldate ).
"Weighted Interset Amt
TRY. <fs_data>-wei_int_c = <fs_data>-wei_int_c + ( gv_amt * gv_days / gv_cpnodays ). CATCH cx_sy_arithmetic_error. ENDTRY. "36500
* TRY. gs_wt-zwei_int_c = ( gv_amt * gv_days ) / gv_cpnodays. CATCH cx_sy_arithmetic_error. ENDTRY."36500 .
TRY. gs_wt-zwei_int_c = <fs_data>-wei_int_c . CATCH cx_sy_arithmetic_error. ENDTRY."36500 . "arpan
lv_wcamt = abap_true.
lv_bamt = lv_bamt + gv_amt.
ENDIF.


IF lv_wcamt IS NOT INITIAL.

"" Weigthed Interest Rate
* TRY. gs_wt-zwei_rate_c = gs_wt-zwei_int_c / gs_wt-zwei_c * c_36500 / gv_mdays. CATCH cx_sy_arithmetic_error. ENDTRY."un
* TRY. gv_wt_amt = gv_wt_amt + gs_wt-zwei_c. CATCH cx_sy_arithmetic_error. ENDTRY. "un
* TRY. gv_wt_int = gv_wt_int + gs_wt-zwei_int_c. CATCH cx_sy_arithmetic_error. ENDTRY. "un

TRY. gv_wt_amt = <fs_data>-wei_c. CATCH cx_sy_arithmetic_error. ENDTRY. "arpan
TRY. gv_wt_int = <fs_data>-wei_int_c . CATCH cx_sy_arithmetic_error. ENDTRY. "arpan
TRY. gs_wt-zwei_rate_c = gs_wt-zwei_int_c / gs_wt-zwei_c * c_36500 / gv_mdays. CATCH cx_sy_arithmetic_error. ENDTRY."arpan

IF <fs_tpos>-trldate IN p_date .
gs_wt-zm_amt = lv_bamt.
ENDIF.

* " Updating the Details to the table for Pop-up for the FM
gs_wt-zbukrs = <fs_data>-zbukrs.
gs_wt-zranl = <fs_data>-zranl.
gs_wt-zdate = <fs_tpos>-trldate.
gs_wt-zint_rate = gv_rate.
gs_wt-zsdate = gv_start.
gs_wt-zedate = gv_end.
gs_wt-zdays = gv_days.
gs_wt-zamt = lv_bamt .
gs_wt-zm_amt = lv_bamt .

CASE <fs_tpos>-sign.
WHEN '-'.
gs_wt-zm_stat = 'R'.
TRY. gs_wt-zfamt = <fs_tpos>-position_amt * -1. CATCH cx_sy_arithmetic_error. ENDTRY.
WHEN OTHERS.
gs_wt-zm_stat = 'A'.
gs_wt-zfamt = <fs_tpos>-position_amt.
ENDCASE.

APPEND gs_wt TO gt_wt_sec.
CLEAR:gs_wt, lv_bamt, lv_wcamt.
ENDIF.

ENDIF.
WHEN c_15b OR c_15h OR c_15i OR c_15f.
IF <fs_tpos>-zcategory = c_c03 OR <fs_tpos>-zcategory = c_c10.

IF <fs_tpos>-zcategory = c_c10.
CLEAR gv_tdays.
TRY. gv_tdays = <fs_data>-zdelfz - <fs_tpos>-trldate . CATCH cx_sy_arithmetic_error. ENDTRY. "FOR 15A 310 TXN TYPE
* TRY. GV_MDAYS = gv_start - GV_T_DATE . CATCH cx_sy_arithmetic_error. ENDTRY.
TRY. <fs_data>-wei_int_c = <fs_data>-wei_int_c + ( ( gv_amt / gv_tdays ) * gv_days ). CATCH cx_sy_arithmetic_error. ENDTRY. "36500
TRY. gs_wt-zwei_int_c = ( ( gv_amt / gv_tdays ) * gv_days ). CATCH cx_sy_arithmetic_error. ENDTRY."36500 .
gv_ncdcompdays = gv_tdays.

ELSE.
IF <fs_tpos>-zflow_type = 'SE1200'.
READ TABLE gt_tpos_s ASSIGNING FIELD-SYMBOL(<fs_15a>) WITH KEY zflow_type = 'DBT_A050' trldate = <fs_tpos>-trldate security_id = <fs_tpos>-security_id.
IF sy-subrc = 0.
gv_amt = gv_amt - <fs_15a>-position_amt .
<fs_data>-open_amt = <fs_data>-open_amt - <fs_15a>-position_amt .
ENDIF.
READ TABLE gt_tpos_s ASSIGNING FIELD-SYMBOL(<fs_15a1>) WITH KEY zflow_type = 'DBT_A040' trldate = <fs_tpos>-trldate security_id = <fs_tpos>-security_id.
IF sy-subrc = 0.
gv_amt = gv_amt + <fs_15a1>-position_amt .
<fs_data>-open_amt = <fs_data>-open_amt + <fs_15a1>-position_amt .
ENDIF.

* ls_data-open_amt = <fs_data>-open_amt - <fs_15a1>-position_amt .
ENDIF.

TRY. <fs_data>-wei_c = <fs_data>-wei_c + ( gv_amt * gv_days / gv_mdays ). CATCH cx_sy_arithmetic_error. ENDTRY.
TRY. gs_wt-zwei_c = gv_amt * gv_days / gv_mdays . CATCH cx_sy_arithmetic_error. ENDTRY.
"" weighted Interest Logic EIR
CLEAR:gv_rate.
LOOP AT gt_kopo ASSIGNING <fs_kopo> WHERE rkey1 = <fs_data>-zranl AND pkond IS NOT INITIAL .
gv_rate = <fs_kopo>-pkond.
EXIT.
ENDLOOP.
""Added by arpan on 27.06.2024 for 15f r
IF lv_15frate IS NOT INITIAL.
gv_rate = lv_15frate .
ENDIF.

"" Weighted Interest Logic - Coupon Logic
gs_wt-zint_rate_c = gv_rate.
TRY. <fs_data>-wei_int_c = <fs_data>-wei_int_c + ( gv_amt * gv_days * gv_rate / c_36500 ). CATCH cx_sy_arithmetic_error. ENDTRY. "36500
TRY. gs_wt-zwei_int_c = gv_amt * gv_days * gv_rate / c_36500. CATCH cx_sy_arithmetic_error. ENDTRY."36500 .

ENDIF.
"" Weigthed Interest Rate
TRY. gs_wt-zwei_rate_c = gs_wt-zwei_int_c / gs_wt-zwei_c * c_36500 / gv_mdays. CATCH cx_sy_arithmetic_error. ENDTRY. "36500

TRY. gv_wt_amt = gv_wt_amt + gs_wt-zwei_c. CATCH cx_sy_arithmetic_error. ENDTRY.
TRY. gv_wt_int = gv_wt_int + gs_wt-zwei_int_c. CATCH cx_sy_arithmetic_error. ENDTRY.

IF <fs_tpos>-trldate IN p_date .
gs_wt-zm_amt = gv_amt.
ENDIF.
ENDIF.

"" Updating the Details to the table for Pop-up for the FM
gs_wt-zbukrs = <fs_data>-zbukrs.
gs_wt-zranl = <fs_data>-zranl.
gs_wt-zdate = <fs_tpos>-trldate.
gs_wt-zint_rate = gv_rate.
gs_wt-zsdate = gv_start.
gs_wt-zedate = gv_end.
gs_wt-zdays = gv_days.
gs_wt-zamt = gv_amt .
gs_wt-zm_amt = gv_amt .

CASE <fs_tpos>-sign.
WHEN '-'.
gs_wt-zm_stat = 'R'.
TRY. gs_wt-zfamt = <fs_tpos>-position_amt * -1. CATCH cx_sy_arithmetic_error. ENDTRY.
WHEN OTHERS.
gs_wt-zm_stat = 'A'.
gs_wt-zfamt = <fs_tpos>-position_amt.
ENDCASE.

APPEND gs_wt TO gt_wt_sec.
CLEAR:gs_wt.

WHEN c_15b .
* IF <fs_tpos>-zsfhaart = '310'.
IF <fs_tpos>-zcategory = c_c03 OR <fs_tpos>-zcategory = c_c10 OR <fs_tpos>-zcategory = c_c11.

IF <fs_tpos>-zcategory = c_c10. "DISCOUNT / PREMIUM LOGIC
CLEAR gv_tdays.
TRY. gv_tdays = <fs_data>-zdelfz - <fs_tpos>-trldate . CATCH cx_sy_arithmetic_error. ENDTRY. "FOR 15A 310 TXN TYPE
* TRY. GV_MDAYS = gv_start - GV_T_DATE . CATCH cx_sy_arithmetic_error. ENDTRY.
TRY. <fs_data>-wei_int_c = <fs_data>-wei_int_c + ( ( gv_amt / gv_tdays ) * gv_days ). CATCH cx_sy_arithmetic_error. ENDTRY. "36500
TRY. gs_wt-zwei_int_c = ( ( gv_amt / gv_tdays ) * gv_days ). CATCH cx_sy_arithmetic_error. ENDTRY."36500 .
* TRY. gs_wt-zwei_c = gv_amt * gv_ncdcompdays / gv_mdays . CATCH cx_sy_arithmetic_error. ENDTRY.
ELSE.
IF <fs_tpos>-zcategory = c_c03. "WT AMT
* gv_amt = gv_amt + REDUCE #( INIT amt TYPE tb_limit_amount FOR wa in gt_tpos_s
* WHERE ( zcategory = c_c11 and trldate le gv_end )
* NEXT amt = amt + wa-position_amt ) .
* gv_ncdcompdays = <fs_tpos>-trldate - gv_end + 1 .
READ TABLE gt_tpos_s ASSIGNING FIELD-SYMBOL(<fs_s>) WITH KEY security_id = <fs_tpos>-security_id zcategory = c_c11 .
IF sy-subrc = 0.
IF <fs_s>-trldate GT gv_end.
gv_ncdcompdays = gv_end - <fs_data>-zdblfz + 1 .
IF gv_ncdcompdays GT gv_mdays.
gv_ncdcompdays = gv_mdays.
ENDIF.
ELSE.
gv_ncdcompdays = <fs_s>-calc_end - <fs_tpos>-trldate.
IF gv_ncdcompdays GT gv_mdays AND <fs_data>-zdelfz GE p_date-high.
gv_ncdcompdays = gv_mdays.
ELSEIF gv_ncdcompdays GT gv_mdays AND <fs_data>-zdelfz LE p_date-high.
gv_ncdcompdays = gv_end - gv_start .
ENDIF.
ENDIF.
ELSE.
gv_ncdcompdays = <fs_data>-zdblfz - gv_end .
IF gv_ncdcompdays GT gv_mdays.
gv_ncdcompdays = gv_mdays.
IF gv_ncdcompdays GT gv_mdays AND <fs_data>-zdelfz GE p_date-high.
gv_ncdcompdays = gv_mdays.
ELSEIF gv_ncdcompdays GT gv_mdays AND <fs_data>-zdelfz LE p_date-high.
gv_ncdcompdays = gv_end - gv_start .
ENDIF.
ENDIF.
ENDIF.

gv_amt = <fs_tpos>-nominal_amt .
ELSEIF <fs_tpos>-zcategory = c_c11. "CAPITILIZATION LOGIC
* gv_ncdcompdays = gv_start - <fs_tpos>-calc_end + 1 .
* gv_ncdcompdays = <fs_tpos>-calc_end - gv_end .
IF <fs_tpos>-trldate LT gv_start AND gv_end GE p_date-high.
gv_ncdcompdays = gv_mdays . "since capialization done
ELSEIF <fs_tpos>-trldate LT gv_start AND gv_end LT p_date-high.
gv_ncdcompdays = gv_end - gv_start .
ELSEIF <fs_tpos>-trldate GE gv_start.
gv_ncdcompdays = gv_end - <fs_tpos>-calc_end .
IF gv_ncdcompdays GT gv_mdays .
gv_ncdcompdays = gv_mdays.
ENDIF.
ENDIF.
IF <fs_tpos>-trldate = <fs_data>-zdelfz.
gv_ncdcompdays = 0 .
ENDIF.

* TRY.
* gv_amt = ( gv_amt ) * gv_ncdcompdays / gv_mdays .
* CATCH cx_sy_arithmetic_error.
* ENDTRY.
ENDIF.
* TRY. <fs_data>-wei_c = <fs_data>-wei_c + ( gv_amt * gv_days / gv_mdays ). CATCH cx_sy_arithmetic_error. ENDTRY.
* TRY. gs_wt-zwei_c = gv_amt * gv_days / gv_mdays . CATCH cx_sy_arithmetic_error. ENDTRY.
TRY. <fs_data>-wei_c = <fs_data>-wei_c + ( gv_amt * gv_ncdcompdays / gv_mdays ). CATCH cx_sy_arithmetic_error. ENDTRY.
TRY. gs_wt-zwei_c = gv_amt * gv_ncdcompdays / gv_mdays . CATCH cx_sy_arithmetic_error. ENDTRY.
"" weighted Interest Logic EIR
CLEAR:gv_rate.
LOOP AT gt_kopo ASSIGNING <fs_kopo> WHERE rkey1 = <fs_data>-zranl AND pkond IS NOT INITIAL .
gv_rate = <fs_kopo>-pkond.
EXIT.
ENDLOOP.

"" Weighted Interest Logic - Coupon Logic
gs_wt-zint_rate_c = gv_rate.
* TRY. <fs_data>-wei_int_c = <fs_data>-wei_int_c + ( gv_amt * gv_days * gv_rate / c_36500 ). CATCH cx_sy_arithmetic_error. ENDTRY. "36500
* TRY. gs_wt-zwei_int_c = gv_amt * gv_days * gv_rate / c_36500. CATCH cx_sy_arithmetic_error. ENDTRY."36500 .
TRY. <fs_data>-wei_int_c = <fs_data>-wei_int_c + ( gv_amt * gv_ncdcompdays * gv_rate / c_36500 ). CATCH cx_sy_arithmetic_error. ENDTRY. "36500
TRY. gs_wt-zwei_int_c = gv_amt * gv_ncdcompdays * gv_rate / c_36500. CATCH cx_sy_arithmetic_error. ENDTRY."36500 .


ENDIF.

"" Weigthed Interest Rate
TRY. gs_wt-zwei_rate_c = gs_wt-zwei_int_c / gs_wt-zwei_c * c_36500 / gv_mdays. CATCH cx_sy_arithmetic_error. ENDTRY. "36500


TRY. gv_wt_amt = gv_wt_amt + gs_wt-zwei_c. CATCH cx_sy_arithmetic_error. ENDTRY.
TRY. gv_wt_int = gv_wt_int + gs_wt-zwei_int_c. CATCH cx_sy_arithmetic_error. ENDTRY.

IF <fs_tpos>-trldate IN p_date .
gs_wt-zm_amt = gv_amt.
ENDIF.

ENDIF.

"" Updating the Details to the table for Pop-up for the FM
gs_wt-zbukrs = <fs_data>-zbukrs.
gs_wt-zranl = <fs_data>-zranl.
gs_wt-zdate = <fs_tpos>-trldate.
gs_wt-zint_rate = gv_rate.
gs_wt-zsdate = gv_start.
gs_wt-zedate = gv_end.
gs_wt-zdays = gv_ncdcompdays.
gs_wt-zamt = gv_amt .
gs_wt-zm_amt = gv_amt .

CASE <fs_tpos>-sign.
WHEN '-'.
gs_wt-zm_stat = 'R'.
TRY. gs_wt-zfamt = <fs_tpos>-position_amt * -1. CATCH cx_sy_arithmetic_error. ENDTRY.
WHEN OTHERS.
gs_wt-zm_stat = 'A'.
gs_wt-zfamt = <fs_tpos>-position_amt.
ENDCASE.

APPEND gs_wt TO gt_wt_sec.
CLEAR:gs_wt.

WHEN OTHERS. "Others
IF <fs_tpos>-zcategory = c_c03 OR <fs_tpos>-zcategory = c_c10.
* "" Weighted Amt
* READ TABLE gt_vwpanle ASSIGNING <fs_vwpanle> WITH KEY ranl = <fs_data>-zranl BINARY SEARCH.
* IF sy-subrc = 0.
* TRY. gv_amt = ( <fs_tpos>-units * <fs_vwpanle>-bnoms ). CATCH cx_sy_arithmetic_error. ENDTRY.
* ENDIF.

TRY. <fs_data>-wei_c = <fs_data>-wei_c + ( gv_amt * gv_days / gv_mdays ). CATCH cx_sy_arithmetic_error. ENDTRY.
TRY. gs_wt-zwei_c = gv_amt * gv_days / gv_mdays . CATCH cx_sy_arithmetic_error. ENDTRY.

"" weighted Interest Logic EIR
CLEAR:gv_rate.
LOOP AT gt_kopo ASSIGNING <fs_kopo> WHERE rkey1 = <fs_data>-zranl AND pkond IS NOT INITIAL .
gv_rate = <fs_kopo>-pkond.
EXIT.
ENDLOOP.

"" Weighted Interest Logic - Coupon Logic
gs_wt-zint_rate_c = gv_rate.
TRY. <fs_data>-wei_int_c = <fs_data>-wei_int_c + ( gv_amt * gv_days * gv_rate / c_36500 ). CATCH cx_sy_arithmetic_error. ENDTRY. "36500
TRY. gs_wt-zwei_int_c = gv_amt * gv_days * gv_rate / c_36500. CATCH cx_sy_arithmetic_error. ENDTRY."36500 .

"" Weigthed Interest Rate
TRY. gs_wt-zwei_rate_c = gs_wt-zwei_int_c / gs_wt-zwei_c * c_36500 / gv_mdays. CATCH cx_sy_arithmetic_error. ENDTRY. "36500

TRY. gv_wt_amt = gv_wt_amt + gs_wt-zwei_c. CATCH cx_sy_arithmetic_error. ENDTRY.
TRY. gv_wt_int = gv_wt_int + gs_wt-zwei_int_c. CATCH cx_sy_arithmetic_error. ENDTRY.

IF <fs_tpos>-trldate IN p_date .
gs_wt-zm_amt = gv_amt.
ENDIF.

ENDIF.

"" Updating the Details to the table for Pop-up for the FM
gs_wt-zbukrs = <fs_data>-zbukrs.
gs_wt-zranl = <fs_data>-zranl.
gs_wt-zdate = <fs_tpos>-trldate.
gs_wt-zint_rate = gv_rate.
gs_wt-zsdate = gv_start.
gs_wt-zedate = gv_end.
gs_wt-zdays = gv_days.
gs_wt-zamt = gv_amt .
gs_wt-zm_amt = gv_amt .

CASE <fs_tpos>-sign.
WHEN '-'.
gs_wt-zm_stat = 'R'.
TRY. gs_wt-zfamt = <fs_tpos>-position_amt * -1. CATCH cx_sy_arithmetic_error. ENDTRY.
WHEN OTHERS.
gs_wt-zm_stat = 'A'.
gs_wt-zfamt = <fs_tpos>-position_amt.
ENDCASE.

APPEND gs_wt TO gt_wt_sec.
CLEAR:gs_wt.


ENDCASE.

ENDFORM.
*&---------------------------------------------------------------------*
*& Form WT_TXN
*&---------------------------------------------------------------------*
FORM wt_txn .

CLEAR:gv_flag,gv_start,gv_end,gv_days,gv_check,gv_amt.
"" Start Date Check
IF <fs_tpos>-calc_begin < p_date-low.
gv_start = p_date-low.
ELSE.
gv_start = <fs_tpos>-calc_begin.
ENDIF.

"" End Date Check
IF <fs_tpos>-calc_end > p_date-high.
gv_end = p_date-high.
ELSE.
gv_end = <fs_tpos>-calc_end.
ENDIF.


IF <fs_data>-zsgsart = '10B' OR <fs_data>-zsgsart = '10E' .
ASSIGN gt_cflow[ bukrs = <fs_data>-zbukrs rfha = <fs_data>-zrfha dbervon = <fs_tpos>-calc_begin dberbis = <fs_tpos>-calc_end bzbetr = <fs_tpos>-position_amt ] TO <fs_flow>.
ELSEIF <fs_data>-zsgsart NE '90D' OR <fs_data>-zsgsart NE '90E' OR <fs_data>-zsgsart NE '90H'
OR <fs_data>-zsgsart NE '90I' OR <fs_data>-zsgsart NE '90J' OR <fs_data>-zsgsart NE '90K' .
ASSIGN gt_cflow[ bukrs = <fs_data>-zbukrs rfha = <fs_data>-zrfha dbervon = <fs_tpos>-calc_begin dberbis = <fs_tpos>-calc_end bzbetr = <fs_tpos>-position_amt ] TO <fs_flow>.
ELSE.
ASSIGN gt_cflow[ bukrs = <fs_data>-zbukrs rfha = <fs_data>-zrfha dbervon = <fs_tpos>-calc_begin dberbis = <fs_tpos>-calc_end bzbetr = <fs_tpos>-position_amt ] TO <fs_flow>.
ENDIF.
IF sy-subrc = 0 . "AND <fs_flow> IS ASSIGNED.
""Base Rate and Spread Calculation
IF <fs_flow>-dbervon IS INITIAL .
LOOP AT lt_tmth ASSIGNING FIELD-SYMBOL(<fs_mth>) WHERE bukrs = <fs_data>-zbukrs AND rfha = <fs_data>-zrfha AND dguel_kp LE <fs_flow>-dzterm.

gs_wt-zspread = <fs_mth>-spread .
gs_wt-zbase_rate = <fs_flow>-pkond + <fs_data>-ze_spread - <fs_mth>-spread .
EXIT.
ENDLOOP.
ELSE.
LOOP AT lt_tmth ASSIGNING <fs_mth> WHERE bukrs = <fs_data>-zbukrs AND rfha = <fs_data>-zrfha AND dguel_kp LE <fs_flow>-dbervon.
gs_wt-zspread = <fs_mth>-spread .
gs_wt-zbase_rate = <fs_flow>-pkond + <fs_data>-ze_spread - <fs_mth>-spread .
EXIT.
ENDLOOP.
ENDIF.
""
IF <fs_tpos>-calc_begin IN p_date AND <fs_tpos>-calc_end IN p_date.
"" Use days from condition
gv_days = <fs_flow>-atage.
""If Calc start date not in month & end date is within the report month
ELSEIF <fs_tpos>-calc_begin NOT IN p_date AND <fs_tpos>-calc_end IN p_date.
IF <fs_flow>-sinclbis = 1.
"" End date - 1st of report month; if end date inclusive, +1
TRY. gv_days = <fs_tpos>-calc_end - p_date-low + 1. CATCH cx_sy_arithmetic_error. ENDTRY.
ELSE.
TRY. gv_days = <fs_tpos>-calc_end - p_date-low. CATCH cx_sy_arithmetic_error. ENDTRY.
ENDIF.
"" If Calc end date not in month & start date is within the report month
ELSEIF <fs_tpos>-calc_begin IN p_date AND <fs_tpos>-calc_end NOT IN p_date.
IF <fs_flow>-sexclvon = 0.
"" 1st of next month - Start date; if start date inclusive, +1
IF <fs_tpos>-calc_begin = p_date-high.
TRY. gv_days = gv_snext - <fs_tpos>-calc_begin . CATCH cx_sy_arithmetic_error. ENDTRY.
ELSE.
TRY. gv_days = p_date-high - <fs_tpos>-calc_begin + 1. CATCH cx_sy_arithmetic_error. ENDTRY.
ENDIF.
ELSE.
IF <fs_tpos>-calc_begin <> p_date-high.
TRY. gv_days = gv_snext - <fs_tpos>-calc_begin. CATCH cx_sy_arithmetic_error. ENDTRY.
ENDIF.
ENDIF.
"" If Calc start date & end date are not within the report month
ELSEIF <fs_tpos>-calc_begin NOT IN p_date AND <fs_tpos>-calc_end NOT IN p_date.
"" Days = 1st of next month - 1st of report month
TRY. gv_days = gv_snext - p_date-low. CATCH cx_sy_arithmetic_error. ENDTRY.
ENDIF.
* gv_amt = gv_rol_amt + <fs_flow>-bbasis.
gv_amt = <fs_flow>-bbasis.
CASE <fs_tpos>-product_type.
WHEN '90D' OR '10B' OR '10C' OR '12A' OR '10E' OR '27B'. "27B added by Harish on 26.10.2023
LOOP AT gt_tpos_m INTO DATA(ls_tpos) WHERE trldate GE gv_start AND trldate LE gv_end AND zcategory = 'C05' AND deal_number = gs_data-zrfha AND company_code = gs_data-zbukrs . "for repayment in month
gv_amt = gv_amt + ls_tpos-position_amt.
ENDLOOP.
ENDCASE.

CASE <fs_tpos>-zsgsart .
WHEN '90H'.
DATA: gv_totdays TYPE p.
* gv_amt = <fs_flow>-bbasis.
* gv_days =
gv_totdays = <fs_data>-zdelfz - <fs_data>-zdblfz .
READ TABLE gt_po ASSIGNING FIELD-SYMBOL(<fs_po>) WITH KEY rfha = <fs_tpos>-deal_number bukrs = <fs_tpos>-company_code.
IF sy-subrc = 0 .
TRY. <fs_data>-wei_c = gv_amt * <fs_po>-pwkurs * gv_days / ( gv_mdays * 100 ) . CATCH cx_sy_arithmetic_error. ENDTRY.

TRY. gs_wt-zwei_c = gv_amt * <fs_po>-pwkurs * gv_days / ( gv_mdays * 100 ) . CATCH cx_sy_arithmetic_error. ENDTRY.

* TRY. <fs_data>-wei_int_c = ( gv_amt - <fs_tpos>-position_amt ) * gv_days / 365 . CATCH cx_sy_arithmetic_error. ENDTRY.
" BELOW LINE CHANGED BY ARPAN ON 05.03.2022
TRY. <fs_data>-wei_int_c = ( gv_amt - <fs_tpos>-position_amt ) * gv_days / gv_totdays . CATCH cx_sy_arithmetic_error. ENDTRY.

* TRY. gs_wt-zwei_int_c = gv_amt * gv_days / 365. . CATCH cx_sy_arithmetic_error. ENDTRY.
* TRY. gs_wt-zwei_rate_c = gs_wt-zwei_int_c / gs_wt-zwei_c * c_36500 / gv_mdays. . CATCH cx_sy_arithmetic_error. ENDTRY.
* gs_wt-zwei_rate_c = <fs_data>-wei_int_c.
gs_wt-zwei_int_c = <fs_data>-wei_int_c.
TRY. gs_wt-zwei_rate_c = gs_wt-zwei_int_c / gs_wt-zwei_c * c_365 / gv_mdays. CATCH cx_sy_arithmetic_error. ENDTRY.
ENDIF.

WHEN OTHERS.
"" If Calc start date & end date are within the report month

** Weighted Interest Logic - Coupon Logic
" Wei Amt
TRY. <fs_data>-wei_c = <fs_data>-wei_c + ( gv_amt * gv_days / gv_mdays ). CATCH cx_sy_arithmetic_error. ENDTRY.
TRY. gs_wt-zwei_c = gv_amt * gv_days / gv_mdays . CATCH cx_sy_arithmetic_error. ENDTRY.
gs_wt-zint_rate_c = <fs_flow>-pkond + <fs_data>-ze_spread.
TRY. <fs_data>-wei_int_c = <fs_data>-wei_int_c + ( gv_amt * gv_days * gs_wt-zint_rate_c / c_36500 ). CATCH cx_sy_arithmetic_error. ENDTRY. "36500
TRY. gs_wt-zwei_int_c = gv_amt * gv_days * gs_wt-zint_rate_c / c_36500. CATCH cx_sy_arithmetic_error. ENDTRY. "36500 .
"" Weigthed Interest Rate
TRY. gs_wt-zwei_rate_c = gs_wt-zwei_int_c / gs_wt-zwei_c * c_36500 / gv_mdays. CATCH cx_sy_arithmetic_error. ENDTRY. "36500

ENDCASE.
* gs_wt-zbase_rate = <fs_flow>-pkond .
* gs_wt-zspread = <fs_data>-ze_spread .

"" Movement Type for appending the table
IF ( <fs_tpos>-calc_begin IN p_date AND <fs_tpos>-calc_end IN p_date ) .
IF gv_mamt IS INITIAL.
gs_wt-zm_amt = gv_amt.
gs_wt-zm_stat = 'A'.
ELSE.
gs_wt-zm_amt = gv_amt - gv_mamt.
IF gs_wt-zm_amt > 0.
gs_wt-zm_stat = 'A'.
ELSEIF gs_wt-zm_amt < 0.
gs_wt-zm_amt = abs( gs_wt-zm_amt ).
gs_wt-zm_stat = 'R'.
ELSE.
CLEAR:gs_wt-zm_amt.
ENDIF.
ENDIF.
ENDIF.

* "Margin Amount
* IF <fs_data>-mrg_rate IS NOT INITIAL.
* TRY. <fs_data>-mrg_amt = <fs_data>-mrg_amt + ( ( <fs_data>-wei_c * <fs_data>-mrg_rate * gv_days ) / c_36000 ) . CATCH cx_sy_arithmetic_error. ENDTRY.
* ENDIF.


"" Updating the Details to the table for Pop-up for the FM
gv_mamt = gv_amt.
gs_wt-zbukrs = <fs_data>-zbukrs.
gs_wt-zrfha = <fs_data>-zrfha.
gs_wt-zdate = <fs_tpos>-trldate.
gs_wt-zsdate = gv_start.
gs_wt-zedate = gv_end.
gs_wt-zdays = gv_days.
gs_wt-zamt = gv_amt.
APPEND gs_wt TO gt_wt. "" FM internal table
CLEAR:gs_wt,gv_rol_amt,gv_flg.
ENDIF.

ENDFORM.
*&---------------------------------------------------------------------*
*& Form WT_REPLACE
*&---------------------------------------------------------------------*
FORM wt_replace .

ENDFORM.
*&---------------------------------------------------------------------*
*& Form SUB_TOTAL
*&---------------------------------------------------------------------*
FORM sub_total .

TRY. gs_stot-wei_rate_c = gs_stot-wei_int_c / gs_stot-wei_c * c_36500 / gv_mdays. CATCH cx_sy_arithmetic_error. ENDTRY. "36500

TRY. gs_stot-open_amt = gs_stot-open_amt / gv_div . CATCH cx_sy_arithmetic_error. ENDTRY.
TRY. gs_stot-close_amt = gs_stot-close_amt / gv_div . CATCH cx_sy_arithmetic_error. ENDTRY.
TRY. gs_stot-add_amt = gs_stot-add_amt / gv_div . CATCH cx_sy_arithmetic_error. ENDTRY.
TRY. gs_stot-red_amt = gs_stot-red_amt / gv_div . CATCH cx_sy_arithmetic_error. ENDTRY.
TRY. gs_stot-wei_c = gs_stot-wei_c / gv_div . CATCH cx_sy_arithmetic_error. ENDTRY.
TRY. gs_stot-wei_int_c = gs_stot-wei_int_c / gv_div . CATCH cx_sy_arithmetic_error. ENDTRY.

* IF gs_stot-mrg_amt IS NOT INITIAL.
* TRY. gs_stot-mrg_rate = gs_stot-mrg_amt / gs_stot-wei_c * 100. CATCH cx_sy_arithmetic_error. ENDTRY.
* ENDIF.
* TRY. gs_stot-lbr_rate = gs_stot-wei_rate_c - gs_stot-mrg_rate. CATCH cx_sy_arithmetic_error. ENDTRY.
TRY. gs_stot-ze_final = gv_stamt / gs_stot-close_amt. CATCH cx_sy_arithmetic_error. ENDTRY.
gs_stot-zsgsart = <fs_data>-zsgsart && '-' && 'T'.
gs_stot-zprd_desc = <fs_data>-zprd_desc.
gs_stot-color = 'C300'. " VALUE #( ( fname = '' color-col = 3 color-int = 0 ) ).
gs_stot-zbukrs = 'T'.
APPEND gs_stot TO gt_stot.

"Subtotal based on Type for export internal table
gs_stot-zsgsart = <fs_data>-zsgsart.
APPEND gs_stot TO gt_dd.

CLEAR:gs_stot, gv_stamt.

ENDFORM.
*&---------------------------------------------------------------------*
*& Form TOTAL
*&---------------------------------------------------------------------*
FORM total .

TRY. gs_tot-wei_rate_c = gs_tot-wei_int_c / gs_tot-wei_c * c_36500 / gv_mdays. CATCH cx_sy_arithmetic_error. ENDTRY. "36500
* IF gs_tot-mrg_amt IS NOT INITIAL.
* TRY. gs_tot-mrg_rate = gs_tot-mrg_amt / gs_tot-wei_c * 100. CATCH cx_sy_arithmetic_error. ENDTRY.
* ENDIF.
* TRY. gs_tot-lbr_rate = gs_tot-wei_rate_c - gs_tot-mrg_rate. CATCH cx_sy_arithmetic_error. ENDTRY.
TRY. gs_tot-ze_final = gv_tamt / gs_tot-close_amt. CATCH cx_sy_arithmetic_error. ENDTRY.

TRY. gs_tot-open_amt = gs_tot-open_amt / gv_div . CATCH cx_sy_arithmetic_error. ENDTRY.
TRY. gs_tot-close_amt = gs_tot-close_amt / gv_div . CATCH cx_sy_arithmetic_error. ENDTRY.
TRY. gs_tot-add_amt = gs_tot-add_amt / gv_div . CATCH cx_sy_arithmetic_error. ENDTRY.
TRY. gs_tot-red_amt = gs_tot-red_amt / gv_div . CATCH cx_sy_arithmetic_error. ENDTRY.
TRY. gs_tot-wei_c = gs_tot-wei_c / gv_div . CATCH cx_sy_arithmetic_error. ENDTRY.
TRY. gs_tot-wei_int_c = gs_tot-wei_int_c / gv_div . CATCH cx_sy_arithmetic_error. ENDTRY.


gs_tot-zbukrs = 'T'.
gs_tot-zsgsart = 'T'.
gs_tot-zprd_desc = 'Z-Total'.
* gs_tot-color = 'C310'.
gs_tot-color = 'C310'. "VALUE #( ( fname = '' color-col = 3 color-int = 1 ) ).

APPEND gs_tot TO gt_tot.

"Subtotal based on Type for export internal table
APPEND gs_tot TO gt_dd.

CLEAR:gs_tot, gv_tamt.

ENDFORM.
*&---------------------------------------------------------------------*
*& Form COLLECT
*&---------------------------------------------------------------------*
FORM collect .
"Sub Total
TRY. gs_stot-open_amt = gs_stot-open_amt + <fs_data>-open_amt. CATCH cx_sy_arithmetic_error. ENDTRY.
TRY. gs_stot-add_amt = gs_stot-add_amt + <fs_data>-add_amt. CATCH cx_sy_arithmetic_error. ENDTRY.
TRY. gs_stot-red_amt = gs_stot-red_amt + <fs_data>-red_amt. CATCH cx_sy_arithmetic_error. ENDTRY.
TRY. gs_stot-close_amt = gs_stot-close_amt + <fs_data>-close_amt. CATCH cx_sy_arithmetic_error. ENDTRY.
TRY. gs_stot-wei_c = gs_stot-wei_c + <fs_data>-wei_c. CATCH cx_sy_arithmetic_error. ENDTRY.
TRY. gs_stot-wei_int_c = gs_stot-wei_int_c + <fs_data>-wei_int_c. CATCH cx_sy_arithmetic_error. ENDTRY.
* TRY. gs_stot-mrg_amt = gs_stot-mrg_amt + <fs_data>-mrg_amt. CATCH cx_sy_arithmetic_error. ENDTRY.
TRY. gv_stamt = gv_stamt + ( <fs_data>-close_amt * <fs_data>-ze_final ). CATCH cx_sy_arithmetic_error. ENDTRY.

"Total
TRY. gs_tot-open_amt = gs_tot-open_amt + <fs_data>-open_amt. CATCH cx_sy_arithmetic_error. ENDTRY.
TRY. gs_tot-add_amt = gs_tot-add_amt + <fs_data>-add_amt. CATCH cx_sy_arithmetic_error. ENDTRY.
TRY. gs_tot-red_amt = gs_tot-red_amt + <fs_data>-red_amt. CATCH cx_sy_arithmetic_error. ENDTRY.
TRY. gs_tot-close_amt = gs_tot-close_amt + <fs_data>-close_amt. CATCH cx_sy_arithmetic_error. ENDTRY.
TRY. gs_tot-wei_c = gs_tot-wei_c + <fs_data>-wei_c. CATCH cx_sy_arithmetic_error. ENDTRY.
TRY. gs_tot-wei_int_c = gs_tot-wei_int_c + <fs_data>-wei_int_c. CATCH cx_sy_arithmetic_error. ENDTRY.
* TRY. gs_tot-mrg_amt = gs_tot-mrg_amt + <fs_data>-mrg_amt. CATCH cx_sy_arithmetic_error. ENDTRY.
TRY. gv_tamt = gv_tamt + ( <fs_data>-close_amt * <fs_data>-ze_final ). CATCH cx_sy_arithmetic_error. ENDTRY.

ENDFORM.
     
 
what is notes.io
 

Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 14 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.