Код на языке COBOL не компилируется и не создает исполняемый файл - PullRequest
0 голосов
/ 17 октября 2018

Я пытаюсь создать отчет для заданного входного файла, в котором я должен проверить каждую запись, чтобы определить, не соответствует ли она определенным критериям.Проблема, с которой я сталкиваюсь сейчас, заключается в том, что 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.

1 Ответ

0 голосов
/ 17 октября 2018

Поскольку вы использовали тег 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отрицательный »(дополнительная строка 139 не имеет смысла« Отрицательный А> = 60 », поскольку это никогда не будет правдой; строка 146 еще более странная:« Не является числовым и отрицательным »).

Проблема, с которой я сталкиваюсь сейчас, заключается в том, что cob-файл не будет компилировать событие, хотя он явно не отображает никаких ошибок при его компиляции

Я предполагаю, что сообщения от компиляторов куда-то перенаправляются.

...