NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

*&---------------------------------------------------------------------*
*& Form PROCESS_DATA
*&---------------------------------------------------------------------*
FORM process_data .

DATA: lv_index TYPE sy-tabix,
ls_vts_cf_irate TYPE vts_cf_irate.

IF p_l1 IS NOT INITIAL.
DELETE gt_data WHERE zact_l1 NE p_l1.
ENDIF.

IF gt_data IS NOT INITIAL.


"Fetching Interest Calculation Method
SELECT rkey1, szbmeth
FROM vzzkoko
INTO TABLE @DATA(lt_mth)
FOR ALL ENTRIES IN @gt_data
WHERE rkey1 = @gt_data-zranl.

*19.03.2024
"Fetching Interest Rate Calculation Method for transaction
****************** SELECT bukrs, rfha, pkond, szbmeth, szsref, pkond1stper, dguel_kp, spread
****************** FROM zfsborv_rr
****************** INTO TABLE @lt_tmth
****************** FOR ALL ENTRIES IN @gt_data
****************** WHERE bukrs = @gt_data-zbukrs
****************** AND rfha = @gt_data-zrfha
****************** AND rfhazu = @gt_data-zrfhazul
****************** AND dguel_kp <= @p_date-high
****************** AND rkond = @cs_c1000.
******************
****************** SORT lt_tmth BY bukrs rfha dguel_kp DESCENDING.
******************
ENDIF.



*----------------------Looping in Final Table---------------------------------------*

CLEAR: gv_stamt , gv_tamt, gt_dd, gs_tot, gt_tot, gs_stot, gt_stot.
SORT gt_data BY zsgsart .
UNASSIGN <fs_data>.
DATA : gs_rfha TYPE vtbfha-rfha.
LOOP AT gt_data ASSIGNING <fs_data>.
gs_rfha = <fs_data>-zrfha.

READ TABLE lt_finko ASSIGNING FIELD-SYMBOL(<fs_finko>) WITH KEY bukrs = <fs_data>-zbukrs rfha = <fs_data>-zrfha .
IF sy-subrc = 0.
<fs_data>-szsref = <fs_finko>-szsref .
ENDIF.

IF <fs_data>-zranl IS INITIAL.

"No of Days
ASSIGN lt_tmth[ bukrs = <fs_data>-zbukrs rfha = <fs_data>-zrfha ] TO FIELD-SYMBOL(<ls_tmth>).
IF sy-subrc = 0.

IF <ls_tmth>-pkond IS NOT INITIAL.
<fs_data>-ze_rate = <ls_tmth>-pkond.
<fs_data>-zrate_type = c_fixed.
ELSE.
<fs_data>-ze_rate = <ls_tmth>-pkond1stper.
<fs_data>-zrate_type = c_floating.
* <fs_data>-zref_rate = <ls_tmth>-szsref.
* <fs_data>-ze_spread = <ls_tmth>-spread.
ENDIF.

ENDIF.

ELSE.
<fs_data>-zrate_type = c_floating.
ENDIF.

"" No.of Days all the 4 Different Date logic
IF <fs_data>-zdblfz >= p_date-low AND <fs_data>-zdelfz <= p_date-high.
TRY. <fs_data>-no_days = <fs_data>-zdelfz - <fs_data>-zdblfz. CATCH cx_sy_arithmetic_error. ENDTRY.
ELSEIF <fs_data>-zdblfz >= p_date-low AND <fs_data>-zdelfz > p_date-high.
TRY. <fs_data>-no_days = p_date-high - <fs_data>-zdblfz + 1. CATCH cx_sy_arithmetic_error. ENDTRY.
ELSEIF <fs_data>-zdblfz < p_date-low AND <fs_data>-zdelfz > p_date-high.
TRY. <fs_data>-no_days = p_date-high - p_date-low + 1. CATCH cx_sy_arithmetic_error. ENDTRY.
ELSEIF <fs_data>-zdblfz < p_date-low AND <fs_data>-zdelfz <= p_date-high.
TRY. <fs_data>-no_days = <fs_data>-zdelfz - p_date-low. CATCH cx_sy_arithmetic_error. ENDTRY.
ENDIF.


