COBOL

Anyone know Cobol???

Page 1 of 1

10 Replies - 1827 Views - Last Post: 22 December 2009 - 10:20 PM Rate Topic: -----

#1 53greek53  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 60
  • Joined: 27-November 08

COBOL

Posted 08 November 2009 - 09:45 PM

Ladies and Gents,

I posted a Cobol question here a while back and received no response. Is this the correct forum for such a question. If not can someone suggest a better place? Does anyone here even know COBOL??
Is This A Good Question/Topic? 0
  • +

Replies To: COBOL

#2 bsaunders  Icon User is offline

  • D.I.C Addict

Reputation: 44
  • View blog
  • Posts: 571
  • Joined: 18-January 09

Re: COBOL

Posted 10 November 2009 - 07:46 AM

I know a bit of COBOL. What's your problem?

This post has been edited by bsaunders: 10 November 2009 - 07:47 AM

Was This Post Helpful? 0
  • +
  • -

#3 53greek53  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 60
  • Joined: 27-November 08

Re: COBOL

Posted 10 November 2009 - 08:20 PM

View Postbsaunders, on 10 Nov, 2009 - 06:46 AM, said:

I know a bit of COBOL. What's your problem?


So basically what I am trying to day is write a bonus program. Here are the specifics.

employees hired in 1999 receive no bonus
employees hired in 1998 recieve a 2% bonus
employees hired before 1995 recieve a 10% bonus
all other employees recieve a 4.5% bonus

I also need to total all the columns in a total row at the bottom.

