数字字段中的非法字符错误与使用Unix系统的Cobol有关吗?

时间:2015-03-08 18:14:51

标签: average numeric cobol

如何解决错误:

执行错误:文件'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 POPPY 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,call = 1,seg = 0 163数字字段中的非法字符

**************执行结束时执行错误***************************

我正在创建一个Cobol程序,用于计算以下输入文件中的信息行和平均值。但是,我不断收到“数字字段中的非法字符”错误,我无法理解为什么。我正在使用Unix系统来编译和运行它。请帮忙。对此非常陌生!

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

列类型数据

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

1-27字母数字属性地址

28-42字母表城市

43-47 Numeric Zip

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个地方)

2 个答案:

答案 0 :(得分:1)

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.

你会得到那条消息。

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

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

答案 1 :(得分:0)

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

        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.