Guest_imported
New member
- Jan 1, 1970
- 0
i have this small program, and it seems to have runtime errors, can someone please help, THANKS
IDENTIFICATION DIVISION.
PROGRAM-ID. Project-2.
AUTHOR. Nathan.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT ORDER-TRANSACTION-FILE ASSIGN TO
'C:\cobol\PRJ02-01.DAT'
ORGANIZATION IS LINE SEQUENTIAL.
SELECT PRINT-FILE ASSIGN TO 'C:\cobol\output.txt'.
DATA DIVISION.
FILE SECTION.
FD ORDER-TRANSACTION-FILE
RECORD CONTAINS 17 CHARACTERS
DATA RECORD IS ORDER-TRANSACTION-RECORD.
01 ORDER-IN.
05 CUST-NO PIC X(8).
05 FILLER PIC X(1).
05 ORD-QTY PIC XXX.
05 ITEM-NUMBER.
10 ITEM-SERIES PIC X.
10 REST-NUMBERS PIC X(4).
FD PRINT-FILE
RECORD CONTAINS 132 CHARACTERS
DATA RECORD IS PRINT-LINE.
01 PRINT-LINE.
05 FILLER PIC X.
05 PRINT-NO PIC X(8).
05 FILLER PIC X(2).
05 PRINT-ITEM-NO PIC X(5).
05 FILLER PIC X(3).
05 PRINT-QTY PIC 9(3).
05 FILLER PIC X(7).
05 PRINT-DISCOUNT PIC 99.
05 FILLER PIC X(101).
WORKING-STORAGE SECTION.
01 END-OF-DATA-FLAG PIC X(3) VALUE SPACES.
01 HEADING-LINE.
05 FILLER PIC X.
05 CUSTOMER-NO PIC X(8) VALUE 'Customer'.
05 FILLER PIC XX.
05 ITEM PIC X(4) VALUE 'Item'.
05 FILLER PIC X(4).
05 QTY PIC X(3) VALUE 'Qty'.
05 FILLER PIC X(3).
05 DISCOUNT PIC X(8) VALUE 'Discount'.
01 DETAIL-LINE.
05 FILLER PIC XX.
05 NUM PIC X(6) VALUE 'Number'.
05 FILLER PIC XX.
05 NUM2 PIC X(6) VALUE 'Number'.
05 FILLER PIC X.
05 ORDERED PIC X(7) VALUE 'Ordered'.
05 FILLER PIC XX.
05 PERCENT PIC X(7) VALUE 'Percent'.
PROCEDURE DIVISION.
100-PREPARE-PROGRAMMER-REPORT.
OPEN INPUT ORDER-TRANSACTION-FILE
OUTPUT PRINT-FILE.
PERFORM 300-WRITE-HEADER
READ ORDER-TRANSACTION-FILE
AT END MOVE 'YES' TO END-OF-DATA-FLAG
END-READ.
PERFORM 200-PROCESS-CUST-RECORDS
UNTIL END-OF-DATA-FLAG = 'YES'.
CLOSE ORDER-TRANSACTION-FILE
PRINT-FILE.
STOP RUN.
200-PROCESS-CUST-RECORDS.
IF ITEM-SERIES = '1' OR ITEM-SERIES = '2'
IF ORD-QTY <= 100
MOVE '00' TO PRINT-DISCOUNT
MOVE CUST-NO TO PRINT-NO
MOVE ORD-QTY TO PRINT-QTY
MOVE ITEM-NUMBER TO PRINT-ITEM-NO
ELSE
IF ORD-QTY > 100 AND ORD-QTY <= 500
MOVE '10' TO PRINT-DISCOUNT
MOVE CUST-NO TO PRINT-NO
MOVE ORD-QTY TO PRINT-QTY
MOVE ITEM-NUMBER TO PRINT-ITEM-NO
ELSE
IF ORD-QTY > 500 AND ORD-QTY <= 999
MOVE '20' TO PRINT-DISCOUNT
MOVE CUST-NO TO PRINT-NO
MOVE ORD-QTY TO PRINT-QTY
MOVE ITEM-NUMBER TO PRINT-ITEM-NO
END-IF
WRITE PRINT-LINE
ELSE
IF ITEM-SERIES = '3' OR ITEM-SERIES = '4' OR ITEM-SERIES =
'5'
IF ORD-QTY <= 50
MOVE '00' TO PRINT-DISCOUNT
MOVE CUST-NO TO PRINT-NO
MOVE ORD-QTY TO PRINT-QTY
MOVE ITEM-NUMBER TO PRINT-ITEM-NO
ELSE
IF ORD-QTY > 50 AND ORD-QTY <= 100
MOVE '15' TO PRINT-DISCOUNT
MOVE CUST-NO TO PRINT-NO
MOVE ORD-QTY TO PRINT-QTY
MOVE ITEM-NUMBER TO PRINT-ITEM-NO
ELSE
IF ORD-QTY > 100 AND ORD-QTY <= 500
MOVE '20' TO PRINT-DISCOUNT
MOVE CUST-NO TO PRINT-NO
MOVE ORD-QTY TO PRINT-QTY
MOVE ITEM-NUMBER TO PRINT-ITEM-NO
ELSE
IF ORD-QTY > 500 AND ORD-QTY <=999
MOVE '25' TO PRINT-DISCOUNT
MOVE CUST-NO TO PRINT-NO
MOVE ORD-QTY TO PRINT-QTY
MOVE ITEM-NUMBER TO PRINT-ITEM-NO
END-IF
WRITE PRINT-LINE
END-IF
READ ORDER-TRANSACTION-FILE
AT END MOVE 'YES' TO END-OF-DATA-FLAG
END-READ.
300-WRITE-HEADER.
MOVE HEADING-LINE TO PRINT-LINE
WRITE PRINT-LINE.
MOVE DETAIL-LINE TO PRINT-LINE
WRITE PRINT-LINE.
IDENTIFICATION DIVISION.
PROGRAM-ID. Project-2.
AUTHOR. Nathan.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT ORDER-TRANSACTION-FILE ASSIGN TO
'C:\cobol\PRJ02-01.DAT'
ORGANIZATION IS LINE SEQUENTIAL.
SELECT PRINT-FILE ASSIGN TO 'C:\cobol\output.txt'.
DATA DIVISION.
FILE SECTION.
FD ORDER-TRANSACTION-FILE
RECORD CONTAINS 17 CHARACTERS
DATA RECORD IS ORDER-TRANSACTION-RECORD.
01 ORDER-IN.
05 CUST-NO PIC X(8).
05 FILLER PIC X(1).
05 ORD-QTY PIC XXX.
05 ITEM-NUMBER.
10 ITEM-SERIES PIC X.
10 REST-NUMBERS PIC X(4).
FD PRINT-FILE
RECORD CONTAINS 132 CHARACTERS
DATA RECORD IS PRINT-LINE.
01 PRINT-LINE.
05 FILLER PIC X.
05 PRINT-NO PIC X(8).
05 FILLER PIC X(2).
05 PRINT-ITEM-NO PIC X(5).
05 FILLER PIC X(3).
05 PRINT-QTY PIC 9(3).
05 FILLER PIC X(7).
05 PRINT-DISCOUNT PIC 99.
05 FILLER PIC X(101).
WORKING-STORAGE SECTION.
01 END-OF-DATA-FLAG PIC X(3) VALUE SPACES.
01 HEADING-LINE.
05 FILLER PIC X.
05 CUSTOMER-NO PIC X(8) VALUE 'Customer'.
05 FILLER PIC XX.
05 ITEM PIC X(4) VALUE 'Item'.
05 FILLER PIC X(4).
05 QTY PIC X(3) VALUE 'Qty'.
05 FILLER PIC X(3).
05 DISCOUNT PIC X(8) VALUE 'Discount'.
01 DETAIL-LINE.
05 FILLER PIC XX.
05 NUM PIC X(6) VALUE 'Number'.
05 FILLER PIC XX.
05 NUM2 PIC X(6) VALUE 'Number'.
05 FILLER PIC X.
05 ORDERED PIC X(7) VALUE 'Ordered'.
05 FILLER PIC XX.
05 PERCENT PIC X(7) VALUE 'Percent'.
PROCEDURE DIVISION.
100-PREPARE-PROGRAMMER-REPORT.
OPEN INPUT ORDER-TRANSACTION-FILE
OUTPUT PRINT-FILE.
PERFORM 300-WRITE-HEADER
READ ORDER-TRANSACTION-FILE
AT END MOVE 'YES' TO END-OF-DATA-FLAG
END-READ.
PERFORM 200-PROCESS-CUST-RECORDS
UNTIL END-OF-DATA-FLAG = 'YES'.
CLOSE ORDER-TRANSACTION-FILE
PRINT-FILE.
STOP RUN.
200-PROCESS-CUST-RECORDS.
IF ITEM-SERIES = '1' OR ITEM-SERIES = '2'
IF ORD-QTY <= 100
MOVE '00' TO PRINT-DISCOUNT
MOVE CUST-NO TO PRINT-NO
MOVE ORD-QTY TO PRINT-QTY
MOVE ITEM-NUMBER TO PRINT-ITEM-NO
ELSE
IF ORD-QTY > 100 AND ORD-QTY <= 500
MOVE '10' TO PRINT-DISCOUNT
MOVE CUST-NO TO PRINT-NO
MOVE ORD-QTY TO PRINT-QTY
MOVE ITEM-NUMBER TO PRINT-ITEM-NO
ELSE
IF ORD-QTY > 500 AND ORD-QTY <= 999
MOVE '20' TO PRINT-DISCOUNT
MOVE CUST-NO TO PRINT-NO
MOVE ORD-QTY TO PRINT-QTY
MOVE ITEM-NUMBER TO PRINT-ITEM-NO
END-IF
WRITE PRINT-LINE
ELSE
IF ITEM-SERIES = '3' OR ITEM-SERIES = '4' OR ITEM-SERIES =
'5'
IF ORD-QTY <= 50
MOVE '00' TO PRINT-DISCOUNT
MOVE CUST-NO TO PRINT-NO
MOVE ORD-QTY TO PRINT-QTY
MOVE ITEM-NUMBER TO PRINT-ITEM-NO
ELSE
IF ORD-QTY > 50 AND ORD-QTY <= 100
MOVE '15' TO PRINT-DISCOUNT
MOVE CUST-NO TO PRINT-NO
MOVE ORD-QTY TO PRINT-QTY
MOVE ITEM-NUMBER TO PRINT-ITEM-NO
ELSE
IF ORD-QTY > 100 AND ORD-QTY <= 500
MOVE '20' TO PRINT-DISCOUNT
MOVE CUST-NO TO PRINT-NO
MOVE ORD-QTY TO PRINT-QTY
MOVE ITEM-NUMBER TO PRINT-ITEM-NO
ELSE
IF ORD-QTY > 500 AND ORD-QTY <=999
MOVE '25' TO PRINT-DISCOUNT
MOVE CUST-NO TO PRINT-NO
MOVE ORD-QTY TO PRINT-QTY
MOVE ITEM-NUMBER TO PRINT-ITEM-NO
END-IF
WRITE PRINT-LINE
END-IF
READ ORDER-TRANSACTION-FILE
AT END MOVE 'YES' TO END-OF-DATA-FLAG
END-READ.
300-WRITE-HEADER.
MOVE HEADING-LINE TO PRINT-LINE
WRITE PRINT-LINE.
MOVE DETAIL-LINE TO PRINT-LINE
WRITE PRINT-LINE.