COBOL程序不会在我的报告中输出明细行

问题描述 投票:1回答:2

EDIT:弄清楚了。我需要在A420-COUNT-MARKS末尾再次调用读取的内容

编辑:在通过Vista TN3270访问的z / OS大型机上工作。该程序是使用教师提供的JCL提交的。

我在学校编程,我有一个COBOL作业,我的程序读取一个充满主题名称和代码的文件,以及一个充满学生标记和相关主题代码的文件。它必须使用此信息来创建一个报告,该报告列出所有学科,并对每个学科获得A,B,C,D或F等级的学生人数进行计数。然后,它在底部总计每个等级的数量。

报告示例:

01         ABC COLLEGE TESTING CENTER
02         TEST RESULTS SUMMARY           DATE: yyyy/mm/dd
03
04 SUBJECT NAME                  A           B            C           D        F
05
06 xxxxxxxxxxxxxxxxxxxx        9,999       9,999        9,999       9,999    9,999
07 xxxxxxxxx                   9,999       9,999        9,999       9,999    9,999
19
20 TOTAL                      99,999      99,999       99,999      99,999   99,999

问题是我的程序仅输出标题行,但不输出明细行或总计行。我已经编写了执行这些功能的函数,但是它们没有出现任何错误,所以我不知道出了什么问题。

这是我的文件控件和文件部分:

FILE-CONTROL.                               
    SELECT F01-SUBJ-FILE ASSIGN TO F01SUBJ. 
    SELECT F02-MARK-FILE ASSIGN TO F02MARK. 
    SELECT F03-REPT-FILE ASSIGN TO F03REPT. 

FILE SECTION.                      
FD  F01-SUBJ-FILE                  
    RECORDING MODE IS F            
    RECORD CONTAINS 80 CHARACTERS  
    DATA RECORD IS F01-SUBJ-RECORD.
01  F01-SUBJ-RECORD.               
    05  F01-SUBJ-CODE  PIC X(6).   
    05  F01-SUBJ-NAME  PIC X(20).  
    05                 PIC X(54).  

FD  F02-MARK-FILE                 
    RECORDING MODE IS F           
    RECORD CONTAINS 80 CHARACTERS 
    DATA RECORD IS F02-MARK-RECORD
01  F02-MARK-RECORD.              
    05  F02-STUD-NAME  PIC  X(20).
    05  F02-SUBJ-CODE  PIC  X(6). 
    05                 PIC  X.    
    05  F02-DATE-TEST  PIC  X(8). 
    05  F02-STUD-MARK  PIC  9(3). 
    05                 PIC  X(42).

FD  F03-REPT-FILE                  
    RECORDING MODE IS F            
    RECORD CONTAINS 120 CHARACTERS 
    DATA RECORD IS F03-REPT-RECORD.
01  F03-REPT-RECORD.               
    05                 PIC X(120). 

这里是工作存储区:

WORKING-STORAGE SECTION.                   
01  W01-EOF-SWITCH.                        
    05  W01-MARK-EOF       PIC X VALUE 'N'.
    05  W01-SUBJ-EOF       PIC X VALUE 'N'.

01  W02-TEST-TABLE.                               
    05  W02-SUBJ-COUNT     PIC 99 VALUE 0.        
    05  W02-SUBJ-MAX       PIC 99 VALUE 50.       
    05  W02-TEST-ROW OCCURS 1 TO 50               
        DEPENDING ON W02-SUBJ-COUNT               
        ASCENDING KEY IS W02-SUBJ-CODE            
        INDEXED BY W02-IDX.                       
        10  W02-SUBJ-CODE  PIC X(6)  VALUE SPACES.
        10  W02-SUBJ-NAME  PIC X(20) VALUE SPACES.
        10  W02-A-CTR      PIC 9999  VALUE 0.     
        10  W02-B-CTR      PIC 9999  VALUE 0.     
        10  W02-C-CTR      PIC 9999  VALUE 0.     
        10  W02-D-CTR      PIC 9999  VALUE 0.     
        10  W02-F-CTR      PIC 9999  VALUE 0.     