Here is my code:

		Identification Division.
	   Program-Id. Payroll-Bonus.
	   Author..
	   Date-Compiled. 10/9/2009.
	   Environment Division.
	   INPUT-OUTPUT SECTION.
	   File-Control.
	   Select Payroll-List assign to 'C0901.DAT'
		   Organization is line Sequential.
	   Select Payroll-Report assign to 'C0901.TXT'
		   Organization is line Sequential.

	   Data Division.
	   File Section.
	   FD  Payroll-List
		   LABEL RECORDS ARE STANDARD
		   Record Contains 80 Characters
		   Data Record is Payroll-Master.
	  *This Paragraph is the input data.
	   01 PAYROLL-MASTER.
		  05 EMPLOYEE-NO				 PIC X(5).
		  05 EMPLOYEE-NAME			   PIC X(20).
		  05 TERRITORY-NO				PIC X(2).
		  05 OFFICE-NO				   PIC X(2).
		  05 ANNUAL-SALARY			   PIC 9(6).
		  05 UNUSED					  PIC X(29).
		  05 DATE-HIRED.
			 10 Hired-Day				Pic x(2).
			 10 Hired-Month			  pic x(2).
			 10 Hired-Year			   pic x(4).
				88 No-Bonus			  Value "1999".
				88 two-percent		   Value "1998".
				88 four-percent		  Value "1900" thru "1995".
		  05 unused					  pic x(10).


	   FD  Payroll-Report
		   LABEL RECORDS ARE STANDARD
		   Record Contains 80 Characters
		   Data Record is Print-Rec.
	   01  Print-Rec					 pic x(80).

	   Working-Storage Section.
	   01 More-Data					  pic xxx value "yes".
	   01 Work-Areas.
		  05 employee-ctr				pic 99.
		  05 WS-Date.
			  10 CURRENT-year			pic 9999.
			  10 CURRENT-MONTH		   pic 99.
			  10 CURRENT-day			 pic 99.
		  05 Page-in.
			  10 WS-PAGE-CT			  pic 99 Value Zero.
			  10 WS-LINE-CT			  pic 99 Value Zero.

	   01 Heading-1.
		  05							 pic x(40) Value Spaces.
		  05							 pic x(5) Value "Bonus".
		  05							 pic x(2) Value Spaces.
		  05							 pic x(6) Value "Report".
		  05							 pic x(7) Value Spaces.
		  05							 pic x(5) Value "Page".
		  05 PAGE-OUT					pic z9.
	   01 DATE-OUT.
			 10 MONTH-OUT				pic 99.
			 10						  pic x(1)  Value "/".
			 10 DAY-OUT				  pic 99.
			 10						  pic x(1)  Value "/".
			 10 YEAR-OUT				 pic 9999.

	   01 Heading-2.
		  05							 pic x(10) Value Spaces.
		  05							 pic x(9) Value "Territory".
		  05							 pic x(1) Value Spaces.
		  05 Territory-no				pic 99.
		  05							 pic x(58) Value Spaces.

	   01 Heading-3.
		  05							 pic x(10) Value Spaces.
		  05							 pic x(6) Value "Office".
		  05							 pic x(4) Value Spaces.
		  05 office-no				   pic 99.
		  05							 pic x(58) Value Spaces.

	   01 Heading-4.
		  05							 pic x(10) Value Spaces.
		  05							 pic x(8) Value "Employee".
		  05							 pic x(1) Value Spaces.
		  05							 pic x(6) Value "Number".
		  05							 pic x(3) Value Spaces.
		  05							 pic x(8) Value "Employee".
		  05							 pic x(1) Value Spaces.
		  05							 pic x(4) Value "Name".
		  05							 pic x(3) Value Spaces.
		  05							 pic x(4) Value "Hire".
		  05							 pic x(1) Value Spaces.
		  05							 pic x(4) Value "Date".
		  05							 pic x(3) Value Spaces.
		  05							 pic x(6) Value "Salary".
		  05							 pic x(3) Value Spaces.
		  05							 pic x(5) Value "Bonus".

	   01 Detail-Line.
		  05							 pic x(10) Value Spaces.
		  05 Employee-No				 pic x(5).
		  05							 pic x(13) Value Spaces.
		  05 Employee-Name			   pic x(15).
		  05							 pic x(1) Value Spaces.
		  05 Date-Hired.
			 10 Hired-Day				pic x(2).
			 10						  pic x(1) Value "/".
			 10 Hired-Month			  pic x(2).
			 10						  pic x(1) Value "/".
			 10 year-hired			   pic x(4).
		  05							 pic x(1) Value Spaces.
		  05 Emp-Salary				  pic zzz,zz9.
		  05							 pic x(1) Value Spaces.
		  05 Bonus					   pic zzz,zz9.
		  05							 pic x(3) Value Spaces.

	   01 Total-Line.
		  05							 pic x(50) Value Spaces.
		  05							 pic x(5) Value "Total".
		  05 office-total				pic z(6).
		  05							 pic x(2) Value Spaces.
		  05 bonus-total				 pic z(6).


	   PROCEDURE DIVISION.
	   100-Payroll.
		   Perform 200-HOUSEKEEPING
		   Perform 300-heading-rtn
		   Perform 3 times
			   Perform 2 times
					Perform
	   Varying employee-ctr from 1 by 1 until employee-ctr > 10
			   Read Payroll-List
				   At End
					   Move 'No' to More-Data
				   Not At End
				   Perform 210-Print-office-total
				   Perform 220-Process-module
				   If employee-ctr = 10
				   then perform 300-heading-rtn move
				   zeros to office-total
				   end-if
			   End-Read
			   End-Perform
			   End-Perform.
		   Perform 230-Finalize
		   Display "Program Finished"
		   Stop Run.




	   200-HOUSEKEEPING.
		   OPEN INPUT Payroll-List
			   Output Payroll-Report.
	   Perform 300-Date.

	   300-Date.
		   Move function current-date to ws-date
		   Move current-day to day-out
		   move current-month to month-out
		   move current-year to year-out.

	   210-Print-Office-Total.

	   220-Process-module.
	   if employee-ctr = 0 then perform 300-heading-rtn.
	   move annual-salary to office-total
	   Perform 320-Bonus
	   Perform 340-Print-Details.

	   230-finalize.
		   Close Payroll-List
			   Payroll-Report.



	   300-Heading-Rtn.
		   Add 1 to WS-PAGE-CT
		   MOVE WS-PAGE-CT to PAGE-OUT
		   WRITE PRINT-REC FROM HEADING-1 after advancing 1 line
		   WRITE PRINT-REC FROM HEADING-2 after advancing 1 line
		   WRITE PRINT-REC FROM HEADING-3 after advancing 1 line
		   Write PRINT-REC FROM HEADING-4 after advancing 1 line
				Move spaces to print-rec
				write print-rec
				after advancing 1 line
		   Move zeros to WS-LINE-CT.


	   320-Bonus.
	   Evaluate true
		  when no-bonus multiply annual-salary by 0 giving bonus
		  when two-percent multiply annual-salary by .02 giving bonus
		  when four-percent multiply annual-salary by .045 giving bonus
		  when other move 0 to bonus
	   end-evaluate.

	   340-print-details.
	   Move annual-salary to emp-salary
	   Move employee-no of payroll-master to employee-no of
	   detail-line
	   Move employee-name of payroll-master to employee-name of
	   detail-line
	   Move territory-no of payroll-master to territory-no of heading-2
	   move office-no of payroll-master to office-no of heading-3
	   move hired-day of payroll-master to hired-day of detail-line
	   move hired-month of payroll-master to hired-month of detail-line
	   move hired-year of payroll-master to year-hired of detail-line
	   Move detail-line to print-rec
		   Write Print-Rec
		   Add 1 to WS-LINE-CT.



