Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Producing a report

Status
Not open for further replies.

angie31

Technical User
Apr 26, 2001
1
US
I have to produce the following report:

We are going to write a program to produce a bonus report.

a. The payroll records have been sorted into ascending sequence by office number within territory number. There are an unknown number of territories, but every territory will have exactly two offices, and every office will have exactly 10 employees. Thus all employees within office 01 within territory 01 will appear before employee records for office 02 within territory 01, and so on.

b. Only employees who were hired before 1994 are entitled to a 10% bonus.

c. Print the names of all the employees and their bonuses. Print a separate page for each office within each territory. Use a nested PERFORM to achieve the page breaks for each office within each territory. (The WRITE...AFTER ADVANCING PAGE will issue a page break)

Record layout for the input file is as follows:

Field Name Size Type
Employee No. 5 Alphanumeric
Employee Name 20 Alphanumeric
Location Code: Group
Territory No. 2 Alphanumeric
Office No. 2 Alphanumeric
Annual Salary 6 Numeric (integer)
unused 29 Alphanumeric
Date Hired 6 Format: MMDDYY
unused 10 Alphanumeric
===========================================
Total Size of Rec 80


The following is the layout for the report. The first 9 lines are the headers. Line 11 describes the detail.
1 2 3 4 5 6
+0+0+0+0+0+0
1
2 BONUS REPORT PAGE 99
3 99/99/9999
4
5 TERRITORY — XX
6
7 OFFICE — XX
8
9 EMPLOYEE NAME BONUS
10
11 XXXXXXXXXXXXXXXXXXXX $ZZ,ZZZ.99


Extra Credit

For up to 10 point of extra credit you can modify the assignment 5 program to assume that the number employees is unknown. Also assume that the number of territories is unknown and the number of offices within each territory is unknown. If you choose to do the extra credit, complete the original assignment 5 as defined above. Then make a copy of the program and modify the copy to get the extra credit. You should then hand in the two programs.

This is what I've produced, however, it's not working, any insight on what I'm doing wrong would be helpful?

IDENTIFICATION DIVISION.
PROGRAM-ID. BNSRPT.
AUTHOR. AR.

ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT EMPLOYEE-FILE ASSIGN TO "C:\EMPPAYRL.TXT"
ORGANIZATION IS LINE SEQUENTIAL.
SELECT PRINT-FILE ASSIGN TO "C:\BONUS.TXT"
ORGANIZATION IS LINE SEQUENTIAL.

DATA DIVISION.
FILE SECTION.
FD EMPLOYEE-FILE
RECORD CONTAINS 80 CHARACTERS.
01 EMPLOYEE-INPUT-REC PIC X(80).

FD PRINT-FILE
RECORD CONTAINS 100 CHARACTERS.
01 PRINT-LINE PIC X(100).

WORKING-STORAGE SECTION.
01 EMPLOYEE-RECORD-IN.
05 EMPLOYEE-NO PIC X(5).
05 EMPLOYEE-NAME PIC X(20).
05 EMPLOYEE-LOCATION-CODE.
10 EMPLOYEE-TERRITORY-NO PIC X(2).
10 EMPLOYEE-OFFICE-NO PIC X(2).
05 EMPLOYEE-ANNUAL-SALARY PIC 9(6).
05 EMPLOYEE-HIRE-DATE.
10 EMP-HIRE-DATE-MM PIC X(2).
10 EMP-HIRE-DATE-DD PIC X(2).
10 EMP-HIRE-DATE-YY PIC X(2).
05 BONUS PIC X(6).

01 IND-BONUS-INFORMATION.
05 IND-BONUS PIC 9(2)V99 VALUE .10.

01 PROGRAM-SWITCHES.
05 WS-EMPLOYEE-EOF PIC X(1) VALUE 'N'.
05 DATA-REMAINS-SWITCH PIC X(2) VALUE SPACES.

01 PAGE-AND-LINE-COUNTERS.
05 LINE-COUNT PIC 9(2) VALUE 6.
05 PAGE-COUNT PIC 9(2) VALUE ZEROES.
05 LINES-PER-PAGE PIC 9(2) VALUE 10.

01 TODAYS-DATE-AREA.
05 TODAYS-MONTH PIC 99.
05 TODAYS-DAY PIC 99.
05 TODAYS-YEAR PIC 99.

