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!

300 and 500 process

Status
Not open for further replies.

lostso

Technical User
Oct 22, 2002
13
US
i have a whole lot of errors in my 300 and 500 process can some one help me out?

Identification Division.
Program-ID. Assign-01.
Author. "Jessica Bennett".
Date-Written. "10-6-02"
* Remarks This Program Lists data, 80-80..

Environment Division.

Configuration Section.


Special-Names. C01 Is Next-Page.

Input-Output section.

File-control.

Select Data-file Assign to "A:Chdata04.dat"
Select Print-File assign to "A:File2.txt".

Data Division.

file section.

FD data-file.

01 Print-record Pic x(56).

Fd Print-file.
01 Print-record Pic x(80).

Working-Storage Section.

01 Data-Area.
05 PIC x Value Spaces.
05 Item-Number-Out PICTURE x(9).
05 PICTURE x(2) Value Spaces.
05 Item-Description-out PICTURE x(15).
05 PICTURE x(11) Value Spaces.
05 Quantity-Sold-out PICTURE ZZ9.
05 PICTURE x(9) Value Spaces.
05 Unit-Price-out PICTURE ZZ9.99.
05 PICTURE x(5) Value Spaces.
05 Sales-Date-out.
10 MO-OUT PIC 99.
10 PIC X.
10 DAY-OUT PIC 99.
10 PIC X.
10 YEAR-Out PIC 99.
05 PICTURE x(6) Value Spaces.
05 Salesman PICTURE x(2).


01 Print-record-In-Ws.
05 Pic x(10) Value Spaces.
05 Data-Area Pic x(55).
05 Pic x(15) Value Spaces.


01 name-record.
05 Pic x(50) Value Spaces.
05 Pic x(30) Value "Jessica Bennett".

01 WS-Date.
05 RUN-year PIC 99.
05 RUN-month Pic 99.
05 RUN-Day Pic 99.


01 Header-Record.
05 Header-date Pic x(8) value "10/17/02".
05 Pic x(25) Value Spaces.
05 Pic x(19) Value "Kitchen Industries".
05 Pic x(26) Value Spaces.
05 Pic x(5) Value "Page".
05 Page-Number-out pic Z9.


01 Record-Count-record.
05 Pic x(26)
Value "Total number of Records Is".
05 Record-Count-Out Pic ZZ9.

01 Counters.
05 Record-Count Pic S999 Value Zero packed-decimal.
05 Page-Number Pic S99 Value Zero packed-decimal.
05 Line-Count Pic S99 Value Zero packed-decimal.

01 Flags.
05 More-data-Flag Pic x(3) Value "Yes".
88 No-More-Data Value "no".

01 Header-01.
05 pic x(13) value "Current Date".
05 pic x(5) Value Spaces.
05 pic x(12) Value "Page Number".
05 pic x(6) Value Spaces.

01 Header-02.
05 Pic x(12) Value "Item Number".
05 Pic x(16) Value "Item Description".
05 Pic x(7) Value Spaces.
05 Pic x(14) value "Quantity Sold".
05 Pic x(8) Value Spaces.
05 Pic x(11) Value "Unit Price".
05 Pic x(9) Value Spaces.
05 Pic x(11) Value "Sales Date".
05 Pic x(5) Value Spaces.
05 Pic x(9) Value "Salesman".
05 Pic x(6) Value Spaces.

01 Detail-Line.
05 PICTURE x(1) Value Spaces.
05 Item-Number PICTURE x(9).
05 PICTURE x(2) Value Spaces.
05 Item-Description PICTURE x(15).
05 PICTURE x(11) Value Spaces.
05 Quantity-Sold PICTURE ZZ9.
05 PICTURE x(9) Value Spaces.
05 Unit-Price PICTURE ZZ9.99.
05 PICTURE x(5) Value Spaces.
05 Sales-Date.
10 MO-OUT PIC 99.
10 PIC X.
10 DAY-OUT PIC 99.
10 PIC X.
10 YEAR-Out PIC 99.
05 PICTURE x(6) Value Spaces.
05 Salesman PICTURE x(2).


Procedure Division.

100-Main-Line-routine.
Perform 200-Intialization-routine.
Perform 300-Process-routine
Until no-More-Data.
Perform 400-final-routine.
Stop run.

200-Initalization-routine.
Open Input Data-File
Output Print-file.
Perform 500-Header-Routine.
Read Data-File at End move "no"
to More-Data-flag.

300-Process-routine.
Move Data-record to data-area.
Move WS-Date from date.
move RUN-month to MO-OUT.
Move RUN-day to DAY-OUT.
Move RUN-year to YEAR-OUT.
Write Print-REc from Heading-record.
Move Print-record-In-ws to Print-Record.
Write Print-record after advancing 1 lines.
add 1 to record-count.
add 1 to line-Count.
If Line-count >56
Perform 500-Header-Routine
else
Next Sentence.
Read data-File at end Move "No"
To more-data-Flag.

