2

Cobol program :

PROGRAM-ID. SCHPROG.            
ENVIRONMENT DIVISION.           
INPUT-OUTPUT SECTION.           
FILE-CONTROL.                   
    SELECT MYFILE ASSIGN TO INDD
    ORGANIZATION IS SEQUENTIAL  
    ACCESS MODE IS SEQUENTIAL.  
DATA DIVISION.                  
FILE SECTION.                   
FD MYFILE.                      
01 FILERECORDS.                 
    05 NAME    PIC A(10).       
    05 CLASS-IN PIC 9(1).       
    05 ROLL    PIC 9(5).        
WORKING-STORAGE SECTION.        
COPY SCHMAPA.                   
COPY SCHMAPB.                   
COPY SCHMAPC.                   
01 END-OF-FILE PIC A(3) VALUE 'NO'.
PROCEDURE DIVISION.                
000-MAIN-PARA.                     
    PERFORM 100-SEND-MAPA.         
    PERFORM 100-RECEIVE-MAPA.      
    IF CHOICEI = '1'               
    PERFORM 200-SEND-MAPB          
    PERFORM 200-RECEIVE-MAPB       
    PERFORM 200-SEND-MAPB          
    PERFORM 100-SEND-MAPA          
    END-IF.                        
    IF CHOICEI = '2'               
    PERFORM 300-SEND-MAPC          
    PERFORM 300-RECEIVE-MAPC       
    PERFORM 500-SRCH-REC           
    PERFORM 300-SEND-MAPC          
        PERFORM 100-SEND-MAPA              
    END-IF.                            
    STOP RUN.                          
100-SEND-MAPA.                         
    EXEC CICS                          
    SEND                               
    MAP('SCHOLA') MAPSET('SCHMAPA')    
    ERASE                              
    END-EXEC.                          
100-RECEIVE-MAPA.                      
    EXEC CICS                          
    RECEIVE                            
    MAP('SCHOLA') MAPSET('SCHMAPA')    
    END-EXEC.                          
200-SEND-MAPB.                         
    EXEC CICS                          
    SEND                               
         MAP('SCHOLB') MAPSET('SCHMAPB')     
     ERASE                               
     END-EXEC.                           
 200-RECEIVE-MAPB.                       
     EXEC CICS                           
     RECEIVE                             
     MAP('SCHOLB') MAPSET('SCHMAPB')     
     END-EXEC.                           
     PERFORM 400-FILE-PROCESS.           
 300-SEND-MAPC.                          
     EXEC CICS                           
     SEND                                
     MAP('SCHOLC') MAPSET('SCHMAPC')     
     ERASE                               
     END-EXEC.                           
 300-RECEIVE-MAPC.                       
     EXEC CICS                           
         RECEIVE                            
    MAP('SCHOLC') MAPSET('SCHMAPC')    
    END-EXEC.                          
400-FILE-PROCESS.                      
    OPEN OUTPUT MYFILE.                
    MOVE NAMEI TO NAME.                
    MOVE CLASSI TO CLASS-IN.           
    MOVE ROLLI TO ROLL.                
    WRITE FILERECORDS.                 
    CLOSE MYFILE.                      
    MOVE 'RECORD INSERTED' TO MSGBO.   
500-SRCH-REC.                          
    OPEN INPUT MYFILE.                 
    PERFORM UNTIL END-OF-FILE = 'YES'  
         READ MYFILE INTO FILERECORDS 
       AT END                     
        MOVE 'YES' TO END-OF-FILE 
       NOT AT END                 
        IF ROLL =  ROLLCI         
        MOVE NAME TO NAMECO       
        MOVE CLASS-IN TO CLASSCO  
        END-IF                    
     END-READ                     
  END-PERFORM.                    
  CLOSE MYFILE.            
    

Getting error.

IGYPA3043-E   Data-item "FILERECORDS (GROUP)" and record "FILERECORDS (GROUP)"
had overlapping storage.  Movement of data may not occur at execution time.

I have provided my cobol program. please check and help me to find the issue.

I am updating file from Cics region and using the same file to get the details and put in cics region.

Not sure why I am getting this error. Earlier I am using same Group data Item to add record to file and it is working fine. Please help !!

Rahul
  • 117
  • 1
  • 14
  • Can you share more of the FILE-CONTROL and WORKING STORAGE definitions ? Where is ROLLCI and NAMECO defined and what do they look like? – Hogstrom Apr 06 '21 at 14:23

3 Answers3

5

While the other answers correctly answer your question, compiling for CICS entails some restrictions documented here and quoted as of 06-Apr-2021 below. You may also want to consult the CICS documentation for your version and release of CICS.

Restriction: You cannot run COBOL programs that have object-oriented syntax for Java™ interoperability in CICS. In addition, if you write programs to run under CICS, do not use the following code:

  • FILE-CONTROL entry in the ENVIRONMENT DIVISION, unless the FILE-CONTROL entry is used for a SORT statement
  • FILE SECTION of the DATA DIVISION, unless the FILE SECTION is used for a SORT statement
  • User-specified parameters to the main program USE declaratives (except USE FOR DEBUGGING)
  • These COBOL language statements:
  • ACCEPT format 1: data transfer (you can use format-2 ACCEPT to retrieve the system date and time)
  • CLOSE
  • DELETE
  • DISPLAY UPON CONSOLE
  • DISPLAY UPON SYSPUNCH
  • MERGE
  • OPEN
  • READ
  • RERUN
  • REWRITE
  • START
  • STOP literal
  • WRITE

[...]

Coding file input and output: You must use CICS commands for most input and output processing. Therefore, do not describe files or code any OPEN, CLOSE, READ, START, REWRITE, WRITE, or DELETE statements. Instead, use CICS commands to retrieve, update, insert, and delete data.

cschneid
  • 10,237
  • 1
  • 28
  • 39
3

READ MYFILE INTO FILERECORDS is a duplicate because those are already assigned to each other.
To fix that simply use READ MYFILE (the INTO somewhere would only be used if you don't want to place that into FILERECORDS but somewhere else).

Simon Sobisch
  • 6,263
  • 1
  • 18
  • 38
3

Similar answer to @simon's.

READ already places the record into the 01 definition in MYFILE. READ INTO is used when you want the data to be placed in another area in WORKING-STORAGE. Executing a READ INTO to the FD area is simply moving the data over itself.

I was always taught to do a READ INTO an area that I defined or was a COPYBOOK in WORKING-STORAGE to separate the I/O area from the data manipulation.

In assembler what you are doing with READ is the equivalent of a GET LOCATE as opposed to a GET MOVE type of operation.

Hogstrom
  • 3,581
  • 2
  • 9
  • 25