When i run the following code it it gives me the following error: illegal character in numeric field. This program is a validation program, here an example of the incoming records:
Hhhhhhh 0BEEOOlOOO9995556OOlOO
Aaaaaaa lBAN012340O122220054320000
Can you please give me a hint on how to fix this, Thanks A lot
IDENTIFICATION DIVISION.
PROGRAM-ID. Project8-8stubs.
AUTHOR. Nathan.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT STOCK-FILE ASSIGN TO 'C:\cobol\prj08-08.dat'
ORGANIZATION IS LINE SEQUENTIAL.
SELECT ERROR-FILE ASSIGN TO 'C:\cobol\error.txt'
ORGANIZATION IS LINE SEQUENTIAL.
SELECT VALID-FILE ASSIGN TO 'C:\cobol\valid.txt'
ORGANIZATION IS LINE SEQUENTIAL.
DATA DIVISION.
FILE SECTION.
FD STOCK-FILE
RECORD CONTAINS 34 CHARACTERS
DATA RECORD IS STOCK-RECORD-IN.
01 STOCK-RECORD-IN.
05 STOCK-INFO.
10 STOCK-NAME PIC X(8).
10 STOCK-EXCHANGE-CODE PIC 9.
88 VALID-EXCHANGE-CODE VALUES 1 THRU 4.
10 STOCK-INDUSTRY-CODE PIC X(3).
88 VALID-INDUST-CODE VALUES 'AIR' 'AUT' 'BAN' 'BEE' 'CMP' 'DRU' 'ELE' 'F&L' 'FOO' 'OIL' 'RET' 'S&L' 'TEL'.
05 STOCK-CURRENT-INFO.
10 STOCK-PRICE PIC 999V999.
10 STOCK-PE PIC 9(3).
10 STOCK-DIVIDEND PIC 9V99.
05 STOCK-PROJECTION-INFO.
10 STOCK-RISK-CODE PIC 9.
88 VALID-RISK-CODE VALUES 1 THRU 5.
10 STOCK-GROWTH-RATE PIC 9V9(4).
88 VALID-GROWTH-RATE VALUES .01 THRU 1.
10 STOCK-SHARES-TO-BUY PIC 9(4).
FD ERROR-FILE
RECORD CONTAINS 132 CHARACTERS
DATA RECORD IS ERROR-RECORD-OUT.
01 ERROR-RECORD-OUT PIC X(132).
FD VALID-FILE
RECORD CONTAINS 132 CHARACTERS
DATA RECORD IS VALID-RECORD-OUT.
01 VALID-RECORD-OUT PIC X(132).
WORKING-STORAGE SECTION.
01 NO-DATA-REMAINS-SWITCH PIC X(3) VALUE SPACES.
01 STOCK-PURCHASE-PRICE PIC 9(10) VALUE ZEROS.
PROCEDURE DIVISION.
100-PREPARE-PROGRAMMER-REPORT.
OPEN INPUT STOCK-FILE
OUTPUT ERROR-FILE
VALID-FILE.
PERFORM 200-PROCESS-CUST-RECORDS
UNTIL NO-DATA-REMAINS-SWITCH = 'YES'.
CLOSE STOCK-FILE
ERROR-FILE
VALID-FILE.
STOP RUN.
200-PROCESS-CUST-RECORDS.
READ STOCK-FILE
AT END
MOVE 'YES' TO NO-DATA-REMAINS-SWITCH
NOT AT END
PERFORM 210-PROCESS-EACH-RECORD
END-READ.
210-PROCESS-EACH-RECORD.
IF STOCK-NAME = SPACES
MOVE 'ERROR1' TO ERROR-RECORD-OUT
END-IF
IF STOCK-EXCHANGE-CODE NOT NUMERIC
MOVE 'ERROR2' TO ERROR-RECORD-OUT
END-IF
IF NOT VALID-EXCHANGE-CODE
MOVE 'ERROR3' TO ERROR-RECORD-OUT
END-IF
IF NOT VALID-INDUST-CODE
MOVE 'ERROR4' TO ERROR-RECORD-OUT
END-IF
IF STOCK-PE NOT NUMERIC
MOVE 'ERROR5' TO ERROR-RECORD-OUT
END-IF
IF STOCK-DIVIDEND NOT NUMERIC
MOVE 'ERROR6' TO ERROR-RECORD-OUT
END-IF
IF STOCK-PRICE NOT NUMERIC
MOVE 'ERROR7' TO ERROR-RECORD-OUT
ELSE
IF STOCK-PRICE IS ZERO
MOVE 'ERROR9' TO ERROR-RECORD-OUT
END-IF
IF STOCK-SHARES-TO-BUY NOT NUMERIC
MOVE 'ERROR8' TO ERROR-RECORD-OUT
ELSE
IF STOCK-SHARES-TO-BUY = ZEROS
MOVE 'ERROR10' TO ERROR-RECORD-OUT
END-IF
COMPUTE STOCK-PURCHASE-PRICE = STOCK-PRICE *
STOCK-SHARES-TO-BUY
IF STOCK-PURCHASE-PRICE > 25000
MOVE 'ERROR11' TO ERROR-RECORD-OUT
END-IF
IF STOCK-RISK-CODE NOT NUMERIC
MOVE 'ERROR12' TO ERROR-RECORD-OUT
END-IF
IF STOCK-GROWTH-RATE NOT NUMERIC
MOVE 'ERROR13' TO ERROR-RECORD-OUT
END-IF
IF NOT VALID-RISK-CODE
MOVE 'ERROR14' TO ERROR-RECORD-OUT
END-IF
IF NOT VALID-GROWTH-RATE
MOVE 'ERROR15' TO ERROR-RECORD-OUT
END-IF
WRITE ERROR-RECORD-OUT.
Hhhhhhh 0BEEOOlOOO9995556OOlOO
Aaaaaaa lBAN012340O122220054320000
Can you please give me a hint on how to fix this, Thanks A lot
IDENTIFICATION DIVISION.
PROGRAM-ID. Project8-8stubs.
AUTHOR. Nathan.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT STOCK-FILE ASSIGN TO 'C:\cobol\prj08-08.dat'
ORGANIZATION IS LINE SEQUENTIAL.
SELECT ERROR-FILE ASSIGN TO 'C:\cobol\error.txt'
ORGANIZATION IS LINE SEQUENTIAL.
SELECT VALID-FILE ASSIGN TO 'C:\cobol\valid.txt'
ORGANIZATION IS LINE SEQUENTIAL.
DATA DIVISION.
FILE SECTION.
FD STOCK-FILE
RECORD CONTAINS 34 CHARACTERS
DATA RECORD IS STOCK-RECORD-IN.
01 STOCK-RECORD-IN.
05 STOCK-INFO.
10 STOCK-NAME PIC X(8).
10 STOCK-EXCHANGE-CODE PIC 9.
88 VALID-EXCHANGE-CODE VALUES 1 THRU 4.
10 STOCK-INDUSTRY-CODE PIC X(3).
88 VALID-INDUST-CODE VALUES 'AIR' 'AUT' 'BAN' 'BEE' 'CMP' 'DRU' 'ELE' 'F&L' 'FOO' 'OIL' 'RET' 'S&L' 'TEL'.
05 STOCK-CURRENT-INFO.
10 STOCK-PRICE PIC 999V999.
10 STOCK-PE PIC 9(3).
10 STOCK-DIVIDEND PIC 9V99.
05 STOCK-PROJECTION-INFO.
10 STOCK-RISK-CODE PIC 9.
88 VALID-RISK-CODE VALUES 1 THRU 5.
10 STOCK-GROWTH-RATE PIC 9V9(4).
88 VALID-GROWTH-RATE VALUES .01 THRU 1.
10 STOCK-SHARES-TO-BUY PIC 9(4).
FD ERROR-FILE
RECORD CONTAINS 132 CHARACTERS
DATA RECORD IS ERROR-RECORD-OUT.
01 ERROR-RECORD-OUT PIC X(132).
FD VALID-FILE
RECORD CONTAINS 132 CHARACTERS
DATA RECORD IS VALID-RECORD-OUT.
01 VALID-RECORD-OUT PIC X(132).
WORKING-STORAGE SECTION.
01 NO-DATA-REMAINS-SWITCH PIC X(3) VALUE SPACES.
01 STOCK-PURCHASE-PRICE PIC 9(10) VALUE ZEROS.
PROCEDURE DIVISION.
100-PREPARE-PROGRAMMER-REPORT.
OPEN INPUT STOCK-FILE
OUTPUT ERROR-FILE
VALID-FILE.
PERFORM 200-PROCESS-CUST-RECORDS
UNTIL NO-DATA-REMAINS-SWITCH = 'YES'.
CLOSE STOCK-FILE
ERROR-FILE
VALID-FILE.
STOP RUN.
200-PROCESS-CUST-RECORDS.
READ STOCK-FILE
AT END
MOVE 'YES' TO NO-DATA-REMAINS-SWITCH
NOT AT END
PERFORM 210-PROCESS-EACH-RECORD
END-READ.
210-PROCESS-EACH-RECORD.
IF STOCK-NAME = SPACES
MOVE 'ERROR1' TO ERROR-RECORD-OUT
END-IF
IF STOCK-EXCHANGE-CODE NOT NUMERIC
MOVE 'ERROR2' TO ERROR-RECORD-OUT
END-IF
IF NOT VALID-EXCHANGE-CODE
MOVE 'ERROR3' TO ERROR-RECORD-OUT
END-IF
IF NOT VALID-INDUST-CODE
MOVE 'ERROR4' TO ERROR-RECORD-OUT
END-IF
IF STOCK-PE NOT NUMERIC
MOVE 'ERROR5' TO ERROR-RECORD-OUT
END-IF
IF STOCK-DIVIDEND NOT NUMERIC
MOVE 'ERROR6' TO ERROR-RECORD-OUT
END-IF
IF STOCK-PRICE NOT NUMERIC
MOVE 'ERROR7' TO ERROR-RECORD-OUT
ELSE
IF STOCK-PRICE IS ZERO
MOVE 'ERROR9' TO ERROR-RECORD-OUT
END-IF
IF STOCK-SHARES-TO-BUY NOT NUMERIC
MOVE 'ERROR8' TO ERROR-RECORD-OUT
ELSE
IF STOCK-SHARES-TO-BUY = ZEROS
MOVE 'ERROR10' TO ERROR-RECORD-OUT
END-IF
COMPUTE STOCK-PURCHASE-PRICE = STOCK-PRICE *
STOCK-SHARES-TO-BUY
IF STOCK-PURCHASE-PRICE > 25000
MOVE 'ERROR11' TO ERROR-RECORD-OUT
END-IF
IF STOCK-RISK-CODE NOT NUMERIC
MOVE 'ERROR12' TO ERROR-RECORD-OUT
END-IF
IF STOCK-GROWTH-RATE NOT NUMERIC
MOVE 'ERROR13' TO ERROR-RECORD-OUT
END-IF
IF NOT VALID-RISK-CODE
MOVE 'ERROR14' TO ERROR-RECORD-OUT
END-IF
IF NOT VALID-GROWTH-RATE
MOVE 'ERROR15' TO ERROR-RECORD-OUT
END-IF
WRITE ERROR-RECORD-OUT.