Skip to content

Instantly share code, notes, and snippets.

@sandeep-sparrow
Last active April 22, 2021 23:30
Show Gist options
  • Save sandeep-sparrow/ead9a0427fe8cae3d2c767369de3f63e to your computer and use it in GitHub Desktop.
Save sandeep-sparrow/ead9a0427fe8cae3d2c767369de3f63e to your computer and use it in GitHub Desktop.
COBOL PROGRAM USING INTERNAL SORT TO MERGE TWO INPUT FILE IN OUTPUT FILE
IDENTIFICATION DIVISION.
PROGRAM-ID. CBLMERG.
*
******************************************************************
* AUTHOR: SANDEEP
* DESC : COBOL PROGRAM USING INTERNAL SORT TO MERGE
* : TWO INPUT FILE IN OUTPUT FILE.
******************************************************************
ENVIRONMENT DIVISION.
*
INPUT-OUTPUT SECTION.
*
FILE-CONTROL.
*
SELECT INPUT1 ASSIGN TO IN1.
SELECT INPUT2 ASSIGN TO IN2.
SELECT OUTPT1 ASSIGN TO OUT.
SELECT WORK ASSIGN TO WRK.
*
DATA DIVISION.
*
FILE SECTION.
*
FD INPUT1 RECORDING MODE F
RECORD CONTAINS 40 CHARACTERS.
01 INPUT1-STUDENT.
05 STUDENT-ID1-I1 PIC 9(05).
05 STUDENT-NAME-I1 PIC X(25).
05 STUDENT-ADDR-I1 PIC X(10).
*
FD INPUT2 RECORDING MODE F
RECORD CONTAINS 40 CHARACTERS.
01 INPUT2-STUDENT.
05 STUDENT-ID2-I2 PIC 9(05).
05 STUDENT-NAME-I2 PIC X(25).
05 STUDENT-ADDR-I2 PIC X(10).
*
FD OUTPT1 RECORDING MODE F.
01 OUTPUT-STUDENT.
05 STUDENT-ID-O PIC 9(05).
05 STUDENT-NAME-O PIC X(25).
05 STUDENT-ADDR-O PIC X(10).
*
SD WORK.
01 WORK-STUDENT.
05 STUDENT-ID-W PIC 9(05).
05 STUDENT-NAME-W PIC X(25).
05 STUDENT-ADDR-W PIC X(10).
*
PROCEDURE DIVISION.
*
MERGE WORK ON ASCENDING KEY STUDENT-ID-W
USING INPUT1, INPUT2 GIVING OUTPT1
DISPLAY 'Merge Succesfull!'
*
STOP RUN.
*
//JOBNAME JOB MSGLEVEL=(1,1),NOTIFY=&SYSUID
//STEP01 EXEC PGM=CBLMERG
//STEPLIB DD DSN=LOADLIB,DISP=SHR
//IN1 DD DSN=DF.STUDENT1,DISP=SHR
//IN2 DD DSN=DF.STUDENT2,DISP=SHR
//OUT DD DSN=DF.OUTPT1,DISP=SHR
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
00001JANVI DESAI KALOL
00002MEET DESAI KALOL
00003YUVRAJ SHANGADA KALOL
00006SLOK DESAI KALOL
00005DESAI MISHWA KALOL
00004SANDEEP PRAJAPATI MUMBAI
00001JANVI DESAI KALOL
00002MEET DESAI KALOL
00003YUVRAJ SHANGADA KALOL
00006SLOK DESAI KALOL
00005DESAI MISHWA KALOL
00004SANDEEP PRAJAPATI MUMBAI
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment