Cobol使用Unix系统的illegal character in numeric field报错关注什么?

What does illegal character in numeric field error concern for Cobol using Unix system?

如何解决错误:

执行错误:文件'prog3.int'

错误代码:163,pc=177,call=1,seg=0

163 数字字段中的非法字符

            IDENTIFICATION DIVISION.
    PROGRAM-ID. prog3.      


    ENVIRONMENT DIVISION.
    Input-output Section.
    File-Control.
            select input-file assign to 
              "/home1/c/a/acsi203/realestate.dat".
            select output-file assign to "prog3out.dat"
               organization is line sequential.


    DATA    DIVISION.
    File    Section.
    FD      Input-File.
    01      INPUT-REC.
            02 PropertyAddress  pic x(27).
            02 City             pic a(15).
            02 Zip              pic 9(5).
            02 State            pic a(2).
            02 Bedrooms         pic 9.
            02 Bathrooms        pic 9.
            02 SqFt             pic 9(4).
            02 PropertyType     pic x(8).
            02 SaleDayofWeek    pic a(3).
            02 Filler           pic x(1).
            02 SaleMonth        pic a(3).
            02 Filler           pic x(1).
            02 SaleDay          pic 9(2).
            02 Filler           pic x(1).
            02 SaleHour         pic 9(2).
            02 Filler           pic x(1).
            02 SaleMinute       pic 9(2).
            02 Filler           pic x(1).
            02 SaleSecond       pic 9(2).
            02 Filler           pic x(1).
            02 TimeZone         pic a(3).
            02 Filler           pic x(1).
            02 SaleYear         pic 9(4).
            02 SalePrice        pic 9(6).
            02 Filler           pic x(18).

    FD  OUTPUT-FILE.
    01  OUTPUT-REC              pic x(114).


    WORKING-STORAGE SECTION.
    01 REPORT-HEADER.

            02 Filler           pic x(27) value spaces.
            02 Filler           pic x(66) value 
              "Sacramento Area Real Estate Transactions-MM/DD/YYYY".
            02 Filler           pic x(61) value spaces.
    01 RECORDS-PROCESSED.
            02 Filler           pic x(28) value 
                    "Number Of Records Processed:".
            02 num-recs         pic 9(4)   value 0.
            02 Filler           pic x(15) value spaces.
    01 AVERAGE-PROCESSED.
            02 Filler           pic x(9)  value
                    "Average: ".
            02 num-nonzero      pic 9(4) value 0.
            02 Filler           pic x(45) value spaces.
            02 BedroomAverage-out pic x(1).
            02 Filler           pic x(10) value spaces.
            02 BathroomAverage-out pic x(1).
            02 Filler           pic x(18) value spaces.
            02 SqFtAverage-out  pic $ZZ,ZZ9.99.
            02 Filler           pic x(4) value spaces.
            02 SalePriceAverage-out pic $ZZ,ZZ9.99.
    01 END-OF-REPORT.
            02 Filler           pic x(13) value
                    "End Of Report".

    01 COLUMN-HEADER.
            02 Filler           pic x(2)  value spaces.
            02 Filler           pic x(16) value "Property Address".
            02 Filler           pic x(10) value spaces.
            02 Filler           pic x(4)  value "City".
            02 Filler           pic x(10) value spaces.
            02 Filler           pic x(5)  value "Zip".
            02 Filler           pic x(1)  value spaces.
            02 Filler           pic x(5)  value "State".
            02 Filler           pic x(2)  value spaces.
            02 Filler           pic x(8)  value "Bedrooms".
            02 Filler           pic x(3)  value spaces.
            02 Filler           pic x(9)  value "Bathrooms".
            02 Filler           pic x(2)  value spaces.
            02 Filler           pic x(4) value "SqFt".
            02 Filler           pic x(1)  value spaces.
            02 Filler           pic x(13) value "Property Type".
            02 Filler           pic x(1)  value spaces.
            02 Filler           pic x(13) value "SaleDayOfWeek".
            02 Filler           pic x(1)  value spaces.
            02 Filler           pic x(9)  value "SaleMonth".
            02 Filler           pic x(1)  value spaces.
            02 Filler           pic x(7)  value "SaleDay".
            02 Filler           pic x(1)  value spaces.
            02 Filler           pic x(8)  value "SaleHour".
            02 Filler           pic x(1)  value spaces.
            02 Filler           pic x(10) value "SaleMinute".
            02 Filler           pic x(1)  value spaces.
            02 Filler           pic x(10)  value "SaleSecond".
            02 Filler           pic x(1)  value spaces.
            02 Filler           pic x(8)  value "TimeZone".
            02 Filler           pic x(1)  value spaces.
            02 Filler           pic x(8)  value "SaleYear".
            02 Filler           pic x(1)  value spaces.
            02 Filler           pic x(9)  value "SalePrice".
            02 Filler           pic x(1)  value spaces.
            02 Filler           pic x(12) value "PricePerSqFt".
            02 Filler           pic x(1)  value spaces.
            02 Filler           pic x(5)  value "Taxes".

    01 INFO-LINE.
            02 Filler           pic x(3)  value spaces.
            02 PropertyAddress-out    pic x(20).
            02 Filler           pic x(2)  value spaces.
            02 City-out         pic a(15).
            02 Filler           pic x(1) value spaces.
            02 Zip-out          pic 9(6).
            02 Filler           pic x(2) value spaces.
            02 State-out        pic a(2).
            02 Filler           pic x(7) value spaces.
            02 Bedrooms-out     pic 9.
            02 Filler           pic x(10) value spaces.
            02 Bathrooms-out    pic 9.
            02 Filler           pic x(2) value spaces.
            02 SqFt-out         pic 9(4).
            02 Filler           pic x(9)  value spaces.
            02 PropertyType-out pic x(8).
            02 Filler           pic x(5) values spaces.
            02 SaleDayOfWeek-out pic a(3).
            02 Filler           pic x(5).
            02 SaleMonth-out    pic a(3).
            02 Filler           pic x(5) value spaces.
            02 SaleDay-out      pic 9(2).
            02 Filler           pic x(1) value spaces.
            02 SaleHour-out     pic 9(2).
            02 Filler           pic x(1) value spaces.
            02 SaleMinute-out   pic 9(2).
            02 Filler           pic x(1) value spaces.
            02 SaleSecond-out   pic 9(2).
            02 Filler           pic x(2) value spaces.
            02 TimeZone-out     pic a(3).
            02 Filler           pic x(1) value spaces.
            02 SaleYear-out     pic 9(4).
            02 Filler           pic x(5) value spaces.
            02 SalePrice-out    pic 9(6).
            02 Filler           pic x(4) value spaces.
            02 PriceSqFtT-out   pic $ZZ,ZZ9.99.
            02 Filler           pic x(2) value spaces.
            02 Taxes-out        pic 9(5).     

    01 TEMP-VAR.
            02 PriceSqFtT       pic 9(5) value zero.
            02 PriceSqFtAccum   pic 9(6) value zero.
            02 BedroomAverage     pic 9(1) value zero.
            02 BathroomAverage    pic 9(1) value zero.
            02 SqFtAverage        pic 9(6) value zero.
            02 SalePriceAverage   pic 9(7) value zero.
            02 Taxes            pic 9(6) value zero.
    01 eof-flag                 pic x(3) value "No".

    PROCEDURE DIVISION.
    0000-MAIN-LOGIC.
            Perform 1000-init.
            Perform 2000-main-loop until eof-flag = "yes".
            Perform 3000-finish.
            stop run.

    1000-init.
            open input input-file
            output output-file.

            write output-rec from Report-Header.
            write output-rec from Column-Header.
            Read input-file at end move "yes" to eof-flag.

    2000-main-loop.
            DISPLAY INPUT-REC.
            move PropertyAddress to PropertyAddress-out.
            move City to City-out.
            move Zip to Zip-out.
            move State to State-out.
            move Bedrooms to Bedrooms-out.
            move Bathrooms to Bathrooms-out.
            move PropertyType to PropertyType-out.
            move SalePrice to SalePrice-out.
            move SaleDayOfWeek to SaleDayOfWeek-out.
            move SaleMonth to SaleMonth-out.
            move SaleDay to SaleDay-out.
            move SaleHour to SaleHour-out.
            move SaleMinute to SaleMinute-out.
            move TimeZone to TimeZone-out.
            move SaleYear to SaleYear-out.
            move SalePrice to SalePrice-out.
            divide SalePrice by sqFt giving PriceSqFtT.
            Add PriceSqFtT to  PriceSqFtAccum.
            Move PriceSqFtT to PriceSqFtT-out.
            add 1 to num-recs.
            if sqft not = 0 and Bedrooms not = 0 and 
             Bathrooms not = 0 and SalePrice not = 0
             add 1 to num-nonzero.
            IF city EQUALS "SACRAMENTO" and Bedrooms EQUALS 2

               compute Taxes = salePrice * 7.5.
            IF city EQUALS "SACRAMENTO" THEN 
               MULTIPLY salePrice by 6 giving Taxes.
            IF city NOT EQUAL "SACRAMENTO"
               MULTIPLY salePrice  by 6 giving Taxes.
        move Taxes to Taxes-out.
            divide Bedrooms by num-nonzero giving BedroomAverage.
            divide Bathrooms by num-nonzero giving BathroomAverage.
            divide SqFt by num-nonzero giving SqFtAverage.
            divide SalePrice by num-nonzero giving SalePriceAverage.
            move Bedrooms to BedroomAverage-out.
            move Bathrooms to BathroomAverage-out.
            move SqFt to SqFtAverage-out.
            move SalePrice to SalePriceAverage-out.
            write output-rec from info-line.
            read input-file at end move "yes" to eof-flag.

    3000-finish.
            write output-rec from Records-processed

            write output-rec from AVERAGE-PROCESSED
            write output-rec from END-OF-REPORT
            close input-file output-file.

**************以下是产生错误的输出结果***************

1122 WILD POPY CT GALT 95632 CA 321406 Resident Wed May 21 02:00:00 EDT 2008 178760 38287789121294715

4520 BOMARK WAY SACRAMENTO 95842 CA 421943 Multi-Fa Wed May 21 00:00:00 EDT 2008 179580 38665724121358576

4520 BOBAY PKWAY SACRAMENTO 95842 CA k2194j Multi-Fa Wed May 21 00:00:00 EDT 2008 179580 38665724121358576

执行错误:文件'prog3.int' 错误代码:163,pc=189,调用=1,段=0 163 数字字段中的非法字符

***************输出结束并出现执行错误**************************** **

我正在创建一个 Cobol 程序,用于计算以下输入文件的信息行和平均值。但是,我不断收到 'illegal character in numeric field' 错误,我不明白为什么。我是用Unix系统编译的运行这个。请帮忙。对此很陌生!

输入文件:/home1/c/a/acsi203/realestate.dat

列类型数据

-------- ------------

1-27 字母数字 属性 地址

28-42 字母城市

43-47 数字邮编

48-49 字母状态

50 间卧室的数字

51 间浴室的数字

52-55 数字平方英尺

56-63 字母数字 属性 类型

64-66 Alhpabetic 销售周几

68-70 字母销售月份

72-73 数字销售日

75-76 数字销售时间

78-79 销售分钟数

81-82 数字销售第二

84-86 字母时区

88-91 数字销售年份

92-97 数字销售价格

98-105 数值 属性 纬度(向左 2 位)

106-114 数字 属性 经度(向左 2 位)

您在 Zip 后缺少 FILLER PIC X。您需要仔细检查实际数据并确保所有字段都符合您的定义。不要依赖您包含的书面定义。数据就是它的真实情况。现在注释没有压缩空格,long 和 lat 可以返回,但请注意它们不是您之前描述的数字编辑字段。


您正在使用 Micro Focus COBOL。

这里,http://supportline.microfocus.com/kbdocs/KBdo4363.HTM,是您的错误代码的描述。

这里是您的问题的相关引用:

Every value you attempt to move to a numeric or numeric edited field is checked to ensure that it is numeric.

您现在已经编辑了您的问题以表明您的经度和纬度字段是 numeric-edited 字段。这意味着它们不是数字。所以当你尝试:

        move PropertyLatitude to PropertyLatitude-out.

您会收到该消息。

当然,这假定您对该字段的定义与数据匹配。

为什么要将这两个字段移动到报告中的两个两位数字字段?

这没有回答您的问题,但我想我应该提请您注意您的代码中的税收规则没有意义(见下文)。第二个 if 语句将始终替换第一个 if 语句的结果。如果此代码确实产生了您想要的结果,您可以通过将所有 6 行代码替换为一行代码来获得相同的结果:MULTIPLY salePrice by 6 giving Taxes.

        IF city EQUALS "SACRAMENTO" and Bedrooms EQUALS 2
           compute Taxes = salePrice * 7.5.
        IF city EQUALS "SACRAMENTO" THEN 
           MULTIPLY salePrice by 6 giving Taxes.
        IF city NOT EQUAL "SACRAMENTO"
           MULTIPLY salePrice  by 6 giving Taxes.