400-Final-Routine.
Move record-Count to record-count-out.
Move record-Count-Record to Print-record.
Write Print-record after advancing 3 lines.
Close data-File, Print-File.

500-header-Routine.
Add 1 to Page-Number.
Move page-number to Page-number-out.
Move Header-01 to Print-Record.
Write Print-record after advancing 1 line.
Move Header-02 to Print-Record.
Write Print-Record after advancing 1 line.
Move Detail-Line to Print-Record.
Write Print-record after advancing 1 line.
Move name-record to Print-Record.
Write Print-record After advancing next-Page.
Move header-record to Print-Record.
Write Print-record after Advancing 2 lines.
Move Spaces to Print-Record.
write Print-record after advancing 3 Lines.
Move 7 to Line-count.
 
Well, Jessica, you've got several problems here to fix. We won't fix them all for you, but maybe we can point you in the right direction.

1. MOVE ... FROM ....
You can only MOVE ... TO, not FROM

2. DATA-RECORD doesn't seem to be defined? Likely in the DATA-FILE FD you meant to define it but defined PRINT-RECORD there instead? When you define it, be sure it reflects what the input record truly looks like, e.g.

Code:
       01 DATA-RECORD
        05 Item-Number          PICTURE x(9).
        05 Item-Description     PICTURE x(15).
        05 Quantity-Sold        PICTURE 999.
        05 Unit-Price           PICTURE 999V99.
        05 Sales-Date           PICTURE 9(6).
        05 Salesman             PICTURE x(2).
[\code]
BTW, most of us gave up typing PICTURE years ago; just use PIC; it's easier on the fingers :-)

Also, a trick that can help keep similarly named data items separate in your mind is to prefix them in some way.  For instance, in the data record, the ITEM-NUMBER could be called DR-ITEM-NUMBER while you call it PR-ITEM-NUMBER in PRINT-RECORD.

I think you'll also benefit by writing your program in smaller pieces.  Test it after each piece gets added to be sure it still works as it should.  Here's the first cut I would make at the program:

[code]
100-Main-Line-routine.
    Perform 200-Intialization-routine.
    Perform 300-Process-routine
        Until no-More-Data.
    Perform 400-final-routine.
    Stop run.

200-Initalization-routine.
    Open Input Data-File
         Output Print-file.
    Read Data-File at End move "no"
        to More-Data-flag.

300-Process-routine.
    Read data-File at end Move "No"
       To more-data-Flag.

40-Final-Routine.
    Close data-File, Print-File.
[\code]

Note that all it does is open the files, read all the input, and close the files.  BUT, getting that to work properly is a big first step.  After that you could consider adding the code to count the input records and write that result to the report.  Then consider adding the Header routine and perhaps simply print out just the ITEM-NUMBER on each record.  Finally you could develop the full print line and any computations that need to be made.

Developing "Top Down" in small pieces helps you focus on a one small step at a time and generally means that a bug that shows up is easy to find because it generally must have been introduced with the small changes you made last.

Good luck!

Glenn
Brainbench MVP for COBOL II
 
I just want to make sure I am on the right track
Identification Division.
Program-ID. Assign-01.
Author. "Jessica Bennett".
Date-Written. "10-6-02"
* Remarks This Program Lists data, 80-80..

Environment Division.

Configuration Section.


Special-Names. C01 Is Next-Page.

Input-Output section.

File-control.

Select Data-file Assign to "A:Chdata04.dat"
Select Print-File assign to "A:File2.cbl".

Data Division.

file section.

FD data-file.

01 Print-record Pic x(56).

Fd Print-file.
01 Print-record Pic x(80).

Working-Storage Section.

01 Data-Record.
05 PIC x Value Spaces.
05 DR-Item-Number PIC x(9).
05 PIC x(2) Value Spaces.
05 DR-Item-Description PIC x(15).
05 PIC x(11) Value Spaces.
05 DR-Quantity-Sold PIC ZZ9.
05 PIC x(9) Value Spaces.
05 DR-Unit-Price PIC ZZ9.99.
05 PIC x(5) Value Spaces.
05 DR-Sales-Date.
10 MO-OUT PIC 99.
10 PIC X.
10 DAY-OUT PIC 99.
10 PIC X.
10 YEAR-Out PIC 99.
05 PIC x(6) Value Spaces.
05 Salesman PIC x(2).


01 Print-record-In-Ws.
05 Pic x(10) Value Spaces.
05 Data-Area Pic x(55).
05 Pic x(15) Value Spaces.


01 name-record.
05 Pic x(50) Value Spaces.
05 Pic x(30) Value "Jessica Bennett".

01 WS-Date.
05 RUN-year PIC 99.
05 RUN-month Pic 99.
05 RUN-Day Pic 99.