01  W03-REPT.                                        
    05  W03-HEADER-ROW1.                             
        10                 PIC X(9)  VALUE SPACES.   
        10                 PIC X(3)  VALUE 'ABC'.    
        10                 PIC X     VALUE SPACES.   
        10                 PIC X(7)  VALUE 'COLLEGE'.
        10                 PIC X     VALUE SPACES.   
        10                 PIC X(7)  VALUE 'TESTING'.
        10                 PIC X     VALUE SPACES.   
        10                 PIC X(6)  VALUE 'CENTER'. 
        10                 PIC X(85) VALUE SPACES.   
    05  W03-HEADER-ROW2.                             
        10                 PIC X(9)  VALUE SPACES.   
        10                 PIC X(4)  VALUE 'TEST'.   
        10                 PIC X     VALUE SPACES.   
        10                 PIC X(7)  VALUE 'RESULTS'.
        10                 PIC X     VALUE SPACES.   
        10                 PIC X(7)  VALUE 'SUMMARY'.
        10                 PIC X(11) VALUE SPACES.   
        10                 PIC X(5)  VALUE 'DATE:'.  
        10                 PIC X     VALUE SPACES.   
        10  W03-YEAR       PIC 9999.                 
        10                 PIC X     VALUE '/'.      
        10  W03-MONTH      PIC 99.                   
        10                 PIC X     VALUE '/'.      
        10  W03-DAY        PIC 99.                   
        10                 PIC X(64) VALUE SPACES. 
    05  W03-HEADER-ROW3.                              
        10                 PIC X     VALUE SPACES.    
        10                 PIC X(7)  VALUE 'SUBJECT'. 
        10                 PIC X     VALUE SPACES.    
        10                 PIC X(4)  VALUE 'NAME'.    
        10                 PIC X(15) VALUE SPACES.    
        10                 PIC X     VALUE 'A'.       
        10                 PIC X(7)  VALUE SPACES.    
        10                 PIC X     VALUE 'B'.       
        10                 PIC X(7)  VALUE SPACES.    
        10                 PIC X     VALUE 'C'.       
        10                 PIC X(7)  VALUE SPACES.    
        10                 PIC X     VALUE 'D'.       
        10                 PIC X(7)  VALUE SPACES.    
        10                 PIC X     VALUE 'F'.         
        10                 PIC X(59) VALUE SPACES.
    05  W03-DETAIL-ROW.                            
        10                 PIC X     VALUE SPACES. 
        10  W03-SUBJ-NAME  PIC X(20).              
        10                 PIC XXX   VALUE SPACES. 
        10  W03-A-CTR      PIC Z,ZZ9.              
        10                 PIC XXX   VALUE SPACES. 
        10  W03-B-CTR      PIC Z,ZZ9.              
        10                 PIC XXX   VALUE SPACES. 
        10  W03-C-CTR      PIC Z,ZZ9.              
        10                 PIC XXX   VALUE SPACES. 
        10  W03-D-CTR      PIC Z,ZZ9.              
        10                 PIC XXX   VALUE SPACES. 
        10  W03-F-CTR      PIC Z,ZZ9.              
        10                 PIC X(59) VALUE SPACES. 

01  W04-SYS-DATE.                       
    05  W04-YEAR           PIC 9999.    
    05  W04-MONTH          PIC 99.      
    05  W04-DAY            PIC 99.      

01  W05-TOTALS.                               
    05  W05-TOTAL-A        PIC 99999 VALUE 0. 
    05  W05-TOTAL-B        PIC 99999 VALUE 0. 
    05  W05-TOTAL-C        PIC 99999 VALUE 0. 
    05  W05-TOTAL-D        PIC 99999 VALUE 0. 
    05  W05-TOTAL-F        PIC 99999 VALUE 0. 

这里的程序部门

PROCEDURE DIVISION.              
    PERFORM A100-OPEN-FILES      
    PERFORM A200-WRITE-HEADINGS  
    PERFORM A300-PROCESS-SUBJECTS
    PERFORM A400-PROCESS-MARKS   
    PERFORM A500-WRITE-TOTALS    
    PERFORM A600-CLOSE-FILES     
    STOP RUN                     
    .                           

 A100-OPEN-FILES.              
