Program to Accept The Records of Employee and Store the contents in one file and store the records of a particular field in another file identification division.
identification division. program-id. employee. environment division. input-output section. file-control. select emp assign to disk organization is line sequential. select empn assign to disk organization is line sequential. data division. file section. fd emp value of file-id is"emp.txt". 01 emp-rec. 05 empno pic 9(3). 05 filler pic x(5). 05 empname pic x(10). 05 filler pic x(5). 05 state pic x(10). 05 filler pic x(5). 05 anlsal pic 9(4). fd empn value of file-id is"empn.txt". 01 empn-rec pic x(10). working-storage section. 01 eof pic x value"n". 01 emp1-rec. 05 empno1 pic 9(3). 05 filler pic x(5). 05 empname1 pic x(10). 05 filler pic x(5). 05 state1 pic x(10). 05 filler pic x(5). 05 anlsal1 pic 9(4). 01 empn1-rec pic x(10). procedure division. para1. open extend emp. open extend empn. display "Emp No.: " with no advancing. accept empno1. display "Emp Name: " with no advancing. accept empname1. display "Emp State: " with no advancing. accept state1. display "Emp Salary: " with no advancing. accept anlsal1. move emp1-rec to emp-rec. write emp-rec. close emp. open input emp. perform until eof="y" read emp at end move "y" to eof not at end display state move state to empn1-rec move empn1-rec to empn-rec write empn-rec end-read end-perform. close emp. close empn. stop run.