I have also attatched the data file. I am using Microfocus as my compiler.
Was This Post Helpful? 0
  • +
  • -

#4 bsaunders  Icon User is offline

  • D.I.C Addict

Reputation: 44
  • View blog
  • Posts: 571
  • Joined: 18-January 09

Re: COBOL

Posted 10 November 2009 - 09:58 PM

Are you having a problem?
Was This Post Helpful? 0
  • +
  • -

#5 53greek53  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 60
  • Joined: 27-November 08

Re: COBOL

Posted 11 November 2009 - 08:33 AM

View Postbsaunders, on 10 Nov, 2009 - 08:58 PM, said:

Are you having a problem?



It won't let me upload the .dat file. But my problem is that i don't know how to acummulate the totals at the end. Also the bonuses are coming out incorrect.
Was This Post Helpful? 0
  • +
  • -

#6 VB6cobolGuy  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 6
  • Joined: 11-November 09

Re: COBOL

Posted 11 November 2009 - 11:46 PM

To get the totals at the end you will perform the write just before you close your files. I see you are just using the Total-line. Right before your
Perform 230-Finalize in the 100 payroll paragraph put

WRITE PRINT-REC FROM Total-line


that's just my quick response if you can try that and let me know how that turns out I will try to help you further. I am not an "expert" as I am taking my second course in COBOL but I have gone through a lot of this already. Also I will try and post a solution to your bonus situation as well.


edit: that should atleast print the total line out for you at the end. you will need to add the office-no to the office-total and also bonus to bonus-total before you do the write that I mentioned above. Let me know how far that gets you.

This post has been edited by VB6cobolGuy: 11 November 2009 - 11:51 PM

Was This Post Helpful? 1
  • +
  • -

#7 53greek53  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 60
  • Joined: 27-November 08

Re: COBOL

Posted 13 November 2009 - 04:47 PM