*    OPENS FILES               
     OPEN INPUT  F01-SUBJ-FILE 
                 F02-MARK-FILE 
     OPEN OUTPUT F03-REPT-FILE 
     .                         

 A200-WRITE-HEADINGS.                                 
*    WRITES HEADERS TO THE REPORT FILE                
     MOVE W03-HEADER-ROW1 TO F03-REPT-RECORD          
     WRITE F03-REPT-RECORD                            

     MOVE FUNCTION CURRENT-DATE (1:8) TO W04-SYS-DATE 
     MOVE W04-YEAR  TO W03-YEAR                       
     MOVE W04-MONTH TO W03-MONTH                      
     MOVE W04-DAY   TO W03-DAY                        

     MOVE W03-HEADER-ROW2 TO F03-REPT-RECORD          
     WRITE F03-REPT-RECORD                            

     MOVE W03-HEADER-ROW3 TO F03-REPT-RECORD          
     WRITE F03-REPT-RECORD                            
     .

 A300-PROCESS-SUBJECTS.                                     
*    MOVES SUBJECT NAMES AND CODES INTO W02-TEST-TABLE      
     PERFORM A310-READ-RECORD                               
     PERFORM UNTIL W01-SUBJ-EOF = 'Y'                       
         IF W02-SUBJ-COUNT < W02-SUBJ-MAX                   
             ADD 1 TO W02-SUBJ-COUNT                        
             SET W02-IDX TO W02-SUBJ-COUNT                  
             MOVE F01-SUBJ-CODE TO W02-SUBJ-CODE(W02-IDX)   
             MOVE F01-SUBJ-NAME TO W02-SUBJ-NAME(W02-IDX)   
         ELSE                                               
             DISPLAY "ERROR - SUBJECT FILE EXCEEDS MAX OF " 
                 W02-SUBJ-MAX " RECORDS, RECORD IGNORED"                       
         END-IF                                             
         PERFORM  A310-READ-RECORD                          
     END-PERFORM
     .          

 A310-READ-RECORD.                                      
*    READS FROM THE SUBJECT FILE INTO THE SUBJECT RECORD
     READ F01-SUBJ-FILE                                 
         AT END MOVE 'Y' TO W01-SUBJ-EOF                
     END-READ                                           
     .                                                  

 A400-PROCESS-MARKS.             
     PERFORM A410-READ-RECORD    
     PERFORM A420-COUNT-MARKS    
         UNTIL W01-MARK-EOF = 'Y'
     .                           

 A410-READ-RECORD.                                  
*    READS FROM THE MARK FILE INTO THE MARK RECORD  
     READ F02-MARK-FILE                             
         AT END MOVE 'Y' TO W01-MARK-EOF            
     END-READ                                       
     .                                              

 A420-COUNT-MARKS.                                               
*    COUNTS GRADE TOTALS                                         
     SET W02-IDX TO 1                                            
     SEARCH ALL W02-TEST-ROW                                     
         AT END DISPLAY 'INVALID INPUT RECORD: ' F02-MARK-RECORD 
         WHEN W02-SUBJ-CODE(W02-IDX) = F02-SUBJ-CODE             
             EVALUATE F02-STUD-MARK                              
                 WHEN "80" THRU "100"                            
                    ADD 1 TO W05-TOTAL-A                         
                    ADD 1 TO W02-A-CTR(W02-IDX)                  
                 WHEN "70" THRU "79"                             
                    ADD 1 TO W05-TOTAL-B                         
                    ADD 1 TO W02-B-CTR(W02-IDX)                  
                 WHEN "60" THRU "69"               
                    ADD 1 TO W05-TOTAL-C           
                    ADD 1 TO W02-C-CTR(W02-IDX)    
                 WHEN "50" THRU "59"               
                    ADD 1 TO W05-TOTAL-D           
                    ADD 1 TO W02-D-CTR(W02-IDX)    
                 WHEN OTHER                        
                    ADD 1 TO W05-TOTAL-F           
                    ADD 1 TO W02-F-CTR(W02-IDX)    
             END-EVALUATE                          
     END-SEARCH                                    
     .                                             

 A500-WRITE-TOTALS.                         
     PERFORM A510-WRITE-SUBJ-GRADE-TOTALS   
     PERFORM A520-WRITE-GRADE-GRAND-TOTALS  
     .                                      

 A510-WRITE-SUBJ-GRADE-TOTALS.              
     PERFORM VARYING W02-IDX FROM 1 BY 1  
     UNTIL W02-IDX > W02-SUBJ-COUNT       
          MOVE W02-SUBJ-NAME(W02-IDX) TO W03-SUBJ-NAME  
          MOVE W02-A-CTR(W02-IDX) TO W03-A-CTR          
          MOVE W02-B-CTR(W02-IDX) TO W03-B-CTR          
          MOVE W02-C-CTR(W02-IDX) TO W03-C-CTR          
          MOVE W02-D-CTR(W02-IDX) TO W03-D-CTR          
          MOVE W02-F-CTR(W02-IDX) TO W03-F-CTR          
          MOVE W03-DETAIL-ROW TO F03-REPT-RECORD        
          WRITE F03-REPT-RECORD                            
     END-PERFORM   
     .               

 A520-WRITE-GRADE-GRAND-TOTALS.                       
