COBOL代码不会编译和创建可执行文件

COBOL代码不会编译和创建可执行文件,cobol,gnucobol,Cobol,Gnucobol,我正在尝试为给定的输入文件创建一个报告,在该报告中,我应该检查每个记录,以确定它是否不符合某些标准。我现在面临的问题是,即使cob文件在命令窗口上编译时没有显式显示任何错误,并且没有创建可执行文件,cob文件也不会编译。我想知道你们是否能帮我找出代码中的错误所在 Identification Division. Program-ID. lab5. Environment Division. Input-Output Section. File-Control.

我正在尝试为给定的输入文件创建一个报告,在该报告中,我应该检查每个记录,以确定它是否不符合某些标准。我现在面临的问题是,即使cob文件在命令窗口上编译时没有显式显示任何错误,并且没有创建可执行文件,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.

因为您使用了我刚才使用的GnuCOBOL标记

结果:

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
无效的表达式部分是“is negative”(附加的第139行“negative And>=60”没有意义,因为这永远不会是真的;第146行更奇怪:“不是数字,是负数”)

我现在面临的问题是,即使cob文件在编译时没有显式显示任何错误,它也不会编译


我猜来自编译器的消息被重定向到了某个地方。

因为您使用了我刚才使用的GnuCOBOL标记

结果:

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
无效的表达式部分是“is negative”(附加的第139行“negative And>=60”没有意义,因为这永远不会是真的;第146行更奇怪:“不是数字,是负数”)

我现在面临的问题是,即使cob文件在编译时没有显式显示任何错误,它也不会编译

我猜来自编译器的消息被重定向到某个地方。

请参阅。显示从编译器获得的错误或消息。GNUCobol是一个多步骤工具,因此我们需要了解详细信息。另外,你的目标语言水平是什么?编译器有您应该使用的
-v[vv]
选项,并在那里检查其他选项--您可能希望保存可以检查的中间结果。现有答案对您有用吗?如果是,请“接受”。如果您(或一旦您)有权对答案进行投票,请对任何您认为“有用”的答案进行投票。一定要去参观…看。显示从编译器获得的错误或消息。GNUCobol是一个多步骤工具,因此我们需要了解详细信息。另外,你的目标语言水平是什么?编译器有您应该使用的
-v[vv]
选项,并在那里检查其他选项--您可能希望保存可以检查的中间结果。现有答案对您有用吗?如果是,请“接受”。如果您(或一旦您)有权对答案进行投票,请对任何您认为“有用”的答案进行投票。而且一定要去旅游。。。