I made those changes but I still cant get the total line to print at all I will repost my code to reflect the changes. I'll keep tinkering with it, let me know if you have any ideas. Thank you.

	   Identification Division.
	   Program-Id. Payroll-Bonus.
	   Author..
	   Date-Compiled. 10/9/2009.
	   Environment Division.
	   INPUT-OUTPUT SECTION.
	   File-Control.
	   Select Payroll-List assign to 'C0901.DAT'
		   Organization is line Sequential.
	   Select Payroll-Report assign to 'C0901.TXT'
		   Organization is line Sequential.

	   Data Division.
	   File Section.
	   FD  Payroll-List
		   LABEL RECORDS ARE STANDARD
		   Record Contains 80 Characters
		   Data Record is Payroll-Master.
	  *This Paragraph is the input data.
	   01 PAYROLL-MASTER.
		  05 EMPLOYEE-NO				 PIC X(5).
		  05 EMPLOYEE-NAME			   PIC X(20).
		  05 TERRITORY-NO				PIC X(2).
		  05 OFFICE-NO				   PIC X(2).
		  05 ANNUAL-SALARY			   PIC 9(6).
		  05 UNUSED					  PIC X(29).
		  05 DATE-HIRED.
			 10 Hired-Day				Pic x(2).
			 10 Hired-Month			  pic x(2).
			 10 Hired-Year			   pic x(4).
				88 No-Bonus			  Value "1999".
				88 two-percent		   Value "1998".
				88 four-percent		  Value "1900" thru "1995".
		  05 unused					  pic x(10).


	   FD  Payroll-Report
		   LABEL RECORDS ARE STANDARD
		   Record Contains 80 Characters
		   Data Record is Print-Rec.
	   01  Print-Rec					 pic x(80).

	   Working-Storage Section.
	   01 More-Data					  pic xxx value "yes".
	   01 Work-Areas.
		  05 ws-bonus					pic 9(6).
		  05 ws-salary				   pic 9(6).
		  05 employee-ctr				pic 99.
		  05 WS-Date.
			  10 CURRENT-year			pic 9999.
			  10 CURRENT-MONTH		   pic 99.
			  10 CURRENT-day			 pic 99.
		  05 Page-in.
			  10 WS-PAGE-CT			  pic 99 Value Zero.
			  10 WS-LINE-CT			  pic 99 Value Zero.

	   01 Heading-1.
		  05							 pic x(40) Value Spaces.
		  05							 pic x(5) Value "Bonus".
		  05							 pic x(2) Value Spaces.
		  05							 pic x(6) Value "Report".
		  05							 pic x(7) Value Spaces.
		  05							 pic x(5) Value "Page".
		  05 PAGE-OUT					pic z9.
	   01 DATE-OUT.
			 10 MONTH-OUT				pic 99.
			 10						  pic x(1)  Value "/".
			 10 DAY-OUT				  pic 99.
			 10						  pic x(1)  Value "/".
			 10 YEAR-OUT				 pic 9999.

	   01 Heading-2.
		  05							 pic x(10) Value Spaces.
		  05							 pic x(9) Value "Territory".
		  05							 pic x(1) Value Spaces.
		  05 Territory-no				pic 99.
		  05							 pic x(58) Value Spaces.

	   01 Heading-3.
		  05							 pic x(10) Value Spaces.
		  05							 pic x(6) Value "Office".
		  05							 pic x(4) Value Spaces.
		  05 office-no				   pic 99.
		  05							 pic x(58) Value Spaces.

	   01 Heading-4.
		  05							 pic x(10) Value Spaces.
		  05							 pic x(8) Value "Employee".
		  05							 pic x(1) Value Spaces.
		  05							 pic x(6) Value "Number".
		  05							 pic x(3) Value Spaces.
		  05							 pic x(8) Value "Employee".
		  05							 pic x(1) Value Spaces.
		  05							 pic x(4) Value "Name".
		  05							 pic x(3) Value Spaces.
		  05							 pic x(4) Value "Hire".
		  05							 pic x(1) Value Spaces.
		  05							 pic x(4) Value "Date".
		  05							 pic x(3) Value Spaces.
		  05							 pic x(6) Value "Salary".
		  05							 pic x(3) Value Spaces.
		  05							 pic x(5) Value "Bonus".

	   01 Detail-Line.
		  05							 pic x(10) Value Spaces.
		  05 Employee-No				 pic x(5).
		  05							 pic x(13) Value Spaces.
		  05 Employee-Name			   pic x(15).
		  05							 pic x(1) Value Spaces.
		  05 Date-Hired.
			 10 Hired-Day				pic x(2).
			 10						  pic x(1) Value "/".
			 10 Hired-Month			  pic x(2).
			 10						  pic x(1) Value "/".
			 10 year-hired			   pic x(4).
		  05							 pic x(1) Value Spaces.
		  05 Emp-Salary				  pic zzz,zz9.
		  05							 pic x(1) Value Spaces.
		  05 Bonus					   pic zzz,zz9.
		  05							 pic x(3) Value Spaces.

	   01 Total-Line.
		  05							 pic x(50) Value Spaces.
		  05							 pic x(5) Value "Total".
		  05 office-total				pic z(6).
		  05							 pic x(2) Value Spaces.
		  05 bonus-total				 pic z(6).


	   PROCEDURE DIVISION.
	   100-Payroll.
		   Perform 200-HOUSEKEEPING
		   Perform 300-heading-rtn
		   Perform 3 times
			   Perform 2 times
					Perform
	   Varying employee-ctr from 1 by 1 until employee-ctr > 10
			   Read Payroll-List
				   At End
					   Move 'No' to More-Data
				   Not At End
				   Perform 220-Process-module
				   If employee-ctr = 10
				   then perform 300-heading-rtn move
				   zeros to office-total
				   end-if
			   End-Read
			   End-Perform
			   End-Perform.
			   write print-rec from total-line
		   Perform 230-Finalize
		   Display "Program Finished"
		   Stop Run.




	   200-HOUSEKEEPING.
		   OPEN INPUT Payroll-List
			   Output Payroll-Report.
	   Perform 300-Date.

	   300-Date.
		   Move function current-date to ws-date
		   Move current-day to day-out
		   move current-month to month-out
		   move current-year to year-out.


	   220-Process-module.
	   if employee-ctr = 0 then perform 300-heading-rtn.
	   move annual-salary to office-total
	   Perform 320-Bonus
	   Perform 340-Print-Details.

	   230-finalize.
		   Close Payroll-List
			   Payroll-Report.






