Cobol-163数字字段中的非法字符
我将如何修复使用此代码收到的此错误消息: 错误消息: 执行错误:文件“prog2.int” 错误代码:163,pc=5AB,call=1,seg=0 163数字字段中的非法字符Cobol-163数字字段中的非法字符,cobol,Cobol,我将如何修复使用此代码收到的此错误消息: 错误消息: 执行错误:文件“prog2.int” 错误代码:163,pc=5AB,call=1,seg=0 163数字字段中的非法字符 是否仍然可以找到非法字符在数字字段中的确切位置?我很难找到问题的罪魁祸首 有几种方法可以确定“非法字符”错误的原因: 分析程序转储 使用交互式调试器 向程序中添加代码以验证数字字段的内容 分析程序转储 如果错误导致系统产生程序转储,请检查转储,查看它是否提供了任何有用的信息 转储通常会提供以下信息: 错误发生时,
是否仍然可以找到非法字符在数字字段中的确切位置?我很难找到问题的罪魁祸首 有几种方法可以确定“非法字符”错误的原因:
- 分析程序转储
- 使用交互式调试器
- 向程序中添加代码以验证数字字段的内容
分析程序转储 如果错误导致系统产生程序转储,请检查转储,查看它是否提供了任何有用的信息 转储通常会提供以下信息:
- 错误发生时,程序的哪一行正在执行
- 上次从每个输入文件中读取的记录是什么
- 程序变量的内容
使用交互式调试器 如果开发环境包括交互式调试器,则可以在调试器中执行程序,直到出现错误,然后记录导致错误的程序语句和数据
向程序中添加验证代码 通过在使用数字字段之前向程序中添加代码以验证其内容,您不仅可以确定错误的原因,还可以从中恢复
您可能需要考虑的验证包括:
(1) 测试2100验证记录中的数字内容的以下附加Input Rec
字段:
Identification Division.
Program-Id. Fifth-Assignment.
Author. Joanne Lin.
Date-Written. 04/12/2017.
Date-Compiled.
*Joanne Lin.
*Assignment #5.
Environment Division.
Input-Output Section.
File-Control.
Select City-File
assign to "/home1/c/a/acsi203/cityrates.dat".
Select Input-File
assign to "/home1/c/a/acsi203/realestate.dat".
Select Output-File
assign to "prog5out.dat"
Organization is line sequential.
Select Error-File
assign to "error5out.dat"
Organization is line sequential.
Data Division.
File Section.
FD City-File.
01 Input-City.
02 City-Table Pic a(15).
02 Rate-Table Pic v9(3).
02 Filler Pic x.
FD Input-File.
01 Input-Rec.
02 Street-Address Pic x(27).
02 City Pic a(15).
02 Zip Pic 9(5).
02 State Pic a(2).
88 Valid-State value "CA".
02 Bedrooms Pic 9.
02 Bathrooms Pic 9.
02 Square-Feet Pic 9(4).
02 Property-Type Pic x(8).
88 Valid-Property values
"Resident",
"Condo",
"Multi-fa".
02 Sale-Day-week Pic a(3).
02 Filler Pic x(1).
02 Sale-Month Pic x(3).
02 Filler Pic x(1).
02 Sale-Day Pic 9(2).
02 Filler Pic x(1).
02 Sale-Hr Pic 9(2).
02 Filler Pic x(1).
02 Sale-Min Pic 9(2).
02 Filler Pic x(1).
02 Filler Pic x(1).
02 Sale-Sec Pic 9(2).
02 Filler Pic x(1).
02 Time-Zone Pic a(3).
02 Filler Pic x(1).
02 Sale-Year Pic x(4).
02 Sale-Price Pic 9(6).
02 Latitude Pic 99V9(6).
02 Longitude Pic 99V9(7).
02 Filler Pic x.
FD Output-File
linage is 58 lines
with footing at 56
lines at top 5
lines at bottom 5.
01 Output-Rec Pic x(132).
FD Error-File.
01 Error-rec Pic x(132).
Working-Storage Section.
01 Report-Header.
02 Filler Pic x(48) value spaces.
02 Filler Pic x(43) value
"California Area Real Estate Transactions - ".
02 Current-Month Pic 99.
02 Filler Pic x value "/".
02 Current-Day Pic 99.
02 Filler Pic x value "/".
02 Current-Year Pic 9999.
01 Date-Header.
02 Year-head Pic 9999.
02 Month-head Pic 99.
02 Day-head Pic 99.
01 Column-Headers.
02 Filler pic x(27) value "Address".
02 Filler pic x(1) value spaces.
02 Filler pic x(16) value "City".
02 Filler pic x(6) value "Zip".
02 Filler pic x(3) value "St".
02 Filler pic x(6) value "BD".
02 Filler pic x(3) value "BT".
02 Filler pic x(4) value "SFt".
02 Filler pic x(10) value "Prop Type".
02 Filler pic x(4) value "Day".
02 Filler pic x(4) value "Mth".
02 Filler pic x(3) value "DD".
02 Filler pic x(3) value "HR".
02 Filler pic x(3) value "MN".
02 Filler pic x(3) value "SC".
02 Filler pic x(4) value "Zon".
02 Filler pic x(5) value "Year".
02 Filler pic x(6) value "Price".
02 Filler pic x(6) value spaces.
02 Filler pic x(9) value "Latitude".
02 Filler pic x(10) value "Longitude".
02 Filler pic x(7) value "$/Sq Ft".
02 Filler pic x(1) value spaces.
02 Filler pic x(9) value "Est Value".
01 Info-Line.
02 Street-Address-out Pic x(27).
02 Filler Pic x(1) value spaces.
02 City-out Pic a(15).
02 Filler Pic x(1) value spaces.
02 Zip-Out Pic 9(5).
02 Filler Pic x(1) value spaces.
02 State-out Pic a(2).
02 Filler Pic x(1) value spaces.
02 Bedrooms-out Pic x(5).
02 Filler Pic x(2) value spaces.
02 Bathrooms-out Pic 9(1).
02 Filler Pic x(1) value spaces.
02 Square-feet-out Pic 9(4).
02 Filler Pic x(1) value spaces.
02 Property-Type-out Pic x(8).
02 Filler Pic x(1) value spaces.
02 Sale-Day-week-out Pic x(3).
02 Filler Pic x(1) value spaces.
02 Sale-Month-out Pic x(3).
02 Filler Pic x(1) value spaces.
02 Sale-day-out Pic 9(2).
02 Filler Pic x value spaces.
02 Sale-hr-out Pic 9(2).
02 Filler Pic x value spaces.
02 Sale-min-out Pic 9(2).
02 Filler Pic x value spaces.
02 Sale-Sec-out pic 9(2).
02 Filler Pic x value spaces.
02 Time-Zone-out pic x(3).
02 Filler Pic x(1) value spaces.
02 Sale-Year-out Pic x(4).
02 Filler Pic x(1) value spaces.
02 Sale-price-out Pic $zzz,zz9.99.
02 Filler Pic x(1) value spaces.
02 Latitude-out Pic 9(8).
02 Filler Pic x value spaces.
02 Longitude-out Pic 9(9).
02 Filler Pic x(2) value spaces.
02 Price-Sq-Ft-Out Pic $zz9.99.
02 Filler Pic x(1) value spaces.
02 Estimate-Value-Out Pic $zzz,zz9.99.
01 WSMisc-fields.
02 WS-Price-Sq-Ft Pic 9(6)V99.
02 ws-Estimate-value Pic 9(6)V99.
02 Total-Bedrooms Pic 9(5) value zeros.
02 Total-Bathrooms Pic 9(5) value zeros.
02 Total-Square-Feet Pic 9(7) value zeros.
02 Total-Sale-Price Pic 9(9) value zeros.
02 Total-Records Pic 9(5) value zeros.
02 Avg-Bedrooms Pic 9(5)V99.
02 Avg-Bathrooms Pic 9(5)v99.
02 Avg-Square-Feet Pic 9(6)V99.
02 Avg-Sale-Price Pic 9(6)V99.
02 Row-Index Pic 9(2).
02 Bedroom-Index Pic 9.
02 Sale-Price-Temp Pic 9(8)v99 value zeros.
01 Error-out-line.
02 Filler Pic x(15) value
"Record Number: ".
02 Error-rec-number Pic z,zz9.
02 Filler Pic x(2) value spaces.
02 Error-message Pic x(30) value spaces.
02 Filler Pic xx value spaces.
01 WS-Error-line Pic x(114) value spaces.
01 Averages.
02 Filler Pic x(9) value "Averages:".
02 Filler Pic x(45) value spaces.
02 Bedroom-Average Pic zzz.
02 Filler Pic x(2) value spaces.
02 Bathroom-Average Pic zzz.
02 Filler Pic x(2) value spaces.
02 SqFt-Average Pic z,zzz,zz.
02 Filler Pic x(5) value spaces.
02 Sale-Price-Average Pic $$,$$$,$$9.99.
01 End-Report.
02 Filler Pic x(60) value spaces.
02 Filler Pic x(13) value
"End of Report".
02 Filler Pic x(59) value spaces.
01 Number-of-files-line.
02 Filler Pic x(29) value
"Number of records processed:".
02 Rec-count Pic 9(4) value 0.
02 Filler Pic x(99) value spaces.
01 eof-flag Pic xxx value "No".
01 Invalid-flag Pic xxx value "No".
01 eop-flag Pic x value "N".
01 eof-city-flag Pic x value "N".
01 match-flag Pic x value "N".
01 blank-line Pic x(132) value spaces.
01 Page-Footer.
02 Filler Pic x(80) value spaces.
02 Filler Pic x value "-".
02 Page-Num Pic 9 value 1.
02 Filler Pic x value "-".
01 Bedrooms-Heading.
02 Filller Pic x(18) value "Number of Bedrooms".
02 Filler Pic x(6) value spaces.
02 Filler Pic x(22) value
"Accumulated Sale Price".
01 WS-Num-Bedroom.
02 Filler Pic x(5) value "Zero".
02 Filler Pic x(5) value "One".
02 Filelr Pic x(5) value "Two".
02 Filler Pic x(5) value "Three".
02 Filler pic x(5) value "Four".
02 Filler Pic x(5) value "Five".
02 Filler Pic x(5) value "Six".
01 Ws-Num-Bedroom-Table redefines Ws-Num-Bedroom.
02 Table-Num-Bedrooms occurs 7 times Pic x(5).
01 Ws-Sale-Price-Table occurs 6 times.
02 Table-bedroom-price Pic 9(9)v99 value zeroes.
01 Total-Sale-Bedroom.
02 Filler Pic x(7) value spaces.
02 Num-bedrooms Pic 9(1).
02 Filler Pic x(18) value spaces.
02 Tot-Sale-Price Pic $zzz,zzz,zz9.99.
01 City-Index Pic 99 value 1.
01 City-Rate-Table occurs 22 times
ascending key is city-name
indexed by City-Table-Index.
02 City-Name Pic a(15).
02 Multi-Rate pic v9(3).
01 Bath-Header.
02 Filler Pic x(13) value spaces.
02 Filler Pic x(5) value "Baths".
02 Filler Pic x(15) value spaces.
02 Filler Pic x value "1".
02 Filler Pic x(18) value spaces.
02 Filler Pic x Value "2".
02 Filler Pic x(18) value spaces.
02 Filler Pic x Value "3".
02 Filler Pic x(18) Value spaces.
02 Filler Pic x Value "4".
02 Filler Pic x(18) Value spaces.
02 Filler Pic x Value "5".
01 Bedroom-Header.
02 Filelr Pic x(4) value spaces.
02 Filler Pic x(6) value "Bedrms".
01 Bed-Row occurs 6 times.
02 Bath-Col occurs 5 times.
03 Bed-Bath-Accum Pic 9(8)v99 value zeroes.
01 Bed-Bath-Row occurs 6 times.
02 Filler Pic x(15) value spaces.
02 Bed-Num-Out Pic zz9.
02 Filler Pic x(8) value spaces.
02 Bed-Bath-Sale-Out occurs 5 times.
03 Bed-Bath-Sale Pic zzz,zzz,zz9.99.
03 Filler Pic x(5) value spaces.
01 Column-Counter Pic 99 value 0.
Procedure Division.
*Main logic of the program.
0000-Main-Logic.
Perform 1000-Init.
Perform 2000-Main-Loop until Eof-Flag = "Yes".
Perform 3000-Calculate-Average.
Perform 4000-Finish.
Perform 5000-Write-Bedroom-Heading.
* Prints 1-dimensional table accumulated price
* per bedroom
Perform 6000-Print-Tot-Price-Bed
varying row-index from 1 by 1
until row-index > 6.
Perform 8000-Write-Ftr-Space-Line-Num.
Perform 6500-Write-Bed-Bath-Headings.
Perform 7000-Print-Bed-Bath-Sales-Tot
varying row-index from 1 by 1
until row-index > 6.
Perform 8000-Write-Footer.
Perform 9000-Close-Files.
Stop Run.
1000-init.
Open Input Input-File
Input City-File
output Output-File
output Error-File.
Perform 1500-Load-City-Rate until
Eof-City-Flag = "Y".
Close City-File.
Move Ws-Num-Bedroom to Ws-Num-Bedroom-Table.
Move Function Current-Date to Date-header.
Move Year-head to Current-year.
Move Month-head to Current-month.
Move Day-head to Current-day.
Write Output-Rec from Report-Header
after advancing 2 lines.
Write Output-Rec from Column-Headers
after advancing 2 lines.
Write output-Rec from blank-line.
Read Input-File at end move "Yes" to Eof-Flag.
1500-Load-City-Rate.
Read City-File at end move "Y" to Eof-City-Flag.
If Eof-City-Flag = "N"
Move City-Table to City-Name(City-Index)
Move Rate-Table to Multi-Rate(City-Index)
Add 1 to City-Index.
2000-Main-Loop.
Add 1 to Rec-count.
Perform 2100-Validate-Record.
If Invalid-Flag = "N"
Perform 2200-Write-Good-Record
else
Perform 2300-Write-Error-Record.
Read Input-File at end move "Yes" to Eof-Flag.
2100-Validate-record.
If Valid-State and
Valid-Property and
Bedrooms is Numeric and
Bathrooms is Numeric and
Square-feet is Numeric and
Sale-Price is Numeric
Move "N" to Invalid-Flag
Else
Move "Y" to Invalid-Flag.
2200-Write-Good-Record.
Move Street-Address to Street-Address-out.
Move City to City-out.
Move State to State-out.
Move Zip to Zip-out.
Move 1 to City-Index.
Move "Y" to Match-Flag.
Search all City-Rate-Table
at end
Move "N" to Match-Flag
When City-Name(City-Table-Index) = City
Compute Sale-Price-Temp = Sale-Price *
Multi-Rate(City-Table-Index).
If bedrooms > 0 and Bathrooms > 0 and
Match-Flag = "Y"
Add Sale-Price-Temp to
Bed-Bath-Accum(Bedrooms,Bathrooms).
If bedrooms > 0
Add Sale-Price-temp to Table-Bedroom-Price(bedrooms).
Compute bedroom-index = Bedrooms + 1.
Move Table-Num-Bedrooms(bedroom-index) to
Bedrooms-Out.
Move Bathrooms to Bathrooms-out.
Move Square-feet to Square-feet-out.
Move Property-Type to Property-Type-out.
Move Sale-Day-week to Sale-Day-week-out.
Move Sale-Month to Sale-Month-out.
Move Sale-day to Sale-day-out.
Move Sale-hr to Sale-hr-out.
Move Sale-min to Sale-min-out.
Move Sale-sec to Sale-sec-out.
Move Sale-Year to Sale-Year-out.
Move Sale-price-Temp to Sale-price-out.
Perform 2050-Calculation.
Write Output-Rec from Info-Line at eop
perform 2040-Write-Page-Footer.
Add 1 to Rec-Count.
2040-Write-Page-Footer.
Write Output-Rec from Page-Footer
after advancing 2 lines.
Add 1 to Page-Num.
Write Output-Rec from Report-Header
after advancing page.
Write Output-Rec from Column-Headers
after advancing 2 lines.
Write Output-Rec from Blank-Line.
2050-Calculation.
If Square-feet > 0
Compute WS-Price-Sq-Ft =
Sale-price-temp / Square-feet
Else
Move 0 to WS-Price-Sq-Ft.
Move WS-Price-Sq-Ft to Price-Sq-Ft-out.
If City = "SACRAMENTO" or "RIO LINDA"
Compute WS-Estimate-Value = Sale-price-temp * 1.18
Else
Compute WS-Estimate-Value = Sale-price-temp * 1.13.
Move WS-Estimate-Value to Estimate-Value-out.
If Square-feet > 0
Add Bedrooms to Total-Bedrooms
Add Bathrooms to Total-Bathrooms
Add Square-feet to Total-Square-Feet
Add Sale-Price-temp to Total-Sale-Price
Add 1 to Total-Records.
2300-Write-Error-Record.
Move Input-Rec to WS-Error-Line.
Write Error-Rec from WS-Error-Line.
Move Rec-count to Error-rec-number.
If not Valid-State
Move "State is invalid" to error-message
Write error-rec from Error-out-line.
If not Valid-Property
Move "Propery Type is invalid" to error-message
Write error-rec from Error-out-line.
If Bedrooms is not numeric
Move "Bedrooms is not numeric" to error-message
Write error-rec from Error-out-line.
If Bathrooms is not numeric
Move "Bathrooms is not numeric" to error-message
Write error-rec from Error-out-line.
If Square-Feet is not numeric
Move "Square feet is not numeric" to error-message
Write error-rec from Error-out-line.
If Sale-Price is not numeric
Move "Sale Price is not numeric" to error-message
Write error-rec from Error-out-line.
Write error-rec from blank-Line.
3000-Calculate-Average.
Compute Avg-Bedrooms =
Total-Bedrooms / Total-Records.
Compute Avg-Bathrooms =
Total-Bathrooms / Total-Records.
Compute Avg-Square-Feet =
Total-Square-Feet / Total-Records.
Compute Avg-Sale-Price =
Total-Sale-Price / Total-Records.
Move Avg-Bedrooms to Bedroom-Average.
Move Avg-Bathrooms to Bathroom-Average.
Move Avg-Square-Feet to SqFt-Average.
Move Avg-Sale-Price to Sale-Price-Average.
6000-Print-Tot-Price-Bed.
Move Table-Bedroom-Price(row-index) to
Tot-Sale-Price.
move row-index to Num-Bedrooms.
Write Output-Rec from Total-Sale-Bedroom.
4000-Finish.
Write Output-Rec from Averages
after advancing 2 lines.
Write Output-Rec from Number-of-files-line
after advancing 2 lines.
Perform 5500-Write-Blank-Lines until Eop-Flag = "Y".
5500-Write-Blank-Lines.
Write Output-Rec from blank-Line
at eop Write Output-Rec from Page-Footer
Move "Y" to Eop-Flag.
5000-Write-Bedroom-Heading.
Add 1 to Page-Num.
Write Output-Rec from Bedrooms-Heading
after advancing page.
Write Output-Rec from blank-Line.
6500-Write-Bed-Bath-Headings.
Add 1 to Page-Num.
Write Output-Rec from Bath-Header
after advancing page.
Write Output-Rec from Bedroom-Header.
Write Output-Rec from blank-Line.
7000-Print-Bed-Bath-Sales-Tot.
Move Row-Index to Bed-Num-Out(Row-Index).
Perform 7500-Print-Line varying
Column-Counter from 1 by 1
Until Column-Counter > 5.
Write Output-Rec from Bed-Bath-Row(Row-Index).
7500-Print-Line.
Move Bed-Bath-Accum(Row-Index,Column-Counter) to
Bed-Bath-Sale(Row-Index,Column-Counter).
8000-Write-Ftr-Space-Line-Num.
Move "N" to Eop-Flag.
Perform 5500-Write-Blank-Lines until Eop-Flag = "Y".
8000-Write-Footer.
Write Output-Rec from blank-line.
Write Output-Rec from End-Report.
Perform 8000-Write-Ftr-Space-Line-Num.
9000-Close-Files.
Close Output-File Input-File Error-File.
(2) 在将数字内容移动到多费率(城市索引)
之前,测试字段费率表
(3) 验证
卧室
的值是否为您正在运行Micro Focus COBOL的某些变体。您遇到了一个运行时错误,该错误表示“要么源数据(某处)被破坏,要么我所做的某件事被破坏,而非数字数据在数字字段中是一个”
为此,数字字段是一个使用情况显示
数字或数字编辑字段,或者是一个压缩的十进制字段(尽管您没有这些字段,我也不完全确定这会给您一个163)
用法
和显示
(在用法上下文中)都是您不常看到的可选词。举个例子:
Zip
Sale-Day
Sale-Hr
Sale-Min
Sale-Sec
Latitude
Longitude
如果您碰巧使用了Zip-Out,那么如果您的程序包含除数字以外的任何内容,那么它将被烧掉
第一个提示:不要因为某个东西是一个“数字”,就把它变成数字,除非你的处理需要它。帐号、客户号、零件号、邮政编码都可以是简单的PICX字段。您(几乎)永远不会将它们用于计算或用作下标,那么为什么要毫无目的地将它们设为数字呢?其他示例包括天、月、年、小时、分钟、秒等
第二个技巧:了解编译选项/指令。163可以“关闭”(在每次引用之前进行数字测试,这不是很有效),并且还有其他东西可以修改处理。你可能想要的是“告诉我它失败的线路号”,我怀疑这是可能的。阅读实际编译器的选项/指令
第三点提示:在“程序”部分中,仅使用最小的句点/句点。例如,目前,所有IF语句都以句号/句点结束。删除这些,并替换为END-IF。找出您应该在程序中使用的其他作用域终止符,并替换它们。然后删除所有句号/句点,但终止过程分段标题和标签(段落名称)除外。然后,在第12栏的单独一行中,以一个句号/句号结束每一段
举个例子。你有:
02 Zip-Out Pic 9(5).
你可以:
1500-Load-City-Rate.
Read City-File at end move "Y" to Eof-City-Flag.
If Eof-City-Flag = "N"
Move City-Table to City-Name(City-Index)
Move Rate-Table to Multi-Rate(City-Index)
Add 1 to City-Index.
第四个技巧:不要在数据名中使用“index”,除非它是一个索引(由数据库上的索引定义)。如果它只是一个数字字段,您将其用作下标,请不要将其命名为“索引”。数据名的目的是准确地记录字段。这不包括误导
第五个提示:如果你被要求对段落/章节进行“编号”,我建议先设计/编写/测试程序,完成后再进行编号。如果数字不按顺序排列,那么它们就没有意义,而你的也没有。仅仅因为您必须修复由于设计缺陷而导致的某些问题,所以多次重新编号是没有意义的
第五点提示:对于数据定义,请在级别编号中留下“空白”。如果因为没有更高层次的定义而不得不重组数据,那么下一个人就会讨厌你。通常会留下五个左右的间隙(01、05、10、15…)。这样做并没有真正的负面影响,它将保留你的名字和其他人在未来看你的程序(可能包括你的标记)
第六个小贴士:使用88。你就是我们
1500-Load-City-Rate.
Read City-File
at end
move "Y" to Eof-City-Flag
End-read
If Eof-City-Flag = "N"
Move City-Table to City-Name
( City-Index )
Move Rate-Table to Multi-Rate
( City-Index )
Add 1 to City-Index
End-if
.
program-id. err-163.
data division.
working-storage section.
1 163-data pic 9(5).
procedure division.
add 1 to 163-data
stop run
.