compare 2 files and move common record into other file
IDENTIFICATION DIVISION.
PROGRAM-ID. SANDEEP.
DATE-COMPILED.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT IN1-FILE ASSIGN TO IN1
ORGANIZATION IS SEQUENTIAL.
SELECT IN2-FILE ASSIGN TO IN2
ORGANIZATION IS SEQUENTIAL.
SELECT MATCH-FILE ASSIGN TO MATCH
ORGANIZATION IS SEQUENTIAL.
SELECT OUT1-FILE ASSIGN TO OUT1
ORGANIZATION IS SEQUENTIAL.
SELECT OUT2-FILE ASSIGN TO OUT2
ORGANIZATION IS SEQUENTIAL.
DATA DIVISION.
FILE SECTION.
FD IN1-FILE
01 IN1-REC.
05 IN1-KEY PIC X(10).
05 FILLER PIC X(70).
FD IN2-FILE
01 IN2-REC.
05 IN2-KEY PIC X(10).
05 FILLER PIC X(70).
FD MATCH-FILE
01 MATCH-REC PIC X(80).
FD OUT1-FILE
01 OUT1-REC PIC X(80).
FD OUT2-FILE
01 OUT2-REC PIC X(80).
WORKING-STORAGE SECTION.
01 S-IN1-FILE PIC X(01) VALUE 'N'.
01 S-IN2-FILE PIC X(01) VALUE 'N'.
PROCEDURE DIVISION.
PERFORM 1000-INITIALIZATION
PERFORM 2000-MAIN-PROCESS UNTIL
S-IN1-FILE = 'Y' AND S-IN2-FILE = 'Y'
PERFORM 3000-WRAPUP
STOP RUN.
.
1000-INITIALIZATION.
*********************************************************************
* THIS PARAGRAPH OPENS INPUT AND OUTPUT FILES AND DOES THE *
* PRIME READ. *
*********************************************************************
OPEN INPUT IN1-FILE
IN2-FILE
OUTPUT MATCH-FILE
OUT1-FILE
OUT2-FILE
PERFORM 2100-READ-IN1-FILE
PERFORM 2200-READ-IN2-FILE
.
2000-MAIN-PROCESS.
*************************************************************
* THIS PARAGRAPH PERFORMS THE MAIN LOGIC *
*************************************************************
EVALUATE TRUE
WHEN IN1-KEY = IN2-KEY
PERFORM 2300-WRITE-MATCH-FILE
PERFORM 2100-READ-IN1-FILE
PERFORM 2200-READ-IN2-FILE
WHEN IN1-KEY < IN2-KEY
PERFORM 2400-WRITE-OUT1-FILE
PERFORM 2100-READ-IN1-FILE
WHEN IN1-KEY > IN2-KEY
PERFORM 2500-WRITE-OUT2-FILE
PERFORM 2200-READ-IN2-FILE
END-EVALUATE
.
2100-READ-IN1-FILE.
*************************************************************
* THIS PARAGRAPH READS THE IN1-FILE *
*************************************************************
READ IN1-FILE
AT END
MOVE 'Y' TO S-IN1-FILE
MOVE HIGH-VALUES TO IN1-KEY
END-READ
.
2200-READ-IN2-FILE.
*************************************************************
* THIS PARAGRAPH READS THE IN2-FILE *
*************************************************************
READ IN2-FILE
AT END
MOVE 'Y' TO S-IN2-FILE
MOVE HIGH-VALUES TO IN2-KEY
END-READ
.
2300-WRITE-MATCH-FILE.
*************************************************************
* THIS PARAGRAPH WRITES RECORDS WHICH MATCHES ON BOTH FILES.*
*************************************************************
MOVE SPACES TO MATCH-REC
MOVE IN1-REC TO MATCH-REC
WRITE MATCH-REC
.
2400-WRITE-OUT1-FILE.
******************************************************************8
* THIS PARAGRAPH WRITES RECORDS WHICH ARE ONLY IN IN1 FILE. *
*******************************************************************
MOVE SPACES TO OUT1-REC
MOVE IN1-REC TO OUT1-REC
WRITE OUT1-REC
.
2500-WRITE-OUT2-FILE.
*******************************************************************
* THIS PARAGRAPH WRITES RECORDS WHICH ARE ONLY IN IN2 FILE. *
*******************************************************************
MOVE SPACES TO OUT2-REC
MOVE IN2-REC TO OUT2-REC
WRITE OUT2-REC
.
3000-WRAPUP.
*************************************************************
* THIS PARAGRAPH CLOSES THE INPUT & OUTPUT FILES. *
*************************************************************
CLOSE IN1-FILE
IN2-FILE
MATCH-FILE
OUT1-FILE
OUT2-FILE.
---------------------------------------------------------------------------------------
COMPILER:
//KC03P85R JOB 123.'SANDEEP',NOTIFY=&SYSUID
//STEP1 EXEC IGYWCL
//COBOL.SYSIN DD DSN=KC03P85.JOB.SAMPLE,DISP=SHR
//LKED.SYSLMOD DD DSN=KC03P85.JOB.LOAD(L1),DISP=SHR
-----------------------------------------------------------------------------------------
RUN JCL
//KC03P85T JOB 123.'SANDEEP',NOTIFY=&SYSUID.
//JOBLIB DD DSN=KC03PP85.JOB.LOAD,DISP=SHR
//STEP1 EXEC PGM=LI
//IN1 DD DSN=KC03P85.JOB.PS1,DISP=SHR
//IN2DD DSN=KC03P85.JOB.PS2,DISP=SHR
//MATCH DD DSN=KC03P85.JOB.MATCH,DISP=SHR
//OUT1 DD DSN=KC03P85.JOB.OUT1,DISP=SHR
//OUT2 DD DSN=KC03P85.JOB.OUT2,DISP=SHR
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUY=*
//
---------------------------------------------------------------------------------------
COMPILER:
//KC03P85R JOB 123.'SANDEEP',NOTIFY=&SYSUID
//STEP1 EXEC IGYWCL
//COBOL.SYSIN DD DSN=KC03P85.JOB.SAMPLE,DISP=SHR
//LKED.SYSLMOD DD DSN=KC03P85.JOB.LOAD(L1),DISP=SHR
-----------------------------------------------------------------------------------------
RUN JCL
//KC03P85T JOB 123.'SANDEEP',NOTIFY=&SYSUID.
//JOBLIB DD DSN=KC03PP85.JOB.LOAD,DISP=SHR
//STEP1 EXEC PGM=LI
//IN1 DD DSN=KC03P85.JOB.PS1,DISP=SHR
//IN2DD DSN=KC03P85.JOB.PS2,DISP=SHR
//MATCH DD DSN=KC03P85.JOB.MATCH,DISP=SHR
//OUT1 DD DSN=KC03P85.JOB.OUT1,DISP=SHR
//OUT2 DD DSN=KC03P85.JOB.OUT2,DISP=SHR
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUY=*
//
Comments
Post a Comment