here is a partial of what my results look like

Bonus Report Page 1
Territory
Office
Employee Number Employee Name Hire Date Salary Bonus
00001 ADAMSON 01/15/1993 40,000 1,800
00002 BAKER 03/20/1994 50,000 2,250
00003 CARTWELL 04/10/1995 100,000 4,500
00004 DORSEY 02/02/1993 45,000 2,025
00005 HAMMOND 05/05/1995 50,000 2,250
00006 NOLTE 06/27/1993 45,000 2,025
00007 REDFORD 11/01/1995 48,000 2,160
00008 JOHNKE 01/15/1993 55,000 2,475
00009 WHITE 06/20/1994 59,000 2,655
00010 MARSHALL 11/29/1996 53,000 0

Bonus Report Page 2
Territory 01
Office 01
Employee Number Employee Name Hire Date Salary Bonus
00011 EISEN 09/28/1994 50,000 2,250
00012 SAGER 07/25/1997 68,000 0
00013 STERN 10/01/1994 68,000 3,060
00014 SUMMERS 02/01/1995 67,500 3,037
00015 JONES 05/05/1998 40,000 800
00016 JOHNSON 08/01/1998 100,000 2,000
00017 NOLAN 07/15/1993 44,750 2,013
00018 CANTWELL 06/28/1993 68,250 3,071
00019 SMITH 02/15/1993 75,000 3,375
00020 HAMMEL 03/20/1993 59,100 2,659
Was This Post Helpful? 0
  • +
  • -

#8 53greek53  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 60
  • Joined: 27-November 08

Re: COBOL

Posted 13 November 2009 - 09:02 PM

