Debug example for SWAP valuation in TPM1
This document was created by my mentor (he is sailing in the Pacific now).
In TPM1 we can set break point in CL_COMMON_VALUATOR_VAL->PROCESS where we can go to the steps that set in PMP.
Swap valuation for forward (FX) transactions
example P7F/000/0001/6452, TPM1 variant 6452
CL_COMMON_VALUATOR_VAL->PROCESS
* Get position info
CALL METHOD assessable_position->get_diff_values
* value the position in different steps
LOOP AT tab_valuation_step INTO l_valuation_step.
-> process each step and updates Accumulator with new values
1st step, i.e. Rate valuation
CL_FX_RATE_VAL-> DETERMINE_CALCULATION_BASIS
* get data of the deal
CALL FUNCTION ‘TB_DATA_GET_FOR_VALUATION_FX’
Calculates forward and spot values and out of it the swap value
* swap in to-currency
IF ex_to_curr = ex_purchase_curr.
ex_swap_fc = ex_fov_pc – ex_spv_pc.
ELSEIF ex_to_curr = ex_sale_curr.
ex_swap_fc = ex_fov_sc – ex_spv_sc.
ENDIF.
-> calc_basis-margin_swap_vc 1481.48
CL_FX_RATE_VAL->CALCULATE
gets it from USD (sell) spot amount converted into EUR and
from current market value in USD converted into EUR
l_rate_s 1.35160-
l_conversion_from_sc 198283.52 (= 268000 / 1.35160)
l_conversion_from_pc 198518.52 (= 268000 / 1.35000)
-> calc_basis-obv_ec_vc 235.00
-> then some checks come
2nd step, i.e. Swap valuation
CL_SWAP_VALUATION_VAL->DETERMINE_CALCULATION_BASIS
-> checks customizing and read necessary accumulator values and market values
-> also calculates swap rate
TB_EVALUATION_SWAPRATE_FIND
“/ wenn das Währungspaar schon im Puffer ist werden diese Sätze *
“/ genommen, sonst auf die Datenbank *
IF LOC_AT15[] IS INITIAL.
SELECT * FROM AT15
TB_EVALUATION_SWAP_INTEROLATE
* Die Laufzeit für den Swap ist nicht zwischen keydate und Fälligkeit
* sondern zwischen Spotvaluta und Fälligkeit 4.5A
(it means, it adjusts the key date with spot days for the currency pair from the customizing)
-> SPOT_STICH.
“/ Laufzeit für Swapsatztabelle in Tagen
CASE IM_FLG_PROLONG_EARLY_SET.
-> SAVE_LFZ
“/ kürzerer Swappsatz/Laufzeit lesen
-> SWAP_KURZ & SAVE_LFZ_KURZ
“/ längeren Swappsatz/Laufzeit lesen
- SWAP_LANG & SAVE_LFZ_LANG
It may happen that the key date is between contract date and spot date or spot date is after maturity (value) date (“negative days”), then swaprate is zero.
If there are no swap rates maintained in AT15, then for missing rates it takes zero.
“/ Interpolieren
SWAPRATE = ( SWAP_LANG – SWAP_KURZ ) * ( SAVE_LFZ – SAVE_LFZ_KURZ ) /
( SAVE_LFZ_LANG – SAVE_LFZ_KURZ ) + SWAP_KURZ.
SWAPRATE 0.04967-
CL_SWAP_VALUATION_VAL-> DETERMINE_CALCULATION_BASIS
calc_basis-mar_swapps 0.04967-
- 3. determine market forward rate
-> l_rate_from2to 1.30193- (= 1.35160- – 0.04967-)
CALL FUNCTION ‘CONVERSION_WITH_RATE_F’
l_amount_lc 205848.24 (=268000/1.30193)
l_amount_fc 268000.00
calc_basis-mar_swap_fc 10224.48 (205848.24 * 0.04967)
calc_basis-mar_swap_vc 7564.72 (10224.48 converted to local currency)
CL_SWAP_VALUATION_VAL->IF_VALUATION_STEP_VAL~VALUE
* calculate write up/down and new Book Values for long positions;
* no calculation for zero/short/inconsistent positions
CL_SWAP_VALUATION_VAL->CALCULATE
* write up/down in valuation currency
write_up_down-swap_val_vc = l_book_swap_vc – calc_basis-mar_swap_vc.
write_up_down-swap_val_vc 6083.24- (= 1481.48 – 7564.72)
new_data-nbv_ec_vc 5848.24- (= 6083.24- + 235.00)
New NetWeaver Information at SAP.com
Very Helpfull