Saturday, 2 February 2013

COBOL Prog to delete record from KSDS

COBOL Prog to delete record from KSDS :

*Record can not be deleted from ESDS or flat file(PS) thru program, records can be deleted only from KSDS & RRDS files.

IDENTIFICATION DIVISION.                     
PROGRAM-ID. FILDELT.                         
ENVIRONMENT DIVISION.                        
CONFIGURATION SECTION.                       
OBJECT-COMPUTER. IBM-390.                    
SOURCE-COMPUTER. IBM-390.                    
INPUT-OUTPUT SECTION.                        
FILE-CONTROL
.                                
    SELECT INFILE ASSIGN TO DD1              
    ORGANIZATION IS INDEXED                  
    ACCESS MODE IS RANDOM                    
    RECORD KEY IS EID                        
    FILE STATUS IS FS1.
                      
DATA DIVISION.                               
FILE SECTION.
                                
FD INFILE.                                   
01 INREC.                                    
    05 EID                   PIC X(05).         
    05 FILLER             PIC X(01).         
    05 ENAME            PIC X(06).         
    05 FILLER             PIC X(01).         
    05 ESAL                PIC 9(05).         
    05 FILLER             PIC X(62).         
WORKING-STORAGE SECTION.                     
01 FS1                    PIC X(02).         
PROCEDURE DIVISION.                          
    PERFORM OPEN-PARA.                       
    PERFORM DELT-PARA.                       
    PERFORM CLOSE-PARA.                      
    STOP RUN.                                
OPEN-PARA.                                   
    OPEN I-O INFILE                          
    DISPLAY ' OPEN INFILE STATUS ' FS1.      
    MOVE '21600' TO EID.                     
DELT-PARA.                                   
    IF FS1 = '00'                            
       READ INFILE                           
          INVALID KEY                        

             DISPLAY ' KEY IS NOT VALID '  
          NOT INVALID KEY                  
                  DISPLAY
INREC            
                  DELETE INFILE            
       END-READ                            
    END-IF.
                                
CLOSE-PARA.                                
    CLOSE INFILE                           
    DISPLAY ' CLOSE INFILE STATUS ' FS1.
   

No comments:

Post a Comment