Here is a portion of an old program that calculates SL depreciation as well as double declining balance and ACRS (If that is still around). If you are new to COBOL, the structure of this code is not very good. The use of go to's should be avoided. Hope this helps.
IF PURCHASE-DATE > CURRENT-DATE
SUBTRACT PERIOD-PURCHASED FROM PERIODS-IN-THE-YEAR
GIVING PERIODS-TO-DEPRECIATE
ELSE
SUBTRACT CURRENT-PERIOD FROM PERIODS-IN-THE-YEAR
GIVING PERIODS-TO-DEPRECIATE
END-IF
ADD 1 TO PERIODS-TO-DEPRECIATE.
IF DEPRECIATION-METHOD = "D"
GO TO 2352-DECLINING-BALANCE
END-IF
IF DEPRECIATION-METHOD = "B"
GO TO 2353-ACRS-SL
END-IF
IF DEPRECIATION-METHOD = "A"
GO TO 2354-ACRS
END-IF
IF DEPRECIATION-METHOD = "C"
GO TO 2354-ACRS-DB
END-IF.
2351-STRAIGHT-LINE.
IF LIFE-REMAINING < PERIODS-TO-DEPRECIATE
MOVE LIFE-REMAINING TO PERIODS-TO-DEPRECIATE
END-IF
IF PERIODS-TO-DEPRECIATE NOT > ZERO
GO TO 2355-NO-DEPRECIATION
END-IF
DIVIDE NET-BASIS BY LIFE-IN-UNITS
GIVING PERIODIC-DEPRECIATION REMAINDER IEC-REM.
ADD UNITS-USED PERIODS-TO-DEPRECIATE
GIVING PERIODS-THIS-YEAR.
IF PERIODS-THIS-YEAR > PERIODS-IN-THE-YEAR
MOVE PERIODS-IN-THE-YEAR TO PERIODS-THIS-YEAR
END-IF
MULTIPLY PERIODS-THIS-YEAR BY PERIODIC-DEPRECIATION
GIVING ANNUAL-DEPRECIATION.
IF YEARS-REMAINING = LIFE-IN-YEARS
ADD IEC-REM TO ANNUAL-DEPRECIATION
END-IF
SUBTRACT YEAR-TO-DATE-DEPRECIATION FROM ANNUAL-DEPRECIATION
GIVING REMAINING-THIS-YEAR.
SUBTRACT REMAINING-THIS-YEAR FROM BOOK-VALUE
GIVING YEAR-END-BOOK-VALUE.
IF YEAR-END-BOOK-VALUE < SALVAGE-VALUE
SUBTRACT SALVAGE-VALUE FROM BOOK-VALUE
GIVING REMAINING-THIS-YEAR
END-IF
IF REMAINING-THIS-YEAR NOT > ZERO
GO TO 2355-NO-DEPRECIATION
END-IF
DIVIDE PERIODS-TO-DEPRECIATE INTO REMAINING-THIS-YEAR
GIVING PERIODIC-DEPRECIATION REMAINDER IEC-REM.
MOVE PERIODIC-DEPRECIATION TO FIRST-PERIOD-EXPENSE.
ADD IEC-REM TO FIRST-PERIOD-EXPENSE.
GO TO 2356-SET-FAS-FILE.
2352-DECLINING-BALANCE.
IF LIFE-REMAINING < PERIODS-TO-DEPRECIATE
MOVE LIFE-REMAINING TO PERIODS-TO-DEPRECIATE.
IF PERIODS-TO-DEPRECIATE NOT > ZERO
GO TO 2355-NO-DEPRECIATION
END-IF
MOVE BOOK-VALUE TO AMOUNT-TO-DEPRECIATE.
IF AMOUNT-TO-DEPRECIATE NOT > SALVAGE-VALUE
GO TO 2355-NO-DEPRECIATION
END-IF
ADD YEAR-TO-DATE-DEPRECIATION TO AMOUNT-TO-DEPRECIATE.
MULTIPLY RATE-OF-DEPRECIATION BY AMOUNT-TO-DEPRECIATE
GIVING ANNUAL-DEPRECIATION ROUNDED.
DIVIDE LIFE-IN-YEARS INTO ANNUAL-DEPRECIATION ROUNDED.
DIVIDE ANNUAL-DEPRECIATION BY PERIODS-IN-THE-YEAR
GIVING PERIODIC-DEPRECIATION REMAINDER IEC-REM.
MOVE PERIODIC-DEPRECIATION TO FIRST-PERIOD-EXPENSE.
MULTIPLY PERIODIC-DEPRECIATION BY PERIODS-TO-DEPRECIATE
GIVING REMAINING-THIS-YEAR.
IF PERIODS-TO-DEPRECIATE = PERIODS-IN-THE-YEAR
ADD IEC-REM TO FIRST-PERIOD-EXPENSE
ADD IEC-REM TO REMAINING-THIS-YEAR
END-IF
SUBTRACT REMAINING-THIS-YEAR FROM BOOK-VALUE
GIVING YEAR-END-BOOK-VALUE.
IF YEAR-END-BOOK-VALUE < SALVAGE-VALUE
SUBTRACT SALVAGE-VALUE FROM BOOK-VALUE
GIVING REMAINING-THIS-YEAR
DIVIDE REMAINING-THIS-YEAR BY PERIODS-TO-DEPRECIATE
GIVING PERIODIC-DEPRECIATION REMAINDER IEC-REM
MOVE PERIODIC-DEPRECIATION TO FIRST-PERIOD-EXPENSE
ADD IEC-REM TO FIRST-PERIOD-EXPENSE
END-IF
GO TO 2356-SET-FAS-FILE.
2353-ACRS-SL.
MOVE NET-BASIS TO AMOUNT-TO-DEPRECIATE.
IF BOOK-VALUE NOT > ZERO
GO TO 2355-NO-DEPRECIATION
END-IF
IF YEARS-REMAINING NOT > ZERO
GO TO 2355-NO-DEPRECIATION
END-IF
DIVIDE LIFE-IN-YEARS INTO AMOUNT-TO-DEPRECIATE
GIVING ANNUAL-DEPRECIATION.
IF YEARS-REMAINING > LIFE-IN-YEARS
DIVIDE 2 INTO ANNUAL-DEPRECIATION
END-IF
IF YEARS-REMAINING = 1
DIVIDE 2 INTO ANNUAL-DEPRECIATION
END-IF
SUBTRACT YEAR-TO-DATE-DEPRECIATION FROM ANNUAL-DEPRECIATION
GIVING REMAINING-THIS-YEAR.
IF REMAINING-THIS-YEAR > BOOK-VALUE
MOVE BOOK-VALUE TO REMAINING-THIS-YEAR
END-IF
IF REMAINING-THIS-YEAR NOT > ZERO
GO TO 2355-NO-DEPRECIATION
END-IF
DIVIDE PERIODS-TO-DEPRECIATE INTO REMAINING-THIS-YEAR
GIVING PERIODIC-DEPRECIATION REMAINDER IEC-REM.
MOVE PERIODIC-DEPRECIATION TO FIRST-PERIOD-EXPENSE.
ADD IEC-REM TO FIRST-PERIOD-EXPENSE.
GO TO 2356-SET-FAS-FILE.
2354-ACRS.
MOVE NET-BASIS TO AMOUNT-TO-DEPRECIATE.
IF YEARS-REMAINING < 1
GO TO 2355-NO-DEPRECIATION
END-IF
SUBTRACT YEARS-REMAINING FROM LIFE-IN-YEARS
GIVING X1.
ADD 1 TO X1.
IF LIFE-IN-YEARS = 3
MULTIPLY WB-3YR (X1) BY AMOUNT-TO-DEPRECIATE
GIVING ANNUAL-DEPRECIATION ROUNDED
END-IF
IF LIFE-IN-YEARS = 5
MULTIPLY WB-5YR (X1) BY AMOUNT-TO-DEPRECIATE
GIVING ANNUAL-DEPRECIATION ROUNDED
END-IF
IF LIFE-IN-YEARS = 10
MULTIPLY WB-10YR (X1) BY AMOUNT-TO-DEPRECIATE
GIVING ANNUAL-DEPRECIATION ROUNDED
END-IF
SUBTRACT YEAR-TO-DATE-DEPRECIATION FROM ANNUAL-DEPRECIATION
GIVING REMAINING-THIS-YEAR.
IF REMAINING-THIS-YEAR > BOOK-VALUE
MOVE BOOK-VALUE TO REMAINING-THIS-YEAR
END-IF
IF REMAINING-THIS-YEAR NOT > ZERO
GO TO 2355-NO-DEPRECIATION
END-IF
DIVIDE PERIODS-TO-DEPRECIATE INTO REMAINING-THIS-YEAR
GIVING PERIODIC-DEPRECIATION REMAINDER IEC-REM.
MOVE PERIODIC-DEPRECIATION TO FIRST-PERIOD-EXPENSE.
ADD IEC-REM TO FIRST-PERIOD-EXPENSE.
GO TO 2356-SET-FAS-FILE.
2354-ACRS-DB.
IF YEARS-REMAINING NOT > ZERO
GO TO 2355-NO-DEPRECIATION
END-IF
IF BOOK-VALUE NOT > ZERO
GO TO 2355-NO-DEPRECIATION
END-IF
MOVE BOOK-VALUE TO AMOUNT-TO-DEPRECIATE.
ADD YEAR-TO-DATE-DEPRECIATION TO AMOUNT-TO-DEPRECIATE.
MULTIPLY RATE-OF-DEPRECIATION BY AMOUNT-TO-DEPRECIATE
GIVING ANNUAL-DEPRECIATION ROUNDED.
DIVIDE LIFE-IN-YEARS INTO ANNUAL-DEPRECIATION ROUNDED.
IF YEARS-REMAINING > LIFE-IN-YEARS
DIVIDE 2 INTO ANNUAL-DEPRECIATION
END-IF
SUBTRACT YEAR-TO-DATE-DEPRECIATION FROM ANNUAL-DEPRECIATION
GIVING REMAINING-THIS-YEAR.
IF REMAINING-THIS-YEAR NOT > ZERO
GO TO 2355-NO-DEPRECIATION
END-IF
DIVIDE PERIODS-TO-DEPRECIATE INTO REMAINING-THIS-YEAR
GIVING PERIODIC-DEPRECIATION REMAINDER IEC-REM.
MOVE PERIODIC-DEPRECIATION TO FIRST-PERIOD-EXPENSE.
ADD IEC-REM TO FIRST-PERIOD-EXPENSE.
GO TO 2356-SET-FAS-FILE.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.