[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [open-cobol-list] PLEASE HELP new to coboL PROGRAMMING
From: |
Vince Coen |
Subject: |
Re: [open-cobol-list] PLEASE HELP new to coboL PROGRAMMING |
Date: |
Mon, 20 Dec 2010 13:24:51 +0000 |
User-agent: |
KMail/1.13.3 (Linux/2.6.33.7-server-2mnb; KDE/4.4.3; i686; ; ) |
Hi;
On Monday 20 Dec 2010, rathin wrote:
> SIR,
> I AM NEW TO COBOL PROGRAMMING . IT WOULD BE VERY KIND OF YOU IF
> IT BE TAUGHT BY EXAMPLE BELOW IS A PROGRAM TAKEN FROM THE NET. SO SIR
> IF YOU CAN KINDLY PUT IT IN THE OPEN COBOL FORMAT THAN IT WOULD BE
> EASIER FOR ME TO UNDERSTAND.
> I SUCCESSFULLY INSTALLED OPEN COBOL 1.0 AND THE COBC HAS BEEN
> SUCCESSFULLY COMPILED.
> SIR KINDLY CHANGE IT TO OPEN COBOL FORMAT SO THAT I CAN IDENTIFY THE
> DIFFERENCE AND LEARN IT STEP BY STEP
It not exactly difficult but first stop writing in upper case, use normal text
and case e.g, the same as this!
1. Remove leading spaces so that Cobol text starts at column 1 for all
sections and division headers and col 2 or more for all others.
2. Replace all comment lines containing '* ' with '*>'
3. Add as line one but starting at column 8 >>source free
4. Cobol does not require all text in upper case so change case to suite your
needs.
5. Upgrade open cobol to version 1.1 or later
[Note that my email editor as messed up spacing in code so that left hand
start position is moved left]
Example :
>>source free
identification division.
program-id. test1.
environment division.
configuration section.
input-output section.
file-control.
select tax-table-file assign "input-file"
organization line sequential.
select salary-file assign "input-file"
organization line sequential.
select salary-report assign "output-file"
organization line sequential.
data division.
file section.
*>
fd tax-table-file.
01 tax-table-rec.
05 t-max-tax-income pic 9(06).
05 t-fed-tax pic v9(3).
05 t-state-tax pic v9(3).
05 pic x(68).
fd salary-file.
01 salary-file-rec.
05 employee-no pic 9(05).
05 employee-name pic x(20).
05 pic x(03).
05 annual-salary pic 9(05).
05 pic x(08).
05 no-dependents pic 9(01).
05 pic x(38).
fd salary-report
record contains 80 characters.
01 salary-report-rec pic x(80).
*>
working-storage section.
01 working-items.
05 more-recs pic x(01).
05 x1 pic 9(02).
05 more-table-recs pic x(01) value 'Y'.
05 fed-tax-deduction pic 9(05).
05 state-tax-deduction pic 9(05).
05 monthly-take-home-pay pic 9(05)v9(02).
05 found-match pic x(01) value 'N'.
05 temp-income pic 9(06) value zeroes.
01 ws-date.
05 ws-date-year pic 9(02).
05 ws-date-month pic 9(02).
05 ws-date-day pic 9(02).
01 ws-report-date.
05 rd-month pic 9(02).
05 pic x(01) value '/'.
05 rd-day pic 9(02).
05 pic x(01) value '/'.
05 rd-year pic 9(02).
01 tax-table.
05 table-entries occurs 6 times.
10 ws-max-tax-income pic 9(06).
10 ws-fed-tax pic v9(3).
10 ws-state-tax pic v9(3).
01 header-1.
05 pic x(12).
05 pic x(21) value 'MONTHLY SALARY REPORT'.
05 pic x(03).
05 date-out pic 99/99/99.
05 pic x(02).
*> 05 pic x(04) value 'PAGE'.
*> 05 page-out pic 9(02).
01 header-2.
05 pic x(08) value 'EMPLOYEE'.
05 pic x(19).
05 pic x(17) value 'MONTHLY TAKE HOME'.
01 header-3.
05 pic x(02).
05 pic x(04) value 'NAME'.
05 pic x(28).
05 pic x(03) value 'PAY'.
01 list-line-1.
05 employee-name-out pic x(20).
05 pic x(11).
05 monthly-take-home-pay-out pic $zz,zzz.99.
01 list-line-2.
05 pic x(05).
05 pic x(35) value 'No match was found in
the tax table'.
procedure division.
000-main-rtn.
perform 100-initialize-rtn
perform 200-table-entry
perform 300-process-rtn until more-recs = 'N'
perform 900-close-files-rtn.
100-initialize-rtn.
open input tax-table-file
salary-file
output salary-report
move 'Y' to more-recs
perform 110-set-date-rtn
perform 120-write-headers-rtn.
110-set-date-rtn.
accept ws-date from date
move ws-date-year to rd-year
move ws-date-month to rd-month
move ws-date-day to rd-day
move ws-report-date to date-out.
120-write-headers-rtn.
write salary-report-rec from header-1 after 5
write salary-report-rec from header-2 after 2
write salary-report-rec from header-3 after 1.
200-table-entry.
perform varying x1 from 1 by 1 until x1 > 7 or more-table-recs = 'N'
read tax-table-file
at end
move 'N' to more-table-recs
not at end
perform 250-table-load
end-read
end-perform
if x1 < 7
display 'Too few records in the file'
end-if
if more-table-recs not = 'N'
display 'Too many records in the file'
end-if.
250-table-load.
move t-max-tax-income to ws-max-tax-income (x1)
move t-fed-tax to ws-fed-tax (x1)
move t-state-tax to ws-state-tax (x1).
300-process-rtn.
read salary-file at end
move 'N' to more-recs
not at end
perform 350-compare-rtn
end-read.
350-compare-rtn.
move 1 to x1
perform 353-increment-subscript-rtn until found-match = 'Y' or x1 > 7
if x1 > 7 and found-match = 'N'
then write salary-report-rec from list-line-2
continue
end-if
perform 356-calculate-rtn
perform 359-write-rtn
move 'N' to found-match
move zeroes to temp-income.
353-increment-subscript-rtn.
if annual-salary > temp-income and <= ws-max-tax-income (x1)
then move 'Y' to found-match
else
move ws-max-tax-income (x1) to temp-income
add 1 to x1
end-if.
356-calculate-rtn.
compute fed-tax-deduction = annual-salary * ws-fed-tax (x1)
compute state-tax-deduction = annual-salary * ws-state-tax (x1)
compute monthly-take-home-pay = (annual-salary - (fed-tax-deduction +
state-tax-deduction))/12.
359-write-rtn.
move employee-name to employee-name-out
move monthly-take-home-pay to monthly-take-home-pay-out
write salary-report-rec from list-line-1 after 1.
900-close-files-rtn.
close tax-table-file
salary-file
salary-report
stop run.