*    WRITES THE GRADE GRAND TOTALS TO THE REPORT FILE 
*    AFTER INSERTING A BLANK ROW                      
     MOVE SPACES TO F03-REPT-RECORD                   
     WRITE F03-REPT-RECORD                            

     MOVE W05-TOTAL-A TO W03-TOTAL-A                  
     MOVE W05-TOTAL-B TO W03-TOTAL-B                  
     MOVE W05-TOTAL-C TO W03-TOTAL-C                  
     MOVE W05-TOTAL-D TO W03-TOTAL-D                  
     MOVE W05-TOTAL-F TO W03-TOTAL-F                  

     MOVE W03-TOTAL-ROW TO F03-REPT-RECORD            
     WRITE F03-REPT-RECORD                            
     .                                                

 A600-CLOSE-FILES.        
*    CLOSES THE FILES     
     CLOSE F01-SUBJ-FILE  
           F02-MARK-FILE  
           F03-REPT-FILE  
     .                    
cobol mainframe zos
2个回答
1
投票

我很高兴你知道了,汤姆。

我希望您没有被关闭,并且会继续探索。仅供参考,尽管ISPF,TSO / E和其他经典用户界面仍然有效(有些人仍然喜欢它们,并且它们将“永远”继续工作),但如今,开发人员经常使用并喜欢图形用户界面。有一些免费的,例如IBM Explorer for z / OS及其远程系统资源管理器(RSE):

https://developer.ibm.com/mainframe/products/zosexplorer/

您可以根据自己的喜好(在z / OS上使用RSE部分)在Mac或PC(Linux或Windows)上单独运行就可以了。全部免费。或者,如果您愿意,可以添加IBM Z Open Development插件来添加更多“ COBOL感知”编辑器(以及其他一些功能):

https://developer.ibm.com/mainframe/products/ibm-z-open-development/

而且它也可以免费使用90天。在90天结束时,您可以支付固定的价格以保留这些插件,也可以将其卸载,然后仅使用base / free Explorer for z / OS功能。

也许这会对您的老师/教授提供很好的反馈?是的,您第一次通过emacs和终端仿真器体验任何编程语言可能是(例如)。是的,您可以使用emacs,ISPF或vi编写Apple Swift代码(例如)。但是,这些经典的用户界面并不是每个人都喜欢的。同样,如果您喜欢特定的UI,并且可以为您工作,那就没问题!但是从教学的角度来看,最好是从听众更熟悉的东西开始。

编辑时:作为另一个示例,如果您偏爱Microsoft Visual Studio Code,则可以向该IDE免费添加IBM Z Open Editor


0
投票

我通过在每个函数的开头放置一个DISPLAY来找出程序的问题,该函数输出正在运行的函数。我看到它处于A420-COUNT-MARKS的无限循环中,并且我忘记在其末尾添加PERFORM A410-READ-RECORD。

© www.soinside.com 2019 - 2024. All rights reserved.