I got my bonuses to calculate correctly. If anyone knows how to get my totals to move to the total line and print correctly that would be very helpful.
Was This Post Helpful? 0
  • +
  • -

#9 VB6cobolGuy  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 6
  • Joined: 11-November 09

Re: COBOL

Posted 15 November 2009 - 04:59 PM

Ok I'm guessing your trying to keep a grand total of the bonuses to print out when there at no more records correct? If so add the bonus you've already calculated to another field(bonus-total). then the line with ------ will add the bonus that you calculated for that employee/record to the grand total field

	   100-Payroll.
		   Perform 200-HOUSEKEEPING
		   Perform 300-heading-rtn
		   Perform 3 times
			   Perform 2 times
					Perform
	   Varying employee-ctr from 1 by 1 until employee-ctr > 10
			   Read Payroll-List
				   At End
					   Move 'No' to More-Data
				   Not At End
		------	add Bonus to bonus-total
				   Perform 220-Process-module
				   If employee-ctr = 10
				   then perform 300-heading-rtn move
				   zeros to office-total
				   end-if
			   End-Read
			   End-Perform
			   End-Perform.
				   write print-rec from total-line
		   Perform 230-Finalize
		   Display "Program Finished"
		   Stop Run.



try adding that statement and let me know if that works. also if you could post your 340-print-details that might help me also. you have the fields there to use but you are not adding or moving anything to them. so with the above statement you should add the bonus of each record/employee to a grand total field which will be printed when there are no more records.

This post has been edited by VB6cobolGuy: 15 November 2009 - 05:01 PM

Was This Post Helpful? 0
  • +
  • -

#10 53greek53  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 60
  • Joined: 27-November 08

Re: COBOL

Posted 15 November 2009 - 06:54 PM

I want it to print a annual salary total and a bonus total at the end of 10 records. Not at the end of all the records. So I want ten records then the totals then a new page. Here is what my output looks like right now. It is computing the total after every record instead of every 10. I will also post all my code again sorry I left some off before.

Bonus Report Page 1
Territory
Office
Employee Number Employee Name Hire Date Salary Bonus

Total040000 40
00001 ADAMSON 01/15/1993 40,000 400
Total050000 50
00002 BAKER 03/20/1994 50,000 500
Total100000 4,50
00003 CARTWELL 04/10/1995 100,000 4,500
Total045000 45
00004 DORSEY 02/02/1993 45,000 450
Total050000 2,25
00005 HAMMOND 05/05/1995 50,000 2,250
Total045000 45
00006 NOLTE 06/27/1993 45,000 450
Total048000 2,16
00007 REDFORD 11/01/1995 48,000 2,160
Total055000 55
00008 JOHNKE 01/15/1993 55,000 550
Total059000 59
00009 WHITE 06/20/1994 59,000 590

Bonus Report Page 2
Territory 01
Office 01
Employee Number Employee Name Hire Date Salary Bonus

