method IF_EX_FAA_DC_CUSTOMER~DEFINE_CHANGEOVER_YR. * Customer-defined changeover method for Japan: * set change-over year when depreciation by declined-balance * is less than depreciation with guarantee rate. CONSTANTS: lc_country(2) TYPE c VALUE 'JP', c_con_z(1) TYPE c VALUE 'Z', lc_year2012 TYPE bf_zujahr VALUE '2012'. FIELD-SYMBOLS: TYPE faa_ee_s_yearseg, TYPE faa_dc_s_hlpseg, TYPE t097jp, TYPE t093b. "Note 1673771/OSS#677828 DATA: ld_sum_apc TYPE f, ld_nbv TYPE f, ld_nbv_p TYPE p, "Note 1673771/OSS#677828 ld_useful_life TYPE faa_dc_useful_life , * ld_guar_rate TYPE p DECIMALS 10, "Note 1673771/OSS#677828 * ld_decl_rate TYPE p DECIMALS 10, "Note 1673771/OSS#677828 ld_guar_rate TYPE f, "Note 1673771/OSS#677828 ld_decl_rate TYPE f, "Note 1673771/OSS#677828 l_abs_dbm TYPE p DECIMALS 2, l_abs_guar TYPE p DECIMALS 2, lt_t097jp TYPE TABLE OF t097jp, * note 1078301(b) lt_anlbzw TYPE TABLE OF anlbzw , ls_anlbzw TYPE anlbzw, ls_anlbzw_new TYPE anlbzw, i_afabe TYPE afabe_d, lv_bzwprz TYPE ANLBZW-BZWPRZ, lv_bzwprz_f TYPE f, lv_action TYPE cdchngind. FIELD-SYMBOLS: TYPE anlbzw. * note 1078301(e) data: lt_t093b TYPE TABLE OF t093b, "Note 1673771 l_abs_guar_calc TYPE f, "Note 1673771/OSS#677828 l_abs_dbm_calc TYPE f, "Note 1673771/OSS#677828 l_abs_guar_rnd TYPE f, "Note 1673771 l_abs_dbm_rnd TYPE f. "Note 1673771 * This method valid only for Japan CHECK io_handle->mo_leadobj->msx_settings-country = lc_country. CASE is_hlpseg-keyref->ms_settings-changeover_meth. WHEN c_con_z. * Change over method Z * check that the asset is acquired from 01.04.2012 * CHECK: * this check may be not necessary * io_handle->mo_assetdata->ms_basic-initial_acq_yr * >= lc_year2012. LOOP AT io_handle->mts_hlpseg ASSIGNING WHERE keyref->ms_settings-changeover_meth CA c_con_z AND area EQ is_hlpseg-area AND changeover_yr IS INITIAL AND use_max_periods IS INITIAL. * Make sure that no changeover year exist in asset master CHECK -changeover_yr IS INITIAL. * Make sure the depreciation phase is initial. CHECK -phase EQ '1'. READ TABLE io_handle->mt_yearseg ASSIGNING WITH KEY fyear = -fyear area = -area. CLEAR ld_sum_apc. CLEAR ld_nbv. * calculate value of asset at the beginning of the year ld_sum_apc = -cum-apc + -cum-invs + -cum-downp + -cum-resv. " Start of changes to read Item Manager for capitalized assets - Note 1549398 FIELD-SYMBOLS : TYPE faa_dc_sx_item, TYPE faa_dc_sx_item_area, TYPE faa_dc_s_item_amount, TYPE faa_dc_sx_item_amountid. DATA lv_capitalized TYPE string. IF ld_sum_apc = 0. LOOP AT io_handle->mo_item_mngr->mts_dc_item ASSIGNING WHERE classification = '15' AND fyear = -fyear. lv_capitalized = 'X'. LOOP AT -t_area ASSIGNING WHERE area = -area. LOOP AT -t_amountid ASSIGNING WHERE ( amountid = 'APC' OR amountid = 'INVS' OR amountid = 'DOWNP' OR amountid = 'RESV' ). LOOP AT -t_amount ASSIGNING . ld_sum_apc = -amount + ld_sum_apc . ENDLOOP. ENDLOOP. ENDLOOP. ENDLOOP. endif. " End of changes to read Item Manager for capitalized assets - Note 1549398 * change over check only if asset has value at all CHECK ld_sum_apc <> 0. * calculate net book value of asset at the beginning of the year ld_nbv = ld_sum_apc + -cum-depr_o + -cum-depr_s + -cum-depr_u + -cum-revl_d + -cum-revl. " Start of changes to read Item Manager for capitalized assets - Note 1549398 IF lv_capitalized = 'X'. LOOP AT -t_area ASSIGNING WHERE area = -area. LOOP AT -t_amountid ASSIGNING WHERE ( amountid = 'PREV-DEPR_O' OR amountid = 'PREV-DEPR_S' OR amountid = 'PREV-DEPR_U' OR amountid = 'PREV-DEPR_D' OR amountid = 'REVL' ). LOOP AT -t_amount ASSIGNING . ld_nbv = -amount + ld_nbv . ENDLOOP. ENDLOOP. ENDLOOP. ENDIF. " End of changes to read Item Manager for capitalized assets - Note 1549398 * Read Anex10 depreciation rates from T097JP * according to useful life ld_useful_life = -useful_life DIV -periods. IF ld_useful_life < 2. ld_useful_life = 2. ENDIF. SELECT * FROM t097jp INTO TABLE lt_t097jp WHERE ndjar = ld_useful_life. IF sy-subrc = 0. ENDIF. IF sy-subrc <> 0. MESSAGE ID 'AA' TYPE 'E' NUMBER '773' WITH ld_useful_life. EXIT. ENDIF. READ TABLE lt_t097jp ASSIGNING WITH KEY ndjar = ld_useful_life. CHECK IS ASSIGNED. ld_decl_rate = -proz_tw3. ld_guar_rate = -proz_gr3. ** 200% DBM rate - calculate "Note 1673771/OSS#677828(s) * l_abs_dbm = ( ld_nbv ) * ld_decl_rate. * l_abs_dbm = ABS( l_abs_dbm ). * check l_abs_dbm > 0 . ** guarantee rate - calculate * l_abs_guar = ( ld_sum_apc ) * ld_guar_rate. * l_abs_guar = ABS( l_abs_guar ). ** set change-over year when guarantee rate is higher. * IF l_abs_guar > l_abs_dbm. * cd_changeover_yr = -fyear. * Calculate the DBM depreciation amount before adjustment and * guarantee depreciation amount BEFORE ROUNDING !!! l_abs_dbm_rnd = ( ld_nbv ) * ld_decl_rate. l_abs_guar_rnd = ( ld_sum_apc ) * ld_guar_rate. * Convert the absolute amount. l_abs_dbm_rnd = ABS( l_abs_dbm_rnd ). l_abs_guar_rnd = ABS( l_abs_guar_rnd ). * Get the rounding method SELECT * FROM t093b INTO TABLE lt_t093b * WHERE basrnd = 1. where bukrs = io_handle->mo_leadobj->md_leadobj and afabe = -area. IF sy-subrc = 0. ENDIF. IF sy-subrc <> 0. EXIT. ENDIF. READ TABLE lt_t093B ASSIGNING * WITH KEY basrnd = 1. WITH KEY bukrs = io_handle->mo_leadobj->md_leadobj. IF IS ASSIGNED. "2012.04.05,v03 data: lv_runden type FAA_EE_DECIMALS. lv_runden = -runden. l_abs_dbm_calc = l_abs_dbm_rnd. l_abs_guar_calc = l_abs_guar_rnd. * adjust calculated amounts to suppress inaccuracy of floating amounts IF -runden > 0. "> 1296925 * move amount by zero decimals to execute a first * (commercial) rounding CALL METHOD cl_faa_ee=>_round_value_prev EXPORTING id_place = 2 id_decimals = 0 id_method = '0' CHANGING cd_value = l_abs_dbm_rnd cd_value_add = l_abs_guar_rnd. ENDIF. "> 1296925 CALL METHOD cl_faa_ee=>_round_value_prev EXPORTING id_place = 2 id_decimals = lv_runden id_method = -metrnd CHANGING cd_value = l_abs_dbm_rnd cd_value_add = l_abs_guar_rnd. * note 1093591 * if the result of previous rounding was not correct * because of calculations with binary floating point numbers * it should be corrected here CALL METHOD cl_faa_ee=>_correct_rounding EXPORTING id_place = 2 id_decimals = lv_runden id_method = -metrnd id_value = l_abs_dbm_calc * id_value_add = l_abs_dbm_calc "v04 id_value_add = l_abs_guar_calc "v04 CHANGING cd_value = l_abs_dbm_rnd cd_value_add = l_abs_guar_rnd. ELSE. "2012.04.05,v03 * EXIT. "2012.04.05,v03 ENDIF. "2012.04.05,v03 * Set he DBM depreciation amount before adjustment and * guarantee depreciation amount AFTER ROUNDING !!! l_abs_dbm = l_abs_dbm_rnd. l_abs_guar = l_abs_guar_rnd. "Note 1673771/OSS#677828(e) * set change-over year when guarantee rate is higher. IF l_abs_guar > l_abs_dbm. cd_changeover_yr = -fyear. * note 1078301 (begin) * Create an entry in master data ANLBZW-bzprz * if no entry exists. ANLBZW-bzproz is ratio (NBV/APC) * at the begin of change-over year IF NOT cd_changeover_yr IS INITIAL. * Get ratio NBV / APC for change-over year CLEAR lv_bzwprz . * lv_bzwprz = ld_nbv / ld_sum_apc * 100 . CHECK:ld_sum_apc <> 0. "Note 1565855. lv_bzwprz_f = ( ld_nbv - -cum-revl ) / ld_sum_apc * 100 . IF lv_bzwprz_f GE '100' OR lv_bzwprz_f LT '0'. lv_bzwprz_f = '99.9999999999999' . ENDIF. lv_bzwprz = lv_bzwprz_f . * read anlbzw entries i_afabe = -area . CALL FUNCTION 'ANLBZW_READ_ASSET' EXPORTING i_bukrs = io_handle->mo_leadobj->md_leadobj i_anln1 = io_handle->mo_assetdata->ms_basic-asset i_anln2 = io_handle->mo_assetdata->ms_basic-subnumber i_afabe = i_afabe IMPORTING es_anlbzw = ls_anlbzw TABLES et_anlbzw = lt_anlbzw EXCEPTIONS no_anlbzw_exists_for_asset = 1 no_anlbzw_for_area_or_year = 2 OTHERS = 3. IF sy-subrc = 0 . * If one result was found get the one IF NOT ls_anlbzw IS INITIAL. ASSIGN ls_anlbzw TO . -bzwprz = lv_bzwprz . ELSE. * If more then 1 result was found, try to get the one * for current fiscal year READ TABLE lt_anlbzw ASSIGNING WITH KEY mandt = sy-mandt bukrs = io_handle->mo_leadobj->md_leadobj anln1 = io_handle->mo_assetdata->ms_basic-asset anln2 = io_handle->mo_assetdata->ms_basic-subnumber afabe = i_afabe bgjahr = -fyear BINARY SEARCH. * If not found for that year, take next table entry IF sy-subrc <> 0. READ TABLE lt_anlbzw ASSIGNING INDEX sy-tabix. ENDIF. IF -bukrs = io_handle->mo_leadobj->md_leadobj AND -anln1 = io_handle->mo_assetdata->ms_basic-asset AND -anln2 = io_handle->mo_assetdata->ms_basic-subnumber AND -afabe = i_afabe AND -bgjahr >= -fyear. * Modify existing ANLBZW entry -bzwprz = lv_bzwprz . ENDIF. ENDIF. " not ls_anlbzw is initial * Create new ANLBZW entry ELSE . ls_anlbzw_new-mandt = sy-mandt. ls_anlbzw_new-bukrs = io_handle->mo_leadobj->md_leadobj . ls_anlbzw_new-anln1 = io_handle->mo_assetdata->ms_basic-asset. ls_anlbzw_new-anln2 = io_handle->mo_assetdata->ms_basic-subnumber. ls_anlbzw_new-afabe = -area. ls_anlbzw_new-bgjahr = '9999'. ls_anlbzw_new-bzwprz = lv_bzwprz . * lv_action = 'I'. ASSIGN ls_anlbzw_new TO . ENDIF . CHECK IS ASSIGNED. * Create / Update ANLBZW entry CALL FUNCTION 'ANLBZW_CREATE_FOR_UPDATE' EXPORTING is_anlbzw = EXCEPTIONS no_read_done_before_update = 1 OTHERS = 2. ENDIF. * note 1078301 (end) ENDIF. ENDLOOP. ENDCASE. endmethod.