01 HEADING-LINE-ONE.
05 FILLER PIC X(26) VALUE SPACES.
05 FILLER PIC X(12) VALUE 'BONUS REPORT'.
05 FILLER PIC X(22) VALUE SPACES.
05 FILLER PIC X(5) VALUE 'PAGE'.
05 HDG-PAGE-NUMBER PIC Z9.
05 FILLER PIC X(3) VALUE SPACES.

01 HEADING-LINE-TWO.
05 FILLER PIC X(55) VALUE SPACES.
05 HDG-DATE PIC X(8).
05 FILLER PIC X(3) VALUE SPACES.

01 HEADING-LINE-THREE.
05 FILLER PIC X(10) VALUE SPACES.
05 FILLER PIC X(16) VALUE ' TERRITORY - '.

01 HEADING-LINE-FOUR.
05 FILLER PIC X(15) VALUE SPACES.
05 FILLER PIC X(11) VALUE ' OFFICE - '.

01 HEADING-LINE-FIVE.
05 FILLER PIC X(10) VALUE SPACES.
05 FILLER PIC X(15) VALUE 'EMPLOYEE NAME -'.
05 FILLER PIC X(15) VALUE SPACES.
05 FILLER PIC X(5) VALUE 'BONUS'.
05 FILLER PIC X(2) VALUE SPACES.

01 DETAIL-LINE.
05 DET-EMPLOYEE-TERRITORY-NO PIC X(2).
05 FILLER PIC X(2) VALUE SPACES.
05 DET-EMPLOYEE-OFFICE-NO PIC X(2).
05 FILLER PIC X(2) VALUE SPACES.
05 DET-EMPLOYEE-NAME PIC X(20).
05 FILLER PIC X(10) VALUE SPACES.
05 DET-BONUS-AMOUNT PIC $ZZ,ZZZZ.99.

PROCEDURE DIVISION.
PREPARE-EMPLOYEE-INPUT-REC.
OPEN INPUT EMPLOYEE-FILE
OUTPUT PRINT-FILE.
PERFORM GET-TODAYS-DATE.
PERFORM UNTIL DATA-REMAINS-SWITCH = 'N'
READ EMPLOYEE-FILE INTO EMPLOYEE-RECORD-IN
AT END
MOVE 'N' TO DATA-REMAINS-SWITCH
NOT AT END
PERFORM PROCESS-EMPLOYEE-RECORD
END-READ
END-PERFORM.
CLOSE EMPLOYEE-FILE
PRINT-FILE.
STOP RUN.

GET-TODAYS-DATE.
ACCEPT TODAYS-DATE-AREA FROM DATE.
STRING TODAYS-MONTH '/' TODAYS-DAY '/' TODAYS-YEAR
DELIMITED BY SIZE INTO HDG-DATE
END-STRING.

PROCESS-EMPLOYEE-RECORD.
IF EMP-HIRE-DATE-YY <= 1994
MOVE EMPLOYEE-NAME TO DET-EMPLOYEE-NAME
WRITE PRINT-LINE.
COMPUTE IND-BONUS = EMPLOYEE-ANNUAL-SALARY * IND-BONUS
MOVE BONUS TO DET-BONUS-AMOUNT
PERFORM WRITE-DETAIL-LINE.

PROCESS-OFFICE.
MOVE EMPLOYEE-TERRITORY-NO TO DET-EMPLOYEE-TERRITORY-NO.
MOVE EMPLOYEE-OFFICE-NO TO DET-EMPLOYEE-OFFICE-NO.



WRITE-HEADING-LINE.
MOVE 1 TO LINE-COUNT.
ADD 1 TO PAGE-COUNT.
MOVE PAGE-COUNT TO HDG-PAGE-NUMBER.
WRITE PRINT-LINE FROM HEADING-LINE-ONE
AFTER ADVANCING PAGE.
WRITE PRINT-LINE FROM HEADING-LINE-TWO
AFTER ADVANCING 2 LINES.
WRITE PRINT-LINE FROM HEADING-LINE-THREE
AFTER ADVANCING 2 LINES.
WRITE PRINT-LINE FROM HEADING-LINE-FOUR
AFTER ADVANCING 2 LINES.
WRITE PRINT-LINE FROM HEADING-LINE-FIVE
AFTER ADVANCING 2 LINES.

