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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error 163 - illegal character in numeric field

Status
Not open for further replies.

Tifa

Programmer
Oct 13, 2002
10
US
I am trying to write a report generating program. It compiles but when I try to run it gives me error 163 which is illegal char in a numeric field. It then highlights "MOVE SR-PURCHASE-DATE TO DL-PURCHASE-DATE." The sr-purchase-date is pic 9(8) and the dl-purchase-date is z9/99/9999. it wont work either if I put 9(8) for the detail line. I dont know what the problem is, this may not even be it but it is what the compiler highlights when it wont run. What do i need to do?? Thanks!
 
Hi Tifa,

Welcome to debugging 101.

Rules:

1) Believe what the system is telling you. 99% of the time it's true.

2) Verify that your data is what you think it is. Is the data that you read into SR-PURCHASE-DATE numeric?

3) To verify use DISPLAY or print the input.


Try this:

READ but before the move, insert the following in your code

DISPLAY '>' SR-PURCHASE-DATE(1:8) '<'
DISPLAY '>' SR-PURCHASE-DATE '<'

Let us know what you get.

Regards, Jack.

 
I believe the info I am reading into sr-purchase-date is numeric. I read through the .dat file and all the dates are in MMDDYYYY format. I put the display commands you listed before the MOVE statement but it just displayed a screen that said:

>L. T. <
>L. T. <

