we have the following code in include ZXAFAU02.
It's working fine generally but if there are additional acquisitions, and other postings for the year, the computation becomes wrong. the depreciation doesn't get spread out correctly according to the remaining useful life.
Please advise how do we correct this.
Thanks very much.
DATA: lv_ul TYPE ndper, "useful life (month)
lv_ex_ul TYPE ndper, "expired useful life (month)
lv_balance TYPE ndper, "balance useful life (month)
lv_nbv LIKE anlc-kansw, "net book value of remaining life
lv_depreciation LIKE anlc-kansw, "depreciate value per month
lv_afblpe LIKE anlc-afblpe, "period of last posting
lv_months TYPE ndper. "remaining months (current run)
* check depreciation calculation method eq 'X'
CHECK i_afap-afamet EQ 'X'.
* calculate userful life in months
lv_ul = i_anlb-ndjar * 12 + i_anlb-ndper.
LOOP AT t_anlc WHERE afabe EQ i_afabe.
* calculate expired useful life, up to last posted month
lv_ex_ul = t_anlc-ndabj * 12 + t_anlc-ndabp + t_anlc-afblpe.
* calculate the NBV for the remaining useful life
lv_nbv = t_anlc-kansw + t_anlc-knafa + t_anlc-nafag.
* store last posting period
lv_afblpe = t_anlc-afblpe.
* balance useful life in months
lv_balance = lv_ul - lv_ex_ul.
* monthly depreciation - per remaining month of useful live
IF lv_balance GT 0.
lv_depreciation = lv_nbv / lv_balance.
lv_depreciation = 0.
* remaining months for current run (useful life)
lv_months = i_afap-rperend - i_afap-rperbeg + 1.
* reduce by already posted months
lv_months = lv_months - lv_afblpe.
* calculate total depreciation value for current period
e_afabtr = ( t_anlc-nafag * -1 ) + ( lv_depreciation * lv_months ).
* set active flag
e_aktiv = 'X'.
- ABAP Definition & Full Form
- SAP ABAP Certification Cost
- SAP ABAP Course Detail & Scope
- ABAP Interview Questions
- ABAP Syntax
- ABAP Date & Time
- ABAP Internal Tables
- ABAP Table Control
- ABAP Data Dictionary
- ABAP Views Types
- ABAP Loop At Where
- ABAP Module Pool Program
- ABAP Search Help
- ABAP Trigger Event
- ABAP Native vs. Open SQL
- ABAP Function Modules
- ABAP OOPs
- ABAP Data Types and Objects
- ABAP Classes
- ABAP Smartforms
- ABAP Sapscript Layout
- ABAP BADI Step by Step
- ABAP BAPI List
- ABAP WEB DYNPRO
- ABAP ALV
- ABAP Core Data Service
- ABAP Trim or Condense Spaces
- ABAP Convert Currency Format
- ABAP Delete Leading Zeros
- ABAP Use Search Help in Selection Screen
- SAP Tcode SE16 vs SE16N