KSDS BEFORE EDITING
10012 DEFAS ACCT 00008 111111111
10013 GHIQW FINS 10102 342-51235
10015 ASFER KKKKK 11111 122222222
10019 DSASA EREWT 31564 124331354
10020 SAFDF SAFAS 35256 12-243253
10021 QQQQQ ZZZZZ 25232 666666666
10012 DEFAS ACCT 00008 111111111
10013 GHIQW FINS 10102 342-51235
10015 ASFER KKKKK 11111 122222222
10019 DSASA EREWT 31564 124331354
10020 SAFDF SAFAS 35256 12-243253
10021 QQQQQ ZZZZZ 25232 666666666
PS FILE BEFORE EXECUTING
10011 ABCSA SALES 50000 004-12345 I
10012 DEFAS ACCT 80000 123-98754 U
10013 GHIQW FINS 10102 342-51235 D
10014 WE2EW PROG 20030 192-24213 I
10015 ASFER DEVOL 24322 1244-2421 U
10016 SFART TEST 15326 213215423 U
10017 SDNGF DJDHA 14223 126723463 D
10018 QWESD AZXCV 15005 12-432153 I
10019 DSASA EREWT 31564 124331354 I
10020 SAFDF SAFAS 35256 12-243253 D
10021 AZDFZ ZAFSA 25232 214215324 U
10022 ZADFA LPNHG 36437 079684456 I
10023 MNGGB GFGUY 35642 186545364 U
10024 FEGFR MNBVC 86543 132434343 I
10025 IOHGY HJGDF 90865 537375879 D
10026 VCGHV VNCFD 64859 323546644 I
KSDS after executing
10011...ABCSA...SALES...50000...004-12345...............
10012...DEFAS...ACCT ...80000...123-98754...............
10014...WE2EW...PROG ...20030...192-24213...............
10015...ASFER...DEVOL...24322...1244-2421...............
10018...QWESD...AZXCV...15005...12-432153...............
10019 dsasa erewt 31564 124331354
10021...AZDFZ...ZAFSA...25232...214215324...............
10022...ZADFA...LPNHG...36437...079684456...............
10024...FEGFR...MNBVC...86543...132434343...............
10026...VCGHV...VNCFD...64859...323546644...............
PS after executing
10011 ABCSA SALES 50000 004-12345 F SUCCESS
10012 DEFAS ACCT 80000 123-98754 F RECORD UPDATED
10013 GHIQW FINS 10102 342-51235 F RECORD DELETED
10014 WE2EW PROG 20030 192-24213 F SUCCESS
10015 ASFER DEVOL 24322 1244-2421 F RECORD UPDATED
10016 SFART TEST 15326 213215423 P RECORD NOT FOUND
10017 SDNGF DJDHA 14223 126723463 P RECORD NOT FOUND
10018 QWESD AZXCV 15005 12-432153 F SUCCESS
10019 DSASA EREWT 31564 124331354 P REC ALREADY PRESENT
10020 SAFDF SAFAS 35256 12-243253 F RECORD DELETED
10021 AZDFZ ZAFSA 25232 214215324 F RECORD UPDATED
10022 ZADFA LPNHG 36437 079684456 F SUCCESS
10023 MNGGB GFGUY 35642 186545364 P RECORD NOT FOUND
10024 FEGFR MNBVC 86543 132434343 F SUCCESS
10025 IOHGY HJGDF 90865 537375879 P RECORD NOT FOUND
10026 VCGHV VNCFD 64859 323546644 F SUCCESS
i - insert
u - update
d - delete
f - on success of operation
p - on failure of operation
f -
p - processes
IDENTIFICATION DIVISION.
PROGRAM-ID. PROJ.
AUTHOR. KK.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT EFILE1 ASSIGN
TO DD1
ORGANIZATION IS SEQUENTIAL
ACCESS MODE IS SEQUENTIAL
FILE STATUS IS FS1.
SELECT EFILE2 ASSIGN
TO DD2
ORGANIZATION IS INDEXED
ACCESS MODE IS RANDOM
RECORD KEY IS EMPID2
FILE STATUS IS FS2.
DATA DIVISION.
FILE SECTION.
FD EFILE1.
01 EREC1.
02 EMPID PIC X(5).
02 FILLER PIC X(3).
02 ENAME PIC X(5).
02 FILLER PIC X(3).
02 DEPT PIC X(5).
02 FILLER PIC X(3).
02 SALARY PIC X(5).
02 FILLER PIC X(3).
02 PNO PIC X(9).
02 FILLER PIC X(3).
02 STATUS1 PIC X.
02 FILLER PIC X(3).
02 REMARKS PIC X(20).
02 FILLER PIC X(12).
FD EFILE2.
01 EREC2.
02 EMPID2 PIC X(5).
02 FILLER PIC X(3).
02 ENAME2 PIC X(5).
02 FILLER PIC X(3).
02 DEPT2 PIC X(5).
02 FILLER PIC X(3).
02 SALARY2 PIC X(5).
02 FILLER PIC X(3).
02 PNO2 PIC X(9).
02 FILLER PIC X(39).
WORKING-STORAGE SECTION.
01 FS1 PIC 9(2).
01 FS2 PIC 9(2).
01 EOF PIC XX.
01 EREC3.
02 EMPID3 PIC X(5).
02 FILLER PIC X(3).
02 ENAME3 PIC X(5).
02 FILLER PIC X(3).
02 DEPT3 PIC X(5).
02 FILLER PIC X(3).
02 SALARY3 PIC X(5).
02 FILLER PIC X(3).
02 PNO3 PIC X(9).
02 FILLER PIC X(39).
PROCEDURE DIVISION.
OPEN I-O EFILE1
OPEN I-O EFILE2
PERFORM 0001-FILE-IN UNTIL FS1 = 10
CLOSE EFILE1
CLOSE EFILE2
STOP RUN.
0001-FILE-IN.
DISPLAY "FILE OPEN" FS1
READ EFILE1
AT END
DISPLAY 'READ SUCCESS'
NOT AT END
DISPLAY "FILE 1"
MOVE EMPID TO EMPID2
MOVE ENAME TO ENAME2
MOVE DEPT TO DEPT2
MOVE SALARY TO SALARY2
MOVE PNO TO PNO2
DISPLAY PNO
DISPLAY STATUS1
DISPLAY EMPID
PERFORM PARA1
REWRITE EREC1
END-READ
PARA1.
DISPLAY 'ENTERED PARA1'
IF STATUS1 = 'I'
DISPLAY 'ENTERED STATUS = I'
WRITE EREC2
INVALID KEY
DISPLAY 'INSERT UNSUCESSFULL'
MOVE "REC ALREADY PRESENT" TO REMARKS
MOVE 'P' TO STATUS1
NOT INVALID KEY
MOVE "SUCCESS" TO REMARKS
MOVE 'F' TO STATUS1
DISPLAY 'INSERT SUCCESSFULL'
ELSE IF STATUS1 = 'U'
REWRITE EREC2
INVALID KEY
DISPLAY 'UPDATE UNSUCESSFULL'
MOVE "RECORD NOT FOUND" TO REMARKS
MOVE 'P' TO STATUS1
NOT INVALID KEY
MOVE "RECORD UPDATED" TO REMARKS
MOVE 'F' TO STATUS1
DISPLAY 'UPDATE SUCCESSFULL'
ELSE IF STATUS1 = 'D'
DELETE EFILE2
INVALID KEY
DISPLAY 'DELETE UNSUCESSFULL'
MOVE "RECORD NOT FOUND" TO REMARKS
MOVE 'P' TO STATUS1
NOT INVALID KEY
MOVE "RECORD DELETED" TO REMARKS
MOVE 'F' TO STATUS1
DISPLAY 'DELETE SUCCESSFULL'
END-IF
END-IF
END-IF.
No comments:
Post a Comment