Total053000 2,38
00010 MARSHALL 11/29/1996 53,000 2,385
Total053000 2,38
Total050000 50
00011 EISEN 09/28/1994 50,000 500
Total068000 3,06
00012 SAGER 07/25/1997 68,000 3,060
Total068000 68
00013 STERN 10/01/1994 68,000 680
Total067500 3,03
00014 SUMMERS 02/01/1995 67,500 3,037
Total040000 80
00015 JONES 05/05/1998 40,000 800
Total100000 2,00
00016 JOHNSON 08/01/1998 100,000 2,000
Total044750 44
00017 NOLAN 07/15/1993 44,750 447
Total068250 68
00018 CANTWELL 06/28/1993 68,250 682
Total075000 75
00019 SMITH 02/15/1993 75,000 750

	  *This Paragraph is the input data.
	   01 PAYROLL-MASTER.
		  05 EMPLOYEE-NO				 PIC X(5).
		  05 EMPLOYEE-NAME			   PIC X(20).
		  05 TERRITORY-NO				PIC X(2).
		  05 OFFICE-NO				   PIC X(2).
		  05 ANNUAL-SALARY			   PIC 9(6).
		  05 UNUSED					  PIC X(29).
		  05 DATE-HIRED.
			 10 Hired-Day				Pic x(2).
			 10 Hired-Month			  pic x(2).
			 10 Hired-Year			   pic 9(4).
				88 No-Bonus			  Value  1999.
				88 two-percent		   Value  1998.
				88 ten-percent		  Values  1900 thru 1994.
		  05 unused					  pic x(10).


	   FD  Payroll-Report
		   LABEL RECORDS ARE STANDARD
		   Record Contains 80 Characters
		   Data Record is Print-Rec.
	   01  Print-Rec					 pic x(80).

	   Working-Storage Section.
	   01 More-Data					  pic xxx value "yes".
	   01 Work-Areas.
		  05 ws-bonus					pic x(6).
		  05 ws-salary				   pic x(6).
		  05 employee-ctr				pic 99.
		  05 WS-Date.
			  10 CURRENT-year			pic 9999.
			  10 CURRENT-MONTH		   pic 99.
			  10 CURRENT-day			 pic 99.
		  05 Page-in.
			  10 WS-PAGE-CT			  pic 99 Value Zero.
			  10 WS-LINE-CT			  pic 99 Value Zero.

	   01 Heading-1.
		  05							 pic x(40) Value Spaces.
		  05							 pic x(2) Value Spaces.
		  05							 pic x(5) Value "Bonus".
		  05							 pic x(1) Value Spaces.
		  05							 pic x(6) Value "Report".
		  05							 pic x(7) Value Spaces.
		  05							 pic x(5) Value "Page".
		  05 PAGE-OUT					pic z9.
	   01 DATE-OUT.
			 10 MONTH-OUT				pic 99.
			 10						  pic x(1)  Value "/".
			 10 DAY-OUT				  pic 99.
			 10						  pic x(1)  Value "/".
			 10 YEAR-OUT				 pic 9999.

	   01 Heading-2.
		  05							 pic x(10) Value Spaces.
		  05							 pic x(9) Value "Territory".
		  05							 pic x(1) Value Spaces.
		  05 Territory-no				pic 99.
		  05							 pic x(58) Value Spaces.

	   01 Heading-3.
		  05							 pic x(10) Value Spaces.
		  05							 pic x(6) Value "Office".
		  05							 pic x(4) Value Spaces.
		  05 office-no				   pic 99.
		  05							 pic x(58) Value Spaces.

	   01 Heading-4.
		  05							 pic x(10) Value Spaces.
		  05							 pic x(8) Value "Employee".
		  05							 pic x(1) Value Spaces.
		  05							 pic x(6) Value "Number".
		  05							 pic x(3) Value Spaces.
		  05							 pic x(8) Value "Employee".
		  05							 pic x(1) Value Spaces.
		  05							 pic x(4) Value "Name".
		  05							 pic x(3) Value Spaces.
		  05							 pic x(4) Value "Hire".
		  05							 pic x(1) Value Spaces.
		  05							 pic x(4) Value "Date".
		  05							 pic x(3) Value Spaces.
		  05							 pic x(6) Value "Salary".
		  05							 pic x(3) Value Spaces.
		  05							 pic x(5) Value "Bonus".

	   01 Detail-Line.
		  05							 pic x(10) Value Spaces.
		  05 Employee-No				 pic x(5).
		  05							 pic x(13) Value Spaces.
		  05 Employee-Name			   pic x(15).
		  05							 pic x(1) Value Spaces.
		  05 Date-Hired.
			 10 Hired-Day				pic x(2).
			 10						  pic x(1) Value "/".
			 10 Hired-Month			  pic x(2).
			 10						  pic x(1) Value "/".
			 10 year-hired			   pic x(4).
		  05							 pic x(1) Value Spaces.
		  05 Emp-Salary				  pic zzz,zz9.
		  05							 pic x(1) Value Spaces.
		  05 Bonus					   pic zzz,zz9.
		  05							 pic x(3) Value Spaces.

	   01 Total-Line.
		  05							 pic x(50) Value Spaces.
		  05							 pic x(5) Value "Total".
		  05 office-total				pic x(6).
		  05							 pic x(2) Value Spaces.
		  05 bonus-total				 pic x(6).


	   PROCEDURE DIVISION.
	   100-Payroll.
		   Perform 200-HOUSEKEEPING
		   Perform 300-heading-rtn
		   Perform 3 times
			   Perform 2 times
					Perform
	   Varying employee-ctr from 1 by 1 until employee-ctr > 10
			   Read Payroll-List
				   At End
					   Move 'No' to More-Data
				   Not At End
				   Perform 220-Process-module
				   If employee-ctr = 0
				   perform 300-heading-rtn move
				   zeros to office-total
				   end-if
			   End-Read
			   End-Perform
			   perform 350-totals
			   End-Perform.
		   Perform 230-Finalize
		   Display "Program Finished"
		   Stop Run.




	   200-HOUSEKEEPING.
		   OPEN INPUT Payroll-List
			   Output Payroll-Report.
	   Perform 300-Date.

	   300-Date.
		   Move function current-date to ws-date
		   Move current-day to day-out
		   move current-month to month-out
		   move current-year to year-out.


	   220-Process-module.
	   if employee-ctr = 10 then perform 300-heading-rtn.
	   Perform 320-Bonus
	   move bonus to ws-bonus
	   move annual-salary to ws-salary
	   perform 350-totals
	   Perform 340-Print-Details.

	   230-finalize.
		   Close Payroll-List
			   Payroll-Report.

	   350-totals.
	   move ws-salary to office-total
	   move ws-bonus to bonus-total
	   move total-line to print-rec
	   write print-rec from total-line.



	   300-Heading-Rtn.
		   Add 1 to WS-PAGE-CT
		   MOVE WS-PAGE-CT to PAGE-OUT
		   WRITE PRINT-REC FROM HEADING-1 after advancing 1 line
		   WRITE PRINT-REC FROM HEADING-2 after advancing 1 line
		   WRITE PRINT-REC FROM HEADING-3 after advancing 1 line
		   Write PRINT-REC FROM HEADING-4 after advancing 1 line
				Move spaces to print-rec
				write print-rec
				after advancing 1 line
		   Move zeros to WS-LINE-CT.


	   320-Bonus.
	   Evaluate true
		  when no-bonus multiply annual-salary by 0 giving bonus
		  when two-percent multiply annual-salary by .02 giving bonus
		  when ten-percent multiply annual-salary by .010 giving bonus
		  when other multiply annual-salary by .045 giving bonus
	   end-evaluate.

	   340-print-details.
	   Move annual-salary to emp-salary
	   Move employee-no of payroll-master to employee-no of
	   detail-line
	   Move employee-name of payroll-master to employee-name of
	   detail-line
	   Move territory-no of payroll-master to territory-no of heading-2
	   move office-no of payroll-master to office-no of heading-3
	   move hired-day of payroll-master to hired-day of detail-line
	   move hired-month of payroll-master to hired-month of detail-line
	   move hired-year of payroll-master to year-hired of detail-line
	   Move detail-line to print-rec
	   Write Print-Rec
	   Add 1 to WS-LINE-CT.



Was This Post Helpful? 0
  • +
  • -

#11 cbwilson  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 5
  • Joined: 22-December 09

Re: COBOL

Posted 22 December 2009 - 10:20 PM

I am a little new to posting, but after reading your code it looks to me that you are short one 'end perform' and am catching the end of your double loop in your loop varying. Pop a 'end perform' right after 'end read'.

Bruce
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1