01 Header-Record.
05 Header-date Pic x(8) value "10/17/02".
05 Pic x(25) Value Spaces.
05 Pic x(19) Value "Kitchen Industries".
05 Pic x(26) Value Spaces.
05 Pic x(5) Value "Page".
05 Page-Number-out pic Z9.


01 Record-Count-record.
05 Pic x(26)
Value "Total number of Records Is".
05 Record-Count-Out Pic ZZ9.

01 Counters.
05 Record-Count Pic S999 Value Zero packed-decimal.
05 Page-Number Pic S99 Value Zero packed-decimal.
05 Line-Count Pic S99 Value Zero packed-decimal.

01 Flags.
05 More-data-Flag Pic x(3) Value "Yes".
88 No-More-Data Value "no".

01 Header-01.
05 pic x(13) value "Current Date".
05 pic x(5) Value Spaces.
05 pic x(12) Value "Page Number".
05 pic x(6) Value Spaces.

01 Header-02.
05 Pic x(12) Value "Item Number".
05 Pic x(16) Value "Item Description".
05 Pic x(7) Value Spaces.
05 Pic x(14) value "Quantity Sold".
05 Pic x(8) Value Spaces.
05 Pic x(11) Value "Unit Price".
05 Pic x(9) Value Spaces.
05 Pic x(11) Value "Sales Date".
05 Pic x(5) Value Spaces.
05 Pic x(9) Value "Salesman".
05 Pic x(6) Value Spaces.

01 Detail-Line.
05 PICTURE x(1) Value Spaces.
05 Item-Number PICTURE x(9).
05 PICTURE x(2) Value Spaces.
05 Item-Description PICTURE x(15).
05 PICTURE x(11) Value Spaces.
05 Quantity-Sold PICTURE ZZ9.
05 PICTURE x(9) Value Spaces.
05 Unit-Price PICTURE ZZ9.99.
05 PICTURE x(5) Value Spaces.
05 Sales-Date.
10 MO-OUT PIC 99.
10 PIC X.
10 DAY-OUT PIC 99.
10 PIC X.
10 YEAR-Out PIC 99.
05 PICTURE x(6) Value Spaces.
05 Salesman PICTURE x(2).

01 Print-Record.
05 PIC x Value Spaces.
05 PR-Item-Number PIC x(9).
05 PIC x(2) Value Spaces.
05 PR-Item-Description PIC x(15).
05 PIC x(11) Value Spaces.
05 PR-Quantity-Sold PIC ZZ9.
05 PIC x(9) Value Spaces.
05 PR-Unit-Price PIC ZZ9.99.
05 PIC x(5) Value Spaces.
05 PR-Sales-Date.
10 PR-MO-OUT PIC 99.
10 PIC X.
10 PR-DAY-OUT PIC 99.
10 PIC X.
10 PR-YEAR-Out PIC 99.
05 PIC x(6) Value Spaces.
05 PR-Salesman PIC x(2).



Procedure Division.

100-Main-Line-routine.
Perform 200-Intialization-routine.
Perform 300-Process-routine
Until no-More-Data.
Perform 400-final-routine.
Stop run.

200-Initalization-routine.
Open Input Data-File
Output Print-file.
Perform 500-Header-Routine.
Read Data-File at End move "no"
to More-Data-flag.

300-Process-routine.
Move Data-record to data-area.
Move Print-record-In-ws to Print-Record.
Write Print-record after advancing 1 lines.
add 1 to record-count.
add 1 to line-Count.
If Line-count >56
Perform 500-Header-Routine
else
Next Sentence.
Read data-File at end Move "No"
To more-data-Flag.

400-Final-Routine.
Move record-Count to record-count-out.
Move record-Count-Record to Print-record.
Write Print-record after advancing 3 lines.
Close data-File, Print-File.

500-header-Routine.
Add 1 to Page-Number.
Move page-number to Page-number-out.
Move name-record to Print-Record.
Write Print-record After advancing next-Page.
Move header-record to Print-Record.
Write Print-record after Advancing 2 lines.
Move Spaces to Print-Record.
write Print-record after advancing 3 Lines.
Move 7 to Line-count.
 
Jessica -

You need to look at the DATA-FILE FD and record layout. Why did you call it PRINT-RECORD? Why did you not just put DATA-RECORD right there?

In a record you READ, you don't normally see editted, numeric PICTURE clauses (e.g. ZZ9). The editing is normally done only for printed output. A more usual situation is to define it as plain numeric (e.g. 999). If you look at your input file, don't the numeric data fields include leading zeros?

Also, look at your MOVEs in 300-. You're not going to get what you want. Here's the deal. READ places the data into the record area defined by the FD. You need to either define that record area properly, OR READ ... INTO a properly defined area, OR READ and then MOVE it to a properly defined area. THEN, you need to move each individual field from there to each output field in the print area (normally defined in WORKING-STORAGE). FINALLY, you can WRITE the print record FROM the working storage area.

Glenn
Brainbench MVP for COBOL II
 
I was being stupid. I figured it out. Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top