IDENTIFICATION DIVISION.
PROGRAM-ID." SEQFILE".
AUTHOR."KUNAL".
DATE-WRITTEN."20/01/12".
DATE-COMPILED."20/01/12".
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SOURCE-COMPUTER. M8.
OBJECT-COMPUTER. M8.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT MAIN ASSIGN TO DISK
ORGANIZATION IS SEQUENTIAL
ACCESS MODE IS SEQUENTIAL.
SELECT O-FILE ASSIGN TO DISK
ORGANIZATION IS SEQUENTIAL
ACCESS MODE IS SEQUENTIAL.
SELECT WORK ASSIGN TO DISK
ORGANIZATION IS SEQUENTIAL
ACCESS MODE IS SEQUENTIAL.
DATA DIVISION.
FILE SECTION.
FD MAIN
LABEL RECORDS ARE STANDARD
VALUE OF FILE-ID IS "MAIN.DAT".
01 MAIN-REC.
02 PNAME PIC X(15).
02 PADD PIC X(20).
02 PPROF PIC X(10).
02 PSAL PIC 9(5)V99.
FD O-FILE
LABEL RECORDS ARE STANDARD
VALUE OF FILE-ID IS "OUTPUT.DAT".
01 O-REC.
02 ONAME PIC X(15).
02 OADD PIC X(15).
02 OPROF PIC X(10).
02 OSAL PIC 9(5)V99.
SD WORK.
01 W-REC.
02 WNAME PIC X(10).
02 WADD PIC X(10).
02 WPROF PIC X(10).
02 WSAL PIC 9(5)V99.
WORKING-STORAGE SECTION.
77 ANS PIC X.
PROCEDURE DIVISION.
OPEN OUTPUT MAIN.
READ-PARA.
DISPLAY "ENTER NAME:".
ACCEPT PNAME.
DISPLAY "ENTER ADDRESS:".
ACCEPT PADD.
DISPLAY "ENTER PROFESSION:".
ACCEPT PPROF.
DISPLAY "ENTER SALARY:".
ACCEPT PSAL.
WRITE MAIN-REC.
DISPLAY "TO continue....press Y".
ACCEPT ANS.
IF ANS = "Y"
GO TO READ-PARA.
END-PARA.
CLOSE MAIN.
SORT-PARA.
SORT WORK ON ASCENDING KEY WNAME USING MAIN GIVING O-FILE.
OPEN INPUT O-FILE.
DISPLAY "--------------------------------------------------".
DISPLAY "NAME ADDRESS PROFESSION SALARY".
DISPLAY "--------------------------------------------------".
PARA-1.
READ O-FILE AT END GO TO LAST-PARA CLOSE O-FILE.
DISPLAY ONAME OADD OPROF OSAL.
GO TO PARA-1.
LAST-PARA.
STOP RUN.
Sign up here with your email
ConversionConversion EmoticonEmoticon