我正在尝试为给定的输入文件创建报告,在该报告中,我应该仔细检查每条记录以确定其是否不符合特定条件。我现在面临的问题是,即使在命令窗口上编译它时,cob文件没有明确显示任何错误,并且没有创建可执行文件,它也不会编译。我想知道你们中的任何人是否可以帮助我弄清楚代码中的错误所在。
Identification Division.
Program-ID. lab5.
Environment Division.
Input-Output Section.
File-Control.
Select PayrollFile
Assign to "lab5-in.dat"
Organization is Line Sequential.
Select OutputReport
Assign to "lab5-out.dat"
Organization is Line Sequential.
Data Division.
File Section.
FD PayrollFile.
01 Input-Rec.
05 Rec-RegionNum Pic X(2).
05 Rec-RegionName Pic X(15).
05 Rec-DeptNum Pic X(5).
05 Rec-DeptName Pic X(30).
05 Rec-EmployeeNum Pic X(5).
05 Rec-LastName Pic X(20).
05 Rec-FirstName Pic X(15).
05 Rec-Gender Pic X.
05 Rec-Address Pic X(20).
05 Rec-CityState Pic X(20).
05 Rec-Title Pic X(20).
05 Rec-DOB Pic 9(8).
05 Rec-DOH.
10 RecDOH-YYYY Pic 9(4).
10 RecDOH-MM Pic 9(2).
10 RecDOH-DD Pic 9(2).
05 Rec-Marital Pic X.
05 Rec-Deps Pic 99.
05 Rec-SD Pic X(3).
05 Rec-Ins Pic X(3).
05 Rec-401k Pic V999.
05 Rec-PayCode Pic X.
05 Rec-Pay Pic 9(7)V9(2).
05 Rec-HrsPerWeek Pic 9(2)V9(2).
05 Rec-CommissionRate Pic V999.
05 Rec-ActualSales Pic 9(7)V9(2).
FD OutputReport.
01 Output-Rec Pic X(210).
Working-Storage Section.
01 WS-EmployeeNum Pic X(5).
01 WS-DeptName Pic X(30).
01 WS-Gender Pic X.
88 ValidGender Values "M" "m" "F" "f".
01 WS-Marital Pic X.
88 ValidMarital Values "D" "d" "M" "m" "P" "p" "S" "s" "W"
"w".
01 WS-PayCode Pic X.
88 ValidPayCode Values "C" "c" "H" "h" "S" "s".
01 WS-HrsPerWeek Pic S9(2)V9(2).
01 WS-Pay Pic S9(7)V9(2).
01 WS-DOH.
10 DOH-YYYY Pic 9(4).
10 DOH-MM Pic 9(2).
10 DOH-DD Pic 9(2).
01 WS-SD Pic X(3).
01 WS-Date.
05 WS-YYYY Pic 9(4).
05 WS-MM Pic 9(2).
05 WS-DD Pic 9(2).
01 EndOfFileIndicator Pic X.
88 EOF Value "Y" When Set To False is "N".
01 Total-Line.
05 Pic X(25) Value "Total errors: ".
05 TL-TotalE Pic ZZ9.
01 TotalRE-Line.
05 Pic X(50) Value "Total record with errors: ".
05 TL-TotalRE Pic ZZ9.
01 TotError Pic 9(3).
01 TotRecordError Pic 9(3).
01 CurrentRec Pic X(208).
01 Blank-Line Pic X Value Spaces.
01 Report-Fields.
05 PageNumber Pic 99 Value 0.
05 LinesPerPage Pic 99 Value 35.
05 LineNumber Pic 99 Value 99.
Procedure Division.
000-MAIN.
Perform 100-initialize
Perform until EOF
Read PayrollFile
At End
Set EOF to True
not at end
perform 300-process
End-read
End-perform
Perform 900-finalize
Close PayrollFile OutputReport
Stop Run.
100-initialize.
Perform 110-open-files
Move Zero to TotError
Move Zero to TotRecordError.
110-open-files.
Open Input PayrollFile
Open Output OutputReport.
300-Process.
Move Input-Rec to CurrentRec
Move Rec-EmployeeNum to WS-EmployeeNum
Move Rec-DeptName to WS-DeptName
Move Rec-Gender to WS-Gender
Move Rec-Marital to WS-Marital
Move Rec-PayCode to WS-PayCode
Move Rec-HrsPerWeek to WS-HrsPerWeek
Move Rec-Pay to WS-Pay
Move Rec-DOH to WS-DOH
Perform 400-check.
400-check.
If WS-EmployeeNum is Not Numeric
Add 1 to TotError TotRecordError
End-If
If WS-DeptName Is Not Alphabetic
Add 1 to TotError TotRecordError
End-If
If Not ValidGender
Add 1 to TotError TotRecordError
End-If
If Not ValidMarital
Add 1 to TotError TotRecordError
End-If
If Not ValidPayCode
Add 1 to TotError TotRecordError
End-If
If WS-HrsPerWeek Is Negative And >= 60
Add 2 to TotError
Add 1 to TotRecordError
End-If
If WS-HrsPerWeek Is Negative Or >=60
Add 1 to TotError TotRecordError
End-If
If WS-Pay Is Not Numeric and Is Negative
Add 2 to TotError
Add 1 to TotRecordError
End-If
If WS-Pay Is Negative Or Not Numeric
Add 1 to TotError TotRecordError
End-If
If Function Test-Date-YYYYMMDD(WS-DOH) Is Not Zero Or WS-DOH Is Not Numeric
Add 1 to TotError TotRecordError
End-If.
900-finalize.
perform 950-print-grand-total.
950-print-grand-total.
Write Output-Rec from Blank-Line
After advancing 1 line
Move TotError to TL-TotalE
Write Output-Rec from Total-Line
after advancing 1 line
Move TotRecordError to TL-TotalRE
Write Output-Rec from TotalRE-Line
after advancing 1 line.
答案 0 :(得分:4)
使用GnuCOBOL标签时,我刚刚使用了a simple compile。
结果:
main.cobc: in paragraph '400-check':
main.cobc: 139: error: invalid expression
main.cobc: 143: error: invalid expression
main.cobc: 146: error: invalid expression
main.cobc: 150: error: invalid expression
main.cobc: 153: error: FUNCTION 'TEST-DATE-YYYYMMDD' has invalid parameter
main.cobc: 153: error: invalid expression
main.cobc: 153: error: invalid expression
无效的表达式部分是“否定的”(附加的第139行没有意义“否定且> = 60”,因为这永远是不正确的;第146行则更加奇怪:“不是数值,而是负数”) )。
我现在面临的问题是,即使在编译时cob文件没有明确显示任何错误,它也不会编译
我想来自编译器的消息会重定向到某个地方。