What does that mean? I pasted the text of the program below if it will help. I am completely lost. :( Thanks for the help!


ENVIRONMENT DIVISION.
**********************

INPUT-OUTPUT SECTION.
**********************

FILE-CONTROL.

SELECT SALES-FILE
ASSIGN TO &quot;C:\COBOL\CUSTSALE.DAT&quot;.

SELECT SATISFACTION-REPORT
ASSIGN TO &quot;C:\COBOL\SATISFACTION.RPT&quot;.

DATA DIVISION.
***************

FILE SECTION.
**************

******************************************
INPUT-FILE - CUSTOMER SALES MASTER FILE

******************************************

FD SALES-FILE.

01 INPUT-RECORD PIC X(130).

**************************************
REPORT-FILE - SATISFACTION REPORT

**************************************

FD SATISFACTION-REPORT.

01 LINE-OUT PIC X(90).

WORKING-STORAGE SECTION.
************************

***************************************
SWITCHES

***************************************

01 SWITCHES.

02 SW-END-OF-FILE PIC X.
88 END-OF-FILE VALUE &quot;Y&quot;.

******************************************
ACCUMULATORS
******************************************

01 ACCUMULATORS.

02 AC-LINE-COUNT PIC 999.
02 AC-PAGE-COUNT PIC 999.
02 AC-TOTAL-CUSTOMERS PIC 999.
02 AC-TOTAL-PURCHASES PIC ZZZ,ZZ9.99.
02 AC-AVERAGE-PURCHASE-PRICE PIC ZZZ,ZZ9.99.

******************************************
WORK AREA FIELDS

******************************************

01 WORK-AREA.

02 WA-TODAYS-DATE-TIME.
03 WA-TODAYS-DATE.
04 WA-TODAYS-YEAR PIC 9(4).
04 WA-TODAYS-MONTH PIC 99.
04 WA-TODAYS-DAY PIC 99.
03 WA-TODAYS-TIME.
04 WA-TODAYS-HOUR PIC 99.
04 WA-TODAYS-MINUTES PIC 99.
03 PIC X(9).

02 WA-DATE.
03 WA-MONTH PIC 99.
03 WA-DAY PIC 99.
03 WA-YEAR PIC 9(4).

02 WA-RUN-DATE
REDEFINES WA-DATE PIC 9(8).

02 WA-ITEM-COST PIC 9(7)V99.

***********************************************
INPUT-FILE - CUSTOMER SALES FILE RECORD LAYOUT

***********************************************

01 SALES-RECORD.

02 SR-CUSTOMER-NUMBER PIC X(4).

02 SR-CUSTOMER-NAME PIC X(20).

02 SR-PURCHASE-DATE PIC 9(8).

02 SR-AUTO-MAKE PIC X(20).

02 SR-PURCHASE-PRICE PIC 9(5)V99.

02 SR-AUTO-YEAR PIC 9(4).

02 SR-SATISFACTION-RATING PIC X.
88 DISSATISFIED VALUE &quot;0&quot;.
88 UNDECIDED VALUE &quot;1&quot;.
88 SATISFIED VALUE &quot;2&quot;.

**********************************
REPORT HEADINGS
**********************************

01 REPORT-HEADING.

02 RH-LINE-1.
03 PIC X(6) VALUE &quot;DATE: &quot;.
03 RH-RUN-DATE PIC Z9/99/9999.
03 PIC X(22) VALUE SPACES.
03 PIC X(13) VALUE
&quot;EZ AUTO SALES&quot;.
03 PIC X(19) VALUE SPACES.
03 PIC X(5) VALUE &quot;PAGE &quot;.
03 RH-PAGE-COUNT PIC ZZ9.

02 RH-LINE-2.
03 PIC X(6) VALUE &quot;TIME: &quot;.
03 RH-HOUR PIC Z9.
03 PIC X VALUE &quot;:&quot;.
03 RH-MINUTES PIC XX.
03 PIC X VALUE SPACE.
03 RH-AM-PM PIC XX.
03 PIC X(19) VALUE SPACES.
03 PIC X(25) VALUE
&quot;SATISFIED CUSTOMER REPORT&quot;.
02 RH-LINE-3.
03 PIC X(15) VALUE
&quot;CUSTOMER NUMBER&quot;.
03 PIC X(2) VALUE SPACES.
03 PIC X(13) VALUE
&quot;CUSTOMER NAME&quot;.
03 PIC X(9) VALUE SPACES.
03 PIC X(13) VALUE
&quot;PURCHASE DATE&quot;.
03 PIC X(4) VALUE SPACES.
03 PIC X(14) VALUE
&quot;PURCHASE PRICE&quot;.
03 PIC X(3) VALUE SPACES.
03 PIC X(19) VALUE
&quot;SATISFACTION RATING&quot;.

02 RH-LINE-4.
03 PIC X(15) VALUE ALL &quot;-&quot;.
03 PIC X(2) VALUE SPACES.
03 PIC X(20) VALUE ALL &quot;-&quot;.
03 PIC X(9) VALUE SPACES.
03 PIC X(15) VALUE ALL &quot;-&quot;.
03 PIC X(4) VALUE SPACES.
03 PIC X(15) VALUE ALL &quot;-&quot;.
03 PIC X(3) VALUE SPACES.
03 PIC X(19) VALUE ALL &quot;-&quot;.
03 PIC X(3) VALUE SPACES.

************************************
DETAIL LINEs
************************************

01 DETAIL-LINE.

02 PIC X(2) VALUE SPACES.
02 DL-CUSTOMER-NUMBER PIC X(4).
02 PIC X(5) VALUE SPACES.
02 DL-CUSTOMER-NAME PIC X(20).
02 PIC X(8) VALUE SPACES.
02 DL-PURCHASE-DATE PIC Z9/99/9999.
02 PIC X(8) VALUE SPACES.
02 DL-PURCHASE-PRICE PIC $$$,$$$.99.
02 PIC X(7) VALUE SPACES.
02 DL-SATISFACTION-RATING PIC X.

*************************************
SUMMARY LINES
*************************************

01 SUMMARY-LINE.

02 SL-LINE-1.
03 PIC X(18) VALUE SPACES.
03 PIC X(25) VALUE &quot;TOTAL CUSTOMERS LISTED = &quot;.
03 PIC X(11) VALUE SPACES.
03 SL-RECORD-COUNT PIC 999.

02 SL-LINE-2.
03 PIC X(18) VALUE SPACES.
03 PIC X(25) VALUE &quot;TOTAL PURCHASES = &quot;.
03 SL-TOTAL-COST PIC $999,999.99.

02 SL-LINE-3.
03 PIC X(18) VALUE SPACES.
03 PIC X(25) VALUE &quot;AVERAGE PURCHASE PRICE = &quot;.
03 SL-AVERAGE-COST PIC $999,999.99.

02 SL-LINE-4.
03 PIC X(39) VALUE SPACES.
03 PIC X(13) VALUE &quot;END OF REPORT&quot;.

PROCEDURE DIVISION.
*******************

***********************************************
MAIN-PROGRAM.
***********************************************

MAIN-PROGRAM.

PERFORM A-100-INITIALIZATION.
PERFORM B-100-PROCESS-FILE.
PERFORM C-100-WRAP-UP.
STOP RUN.

**********************************************
HOUSEKEEPING PARAGRAPH FOLLOWS

**********************************************

A-100-INITIALIZATION.

INITIALIZE ACCUMULATORS.

MOVE FUNCTION CURRENT-DATE TO WA-TODAYS-DATE-TIME.
MOVE WA-TODAYS-MONTH TO WA-MONTH.
MOVE WA-TODAYS-DAY TO WA-DAY.
MOVE WA-TODAYS-YEAR TO WA-YEAR.
MOVE WA-RUN-DATE TO RH-RUN-DATE.

EVALUATE TRUE
WHEN WA-TODAYS-HOUR = 00
MOVE &quot;AM&quot; TO RH-AM-PM
MOVE 12 TO WA-TODAYS-HOUR
WHEN WA-TODAYS-HOUR < 12
MOVE &quot;AM&quot; TO RH-AM-PM
WHEN WA-TODAYS-HOUR = 12
MOVE &quot;PM&quot; TO RH-AM-PM
WHEN WA-TODAYS-HOUR > 12
MOVE &quot;PM&quot; TO RH-AM-PM
SUBTRACT 12 FROM WA-TODAYS-HOUR.
MOVE WA-TODAYS-HOUR TO RH-HOUR.
MOVE WA-TODAYS-MINUTES TO RH-MINUTES.

OPEN INPUT SALES-FILE
OUTPUT SATISFACTION-REPORT.

*************************************************
FILE PROCESSING CONTROL PARAGRAPH

*************************************************

B-100-PROCESS-FILE.

MOVE &quot;N&quot; TO SW-END-OF-FILE.

READ SALES-FILE INTO SALES-RECORD
AT END MOVE &quot;Y&quot; TO SW-END-OF-FILE.

PERFORM B-200-PROCESS-RECORD
UNTIL END-OF-FILE.

MOVE AC-TOTAL-CUSTOMERS TO SL-LINE-1.
MOVE AC-TOTAL-PURCHASES TO SL-LINE-2.
DIVIDE AC-TOTAL-PURCHASES BY AC-TOTAL-CUSTOMERS
GIVING AC-AVERAGE-PURCHASE-PRICE.

WRITE LINE-OUT FROM SL-LINE-1
AFTER ADVANCING 2 LINES.
WRITE LINE-OUT FROM SL-LINE-2
AFTER ADVANCING 1 LINE.
WRITE LINE-OUT FROM SL-LINE-3
AFTER ADVANCING 1 LINE.
WRITE LINE-OUT FROM SL-LINE-4
AFTER ADVANCING 2 LINES.

**********************************************
MOVE INPUT TO OUTPUT AREAS AND PRINT
**********************************************

B-200-PROCESS-RECORD.

IF AC-LINE-COUNT = 0
PERFORM B-300-PRINT-HEADINGS.

MOVE SR-CUSTOMER-NUMBER TO DL-CUSTOMER-NUMBER.
MOVE SR-CUSTOMER-NAME TO DL-CUSTOMER-NAME.
MOVE SR-PURCHASE-DATE TO DL-PURCHASE-DATE.
MOVE SR-PURCHASE-PRICE TO DL-PURCHASE-PRICE.
MOVE SR-SATISFACTION-RATING TO DL-SATISFACTION-RATING.

DIVIDE AC-TOTAL-PURCHASES BY AC-TOTAL-CUSTOMERS
GIVING AC-AVERAGE-PURCHASE-PRICE.
MOVE AC-AVERAGE-PURCHASE-PRICE TO SL-AVERAGE-COST.

WRITE LINE-OUT FROM DETAIL-LINE
AFTER ADVANCING 2 LINES.
ADD 2 TO AC-LINE-COUNT.
ADD 1 TO AC-TOTAL-CUSTOMERS.
ADD SR-PURCHASE-PRICE TO AC-TOTAL-PURCHASES
ON SIZE ERROR DISPLAY &quot;ACCUMULATOR TOO SMALL!&quot;.

IF AC-LINE-COUNT > 55
MOVE ZERO TO AC-LINE-COUNT.

READ SALES-FILE INTO SALES-RECORD
AT END MOVE &quot;Y&quot; TO SW-END-OF-FILE.

*********************************************
HEADINGS PARAGRAPH

*********************************************

B-300-PRINT-HEADINGS.

ADD 1 TO AC-PAGE-COUNT.
MOVE AC-PAGE-COUNT TO RH-PAGE-COUNT.
WRITE LINE-OUT FROM RH-LINE-1
AFTER ADVANCING PAGE.
WRITE LINE-OUT FROM RH-LINE-2
AFTER ADVANCING 1 LINE.
WRITE LINE-OUT FROM RH-LINE-3
AFTER ADVANCING 2 LINES.
WRITE LINE-OUT FROM RH-LINE-4
AFTER ADVANCING 1 LINE.
MOVE 4 TO AC-LINE-COUNT.

*********************************
END OF JOB PARAGRAPH

*********************************

C-100-WRAP-UP.

CLOSE SALES-FILE
SATISFACTION-REPORT.
DISPLAY &quot; &quot;.
DISPLAY &quot;CUSTOMER SATISFACTION REPORT PROGRAM HAS TERMINATED&quot;.
 
Hi Tifa,

What the displays show is that the date field in the input file contains the characters &quot;L.T.&quot; followed by 4 blanks. What that means is that the 1st record you read contains those 8 characters starting in pos 25.

Your code doesn't show the displays, but I assume they're positioned properly. Your code looks like it would display a date if it were present in the i/p rec.

Some possibilities:

1) The file might have a header rec and the header contains text w/&quot;L.T.&quot; in it at the date position.
2) You misspelled the file name and are reading the wrong file in the pgm.

If it's not one of those, I'm stumped.

Regards, Jack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top