Monday, 4 February 2013

COBOL Prog to copy data from PS to PS

COBOL Prog to copy data from PS to PS :

IDENTIFICATION DIVISION.                     
PROGRAM-ID. FILWRIT.                         
ENVIRONMENT DIVISION.                        
CONFIGURATION SECTION.                       
OBJECT-COMPUTER. IBM-390.                    
SOURCE-COMPUTER. IBM-390.                    
INPUT-OUTPUT SECTION.                        
FILE-CONTROL.                                
    SELECT INFILE ASSIGN TO DD1              
    ORGANIZATION IS SEQUENTIAL               
    ACCESS MODE IS SEQUENTIAL                
    FILE STATUS IS FS1.                      
    SELECT OUTFILE ASSIGN TO DD2             
    ORGANIZATION IS SEQUENTIAL               
    ACCESS MODE IS SEQUENTIAL                
    FILE STATUS IS FS2.                      
DATA DIVISION.                               
FILE SECTION.
                                
FD INFILE                                    
    LABEL RECORDS ARE STANDARD               
    BLOCK CONTAINS 0 RECORDS                 
    RECORDING MODE IS F.
                     
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).
      
FD OUTFILE                                   
    LABEL RECORDS ARE STANDARD               
    BLOCK CONTAINS 0 RECORDS                 
    RECORDING MODE IS F.
                     
01 OUTREC.                                   
    05 FILLER                 PIC X(80).
      
WORKING-STORAGE SECTION.                     
01 FS1                            PIC X(02).      
01 FS2                            PIC X(02).      

01 SWITCH                    PIC X(01).     
    88 EOF                        VALUE 'Y'.     
    88 NOT-EOF               VALUE 'N'.     
01 WS-COUNT                PIC 9(04).
     
PROCEDURE DIVISION.                         
    SET NOT-EOF TO TRUE.                    
    PERFORM OPEN-PARA.                      
    PERFORM READ-PARA UNTIL EOF.            
    PERFORM
CLOSE-PARA.                     
    STOP RUN.                               
OPEN-PARA.                                  
    OPEN INPUT INFILE.                      
    OPEN OUTPUT OUTFILE.                    
    DISPLAY ' INPUT FILE OPEN STATUS ' FS1. 
    DISPLAY ' OUTPUT FILE OPEN STATUS ' FS2.
READ-PARA.                                  
    IF FS1 = '00'                           
       READ INFILE                          
         AT END                             
            SET EOF TO TRUE                 
         NOT AT END                         
            MOVE INREC TO OUTREC          
            WRITE OUTREC                    
       END-READ                             
    END-IF.                                 
CLOSE-PARA.                                 
    CLOSE INFILE                            
    CLOSE
OUTFILE.                          
    DISPLAY ' INPUT  FILE CLOSE STATUS ' FS1.   
    DISPLAY ' OUTPUT FILE CLOSE STATUS ' FS2.

No comments:

Post a Comment