* TRY. <fs_data>-ze_final = <fs_data>-ze_rate + <fs_data>-ze_spread. CATCH cx_sy_arithmetic_error. ENDTRY.

"" Opening ,addition,redemption Amt
IF <fs_data>-zranl IS INITIAL.
"" Parallel cursor method
CLEAR:lv_index, gv_count.
gv_count = 1.
READ TABLE gt_tpos_m ASSIGNING <fs_tpos> WITH KEY company_code = <fs_data>-zbukrs deal_number = <fs_data>-zrfha BINARY SEARCH.
IF sy-subrc = 0.
lv_index = sy-tabix.
LOOP AT gt_tpos_m ASSIGNING <fs_tpos> FROM lv_index. "WHERE ( zcategory = c_c03 OR zcategory = c_c04 OR zcategory = c_c05 OR zcategory = c_c07 )
IF <fs_tpos>-company_code = <fs_data>-zbukrs AND <fs_tpos>-deal_number = <fs_data>-zrfha.
ELSE.
EXIT.
ENDIF.

CLEAR gv_amt_c.
IF <fs_tpos>-sign = '-'.
TRY. gv_amt_c = <fs_tpos>-position_amt * ( - 1 ). CATCH cx_sy_arithmetic_error. ENDTRY.
ELSE.
gv_amt_c = <fs_tpos>-position_amt.
ENDIF.

IF gv_flg IS INITIAL.
IF <fs_tpos>-nominal_amt > 0 AND <fs_tpos>-zcategory = c_c03 AND <fs_data>-zsanlf = cs_550
AND ( <fs_data>-zsfgzustt = cs_11 OR <fs_data>-zsfgzustt = cs_21 ).
gv_rol_amt = <fs_tpos>-nominal_amt.
gv_flg = abap_true.
ENDIF.
ENDIF.
IF <fs_tpos>-zsgsart = '90H' . "CHANGE GV_AMTC AND PASS NOMINAL AMT
* gv_amt = <fs_tpos>-nominal_amt .
gv_amt_c = <fs_tpos>-nominal_amt .
ENDIF.


IF <fs_tpos>-trldate < p_date-low AND <fs_tpos>-zcategory = c_c03.
TRY. <fs_data>-open_amt = <fs_data>-open_amt + gv_amt_c. CATCH cx_sy_arithmetic_error. ENDTRY.
ELSEIF <fs_tpos>-trldate BETWEEN p_date-low AND p_date-high.
CASE <fs_tpos>-zcategory.
WHEN c_c04.
TRY. <fs_data>-add_amt = <fs_data>-add_amt + gv_amt_c. CATCH cx_sy_arithmetic_error. ENDTRY.
WHEN c_c05.
TRY. <fs_data>-red_amt = abs( <fs_data>-red_amt ) + abs( gv_amt_c ). CATCH cx_sy_arithmetic_error. ENDTRY.
ENDCASE.
ENDIF.
"Weighted Calculation for Transaction
* CASE <fs_tpos>-sgsart.
* WHEN '90H'.
* IF <fs_tpos>-trldate <= p_date-high.
* CASE <fs_tpos>-zcategory.
* WHEN c_c03 OR c_c08 OR c_c09 OR c_c10 OR c_c11.
* PERFORM wt_replace .
* ENDCASE.
* ENDIF.
* WHEN OTHERS.
IF ( ( <fs_tpos>-calc_begin <= p_date-low AND <fs_tpos>-calc_end >= p_date-high )
OR ( <fs_tpos>-calc_begin IN p_date )
OR ( <fs_tpos>-calc_end IN p_date ) )
AND ( <fs_tpos>-zcategory = c_c07 ).
PERFORM wt_txn .
ENDIF.
* ENDCASE.

ENDLOOP.
ENDIF.
ELSE.
"" Parallel cursor method
CLEAR: gv_amt, gv_count.
gv_count = 1.
CLEAR:gv_date, gv_count, gv_mamt, gv_wt_amt,gv_wt_int,gv_amt.