WRITE-DETAIL-LINE.
MOVE TODAYS-DAY TO HDG-DATE.
MOVE TODAYS-MONTH TO HDG-DATE.
MOVE TODAYS-YEAR TO HDG-DATE.
MOVE EMPLOYEE-TERRITORY-NO TO DET-EMPLOYEE-TERRITORY-NO.
MOVE EMPLOYEE-OFFICE-NO TO DET-EMPLOYEE-OFFICE-NO.
MOVE EMPLOYEE-NAME TO DET-EMPLOYEE-NAME.
MOVE BONUS TO DET-BONUS-AMOUNT.
WRITE PRINT-LINE FROM DETAIL-LINE
AFTER ADVANCING 2 LINES.
ADD 1 TO LINE-COUNT.




 
Hi Angie,

Take a look at the FAQ submitted by &quot;slade&quot;. It discusses how to process data with control breaks in it. Most report pgms are centered around the &quot;control break&quot;. It may pay dividends if you took a step back to learn this very important and ubiquitous concept. If you have any questions in trying to understand this, just give a shout.

Regards, Jack.

 
Jack,

i recently directed someone to your FAQ on this subject as well, but i can't seem to find it anymore ! Do you have a clue to where it went ?

Regards,
Ronald.
 
So I'm not crazy! I tried to reference that FAQ myself just last week and couldn't find it. I was beginning to think I imagined ever seeing it in the first place! confusedlady
 
Got it !

It wasn't actually a FAQ but a Tip (the lightbulb category) with the name &quot;Control break construct&quot;, date: april 5 2001, poster: Slade.

Jack,

i don't want to push you or anything, but would it be an idea to actually make a FAQ out of that ? Because if that Q isn't F A, i don't no which is !

Regards,
Ronald.
 
Hi Ron,

I C&Ped it from the post to the FAQ. It should appear in a few days. I was dead certain I FAQed it, but when I went thru the process, it didn't seem familiar. I'll have to E Dave and apologize.

Thanx for the reminder, Jack.

 
Angie,

You are checking a 2 digit year field against 1994. The 2 digit year will always be less.
Shouldn't you have something like this?
IF EMP-HIRE-DATE-YY < 94 AND EMP-HIRE-DATE > 20
COMPUTE IND-BONUS = EMPLOYEE-ANNUAL-SALARY * IND-BONUS
ELSE
MOVE ZERO TO IND-BONUS.

I stuck the > 20 check in to account for year 2000 employees. Of course this would need to be changed in 2020. This is also assuming that NOBODY has been employed longer than 80 years.
Like Jack said, you also need to correct your control breaks. It doesn't look like you are writing headings at all. You can probably add your control break checks at the top of the PROCESS-EMPLOYEE-RECORD paragraph. How about a line counter as well? You also need a page counter.
Lastly, you have your territory, and office numbers on your detail line. According to your layout, you need these in your heading lines.

Good Luck!
Bob
 
Hello, everyone!

Angie, I assume you are taking a class. Have you gotten to tables/arrays yet? Have they told you about multi-dimensional tables? I've used them frequently for CICS map processing, where you want to have something such as 5 row, with each row having 10 elements.

With this program, you could have a 3-dimensional array, with the first dimension being the number of territories (this would either have to be variable-length or a fixed length with checks to make sure you don't over-fill the table and get an abend), the second dimension being the number of offices (a fixed table length of 2) and the third dimension being the number of employees in each office (a fixed table length of 10). Then you &quot;walk through&quot; each territory, each office, each employee. And pick out the ones who deserve bonuses.

Before I go into any more detail, let me know whether or not you have dealt with multi-dimensional arrays or not. If not, I'll come up with something else.

When you finally get to actually loading the records to be printed onto a print-file, then you will need to know how to do &quot;control breaks&quot; as the others have said.

Nina Too



 
BobSakamano was right on the money about comparing a 2-digit alphanumeric field to a 4-digit literal. However, you dont want &quot;AND EMP-HIRE-DATE > 20&quot;, you want EMP-HIRE-DATE-YY! (I'm sure it was a typo, and not an error, Bob! :) )

Tell your teacher that his/her file is NOT Y2K-compliant, and, accordingly, s/he, him/herself, will receive no bonus this year! *G*

Stephen J Spiro
Member, J4 COBOL Standards Committee
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top