Updating avg

You are asked to write a COBOL report-generation program to print the sales in every month. As an example, let's assume that a bank's customer accounts information is stored in a table.

Similarly, the child elements inside WS-EMPLOYEE(03) would be called WS-EMPLOYEE-SSN(03) and WS-EMPLOYEE-NAME(03). Array elements are laid out in computer memory in adjacent locations. Because arrays are contiguous in memory, data processing is faster. A COBOL table or array is simply a data structure consisting of a collection of elements(values), all of which have the same data description, such as a table of monthly sales. To define the array in WORKING-STORAGE with an OCCURS clause would require the following coding. MOVE WS-FROM-DATE-DD TO WS-TO-DATE-DD MOVE WS-FROM-DATE-CC TO WS-TO-DATE-CC MOVE WS-FROM-DATE-YY TO WS-TO-DATE-YY MOVE WS-FROM-DATE-MM TO WS-MONTH-NUM MOVE WS-MONTH-NAME(WS-MONTH-NUM) TO WS-TO-DATE-MON. I frequently store static data, constants like rates, prices, categories, options in COBOL arrays in WORKING STORAGE, rather than hard-coding at many places. Tax amount of the first bracket is ,925 x 10% = 2.50. Its easy to see, that if the tax rates are revised, only the TAX-RATES-TABLE needs modification, the 7000-COMPUTE-TAX sub-routine remains as is. Note that, the OCCURS clause may not be used on the levels 01, 66 and 77. A well-designed program has the static data centralized at one place. A generic sub-routine can be written to compute tax as follows.

Leave a Reply