*****************************************
      * Program name: dep.cbl
      * This web-based program provides examples of 
      * depreciation function usage and HTML gldi
      * usage.
      *
      * Copyright 2000 Deskware, Inc.
      *****************************************

       1 depreciation_method PIC XXX VALUE `DDB`.

       1 content_length         PIC 9(05).

       1 web_page_top.
         5 `Content-type: text/html`.
         5 ` `.
         5 ``.
         5 `
`. 5 ``. 5 ``. 5 ``. 5 ``. 5 ``. 5 ``. 5 ``. 5 ``. 5 ``. 1 depreciation_header_html. 5 `
Cost of AssetLife of AssetSalvage Value of Asset 
`. 5 `

`. 5 method_text PIC X(50) VALUE `Double Declining Balance Depreciation Schedule`. 5 `

`. 5 ``. 5 ``. 5 ``. 5 ``. 5 ``. 5 ``. 1 depreciation_html. 5 ``. 5 ``. 5 ``. 5 ``. 5 ``. 5 ``. 1 footer_html. 5 `
PeriodDepreciation AmountRemaining Asset ValueTotal Amount Depreicated
`. 5 period PIC 99 VALUE 0. 5 ``. 5 dep_amt PIC $$$$$.99. 5 ``. 5 remaining_asset_value PIC $$$$$$.99. 5 ``. 5 amount_depreciated PIC $$$$$$.99. 5 `
`. MAIN. GETENV USING `CONTENT_LENGTH` content_length. IF content_length > 0 ACCEPT DATA FROM WEBPAGE END-IF. DISPLAYLF web_page_top. * DDB-specific calculations and HTML DISPLAYLF depreciation_header_html. MOVE cost TO remaining_asset_value. MOVE 0 TO amount_depreciated. MOVE `DDB` TO depreciation_method. PERFORM CALC-DEPRECIATION VARYING period FROM 1 BY 1 UNTIL period > life. * SYD-specific calculations and HTML MOVE `Sum-of-Years Digits Depreciation Schedule` TO method_text. DISPLAYLF depreciation_header_html. MOVE cost TO remaining_asset_value. MOVE 0 TO amount_depreciated. MOVE `SYD` TO depreciation_method. PERFORM CALC-DEPRECIATION VARYING period FROM 1 BY 1 UNTIL period > life. * Straight-line-specific calculations and HTML MOVE `Straight Line Depreciation Schedule` TO method_text. DISPLAYLF depreciation_header_html. MOVE cost TO remaining_asset_value. MOVE 0 TO amount_depreciated. MOVE `SLM` TO depreciation_method. PERFORM CALC-DEPRECIATION VARYING period FROM 1 BY 1 UNTIL period > life. * Footer HTML DISPLAY footer_html. STOP RUN. ******************************************************* * MODULE: CALC-DEPRECIATION * * DESCRIPTION: Calculates depreciation, using different * methods for different values of depreciation_method * variable. ******************************************************* CALC-DEPRECIATION. IF depreciation_method = `DDB` COMPUTE dep_amt = DDBAMT(cost, life, period, salvage_value) ELSIF depreciation_method = `SYD` COMPUTE dep_amt = SYDAMT(cost, life, period, salvage_value) ELSIF depreciation_method = `SLM` COMPUTE dep_amt = STRLINEAMT(cost, life, salvage_value) ELSE DISPLAY `
Unknown depreciation method.

` COMPUTE period = life + 1 END-IF. COMPUTE remaining_asset_value = remaining_asset_value - dep_amt. COMPUTE amount_depreciated = amount_depreciated + dep_amt. DISPLAY depreciation_html.