CLEAR:lv_index.
READ TABLE gt_tpos_s ASSIGNING <fs_tpos> WITH KEY company_code = <fs_data>-zbukrs security_id = <fs_data>-zranl BINARY SEARCH.
IF sy-subrc = 0.
lv_index = sy-tabix.
LOOP AT gt_tpos_s ASSIGNING <fs_tpos> FROM lv_index. "AND ( zcategory = c_c03 OR zcategory = c_c04 OR zcategory = c_c05 ).
IF <fs_tpos>-company_code = <fs_data>-zbukrs AND <fs_tpos>-security_id = <fs_data>-zranl.

ELSE.
EXIT.
ENDIF.

CLEAR gv_amt_c.
IF <fs_tpos>-sign = '-'.
TRY. gv_amt_c = <fs_tpos>-position_amt * ( - 1 ). CATCH cx_sy_arithmetic_error. ENDTRY.
ELSE.
* IF <fs_tpos>-sgsart NE c_15b AND <fs_tpos>-zsfhaart NE '310'.
* gv_amt_c = <fs_tpos>-position_amt.
* ELSEIF <fs_tpos>-sgsart EQ c_15b AND <fs_tpos>-zsfhaart EQ '310'.
* gv_amt_c = <fs_tpos>-nominal_amt.
* ENDIF.
IF <fs_tpos>-product_type EQ c_15b AND <fs_tpos>-zsfhaart EQ '310'.
gv_amt_c = <fs_tpos>-nominal_amt.
ELSE.
gv_amt_c = <fs_tpos>-position_amt.
ENDIF.
ENDIF.

IF <fs_tpos>-trldate < p_date-low AND <fs_tpos>-zcategory = c_c03.
TRY. <fs_data>-open_amt = <fs_data>-open_amt + gv_amt_c. CATCH cx_sy_arithmetic_error. ENDTRY.
ELSEIF <fs_tpos>-trldate BETWEEN p_date-low AND p_date-high."<fs_tpos>-trldate LT p_date-high.
CASE <fs_tpos>-zcategory.
WHEN c_c04.
"IF <fs_tpos>-trldate BETWEEN p_date-low AND p_date-high.
TRY. <fs_data>-add_amt = <fs_data>-add_amt + gv_amt_c. CATCH cx_sy_arithmetic_error. ENDTRY.
"ENDIF.
WHEN c_c05.
TRY. <fs_data>-red_amt = abs( <fs_data>-red_amt ) + abs( gv_amt_c ). CATCH cx_sy_arithmetic_error. ENDTRY.
ENDCASE.
ENDIF.
"Weighted Calculation for Class ID

IF ( <fs_data>-zsgsart = '15A' OR <fs_data>-zsgsart = '15C' ) AND <fs_tpos>-zcategory = c_c09.
CASE <fs_tpos>-zcategory.
WHEN c_c03 OR c_c08 OR c_c09 OR c_c10 OR c_c11.
PERFORM wt_class2 .
ENDCASE.
ELSE.
IF <fs_tpos>-trldate <= p_date-high.
CASE <fs_tpos>-zcategory.
WHEN c_c03 OR c_c08 OR c_c09 OR c_c10 OR c_c11.
PERFORM wt_class .
ENDCASE.
ENDIF.
ENDIF.

ENDLOOP.
ENDIF.
ENDIF.


"Rate
IF <fs_data>-zranl IS NOT INITIAL.
TRY. <fs_data>-ze_rate = gv_wt_int / gv_wt_amt * c_36500 / gv_mdays. CATCH cx_sy_arithmetic_error. ENDTRY. "36500
TRY. <fs_data>-ze_final = gv_wt_int / gv_wt_amt * c_36500 / gv_mdays. CATCH cx_sy_arithmetic_error. ENDTRY. "36500
IF <fs_data>-ze_rate > 999 OR <fs_data>-ze_rate < -999.
<fs_data>-ze_rate = 0 .
ENDIF.
IF <fs_data>-ze_final > 999 OR <fs_data>-ze_final < -999.
<fs_data>-ze_rate = 0 .
ENDIF.
ENDIF.

""Closing Amt
TRY. <fs_data>-close_amt = ( <fs_data>-open_amt + <fs_data>-add_amt ) - <fs_data>-red_amt. CATCH cx_sy_arithmetic_error. ENDTRY.
"WAC.
TRY. <fs_data>-wei_rate_c = <fs_data>-wei_int_c / <fs_data>-wei_c * c_36500 / gv_mdays. CATCH cx_sy_arithmetic_error. ENDTRY. " 36500 .

" Amount Conversion
* TRY. <fs_data>-open_amt = <fs_data>-open_amt / gv_div. CATCH cx_sy_arithmetic_error. ENDTRY.
* TRY. <fs_data>-add_amt = <fs_data>-add_amt / gv_div. CATCH cx_sy_arithmetic_error. ENDTRY.
* TRY. <fs_data>-red_amt = <fs_data>-red_amt / gv_div. CATCH cx_sy_arithmetic_error. ENDTRY.
* TRY. <fs_data>-close_amt = <fs_data>-close_amt / gv_div. CATCH cx_sy_arithmetic_error. ENDTRY.
* TRY. <fs_data>-wei_c = <fs_data>-wei_c / gv_div. CATCH cx_sy_arithmetic_error. ENDTRY.
* TRY. <fs_data>-wei_int_c = <fs_data>-wei_int_c / gv_div. CATCH cx_sy_arithmetic_error. ENDTRY.

"Color
* PERFORM style_color CHANGING <fs_data>-color.
PERFORM collect.
"Sub Total based on Type
* ON CHANGE OF <fs_data>-zact_l1.
* PERFORM sub_total.
* ENDON.
TRY. <fs_data>-open_amt = <fs_data>-open_amt / gv_div. CATCH cx_sy_arithmetic_error. ENDTRY. """
TRY. <fs_data>-add_amt = <fs_data>-add_amt / gv_div. CATCH cx_sy_arithmetic_error. ENDTRY.
TRY. <fs_data>-red_amt = <fs_data>-red_amt / gv_div. CATCH cx_sy_arithmetic_error. ENDTRY.
TRY. <fs_data>-close_amt = <fs_data>-close_amt / gv_div. CATCH cx_sy_arithmetic_error. ENDTRY.
TRY. <fs_data>-wei_c = <fs_data>-wei_c / gv_div. CATCH cx_sy_arithmetic_error. ENDTRY.
TRY. <fs_data>-wei_int_c = <fs_data>-wei_int_c / gv_div. CATCH cx_sy_arithmetic_error. ENDTRY. """


AT END OF zsgsart.
PERFORM sub_total.
ENDAT.
"Total
AT LAST.
PERFORM total.
ENDAT.

IF <fs_data>-zranl IS NOT INITIAL.
CLEAR <fs_data>-zrfha.
ENDIF.

ENDLOOP.
* DELETE gt_data WHERE wei_rate_c IS INITIAL.
gt_act = gt_data.
EXPORT gt_act TO MEMORY ID 'GT_DATA'.

APPEND LINES OF gt_stot TO gt_data.
APPEND LINES OF gt_tot TO gt_data.
SORT gt_data BY zsgsart zrfha DESCENDING zranl DESCENDING.
CLEAR: gt_stot, gt_tot.

* DELETE gt_data WHERE open_amt IS INITIAL AND add_amt IS INITIAL AND red_amt IS INITIAL AND close_amt IS INITIAL.
* DELETE gt_dd WHERE open_amt IS INITIAL AND add_amt IS INITIAL AND red_amt IS INITIAL AND close_amt IS INITIAL.


"Export Internal table
EXPORT gt_dd TO MEMORY ID 'GT_DD'.
gt_dd1[] = gt_dd[].
EXPORT gt_dd1 TO MEMORY ID 'GT_DD1'.

IF p_save EQ abap_true.
* PERFORM save_data.
* PERFORM save_data1 .
ENDIF.

ENDFORM. " PROCESS_DATA
     
 
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.