HELLO ,
IDENTIFICATION DIVISION.
PROGRAM-ID. SeqRead.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT StudentFile ASSIGN TO "C:\Users\Hp\Documents\NT5.txt"
ORGANIZATION IS LINE SEQUENTIAL.
SELECT NSTUDENT ASSIGN TO "C:\Users\Hp\Documents\FILE-2.txt"
ORGANIZATION IS LINE SEQUENTIAL.
DATA DIVISION.
FILE SECTION.
FD StudentFile.
01 StudentDetails.
88 EndOfStudentFile VALUE HIGH-VALUES.
02 StudentId PIC 9(7).
02 StudentName.
03 Surname PIC X(10).
02 YOBirth PIC 9(8).
02 CourseCode PIC X(4).
02 gender pic x(1) .
02 malecount pic 9(3) value zeros.
02 femalecount pic 9(3) value zeros.
FD NSTUDENT.
01 Ndetail.
02 NId PIC 9(7).
02 NName.
03 NSurname PIC X(10).
02 NYOBirth PIC 9(8).
02 NCourseCode PIC X(4).
02 Ngender pic x(1) .
02 Nmalecount pic 9(3) value zeros.
02 Nfemalecount pic 9(3) value zeros.
PROCEDURE DIVISION.
Begin.
OPEN INPUT StudentFile
OPEN OUTPUT NSTUDENT
PERFORM until EndOfStudentFile
READ StudentFile
AT END SET EndOfStudentFile TO TRUE
MOVE StudentDetails to Ndetail
DISPLAY Ndetail
WRITE Ndetail
END-PERFORM
CLose NSTUDENT
CLose StudentFile.
STOP RUN.
Im learning cobol ( still a beginner) , i have written the above code trying to transfer data from a .txt file to another but nothing tranfers and i get one letter written 36 times on the new file .
thise is the result file : ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
The originzl file is 36 lines like this one : 8712351SMITH MS19671012LM51F.
There is no error showing before compiling .
IDENTIFICATION DIVISION.
PROGRAM-ID. SeqRead.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT StudentFile ASSIGN TO "C:\Users\Hp\Documents\NT5.txt"
ORGANIZATION IS LINE SEQUENTIAL.
SELECT NSTUDENT ASSIGN TO "C:\Users\Hp\Documents\FILE-2.txt"
ORGANIZATION IS LINE SEQUENTIAL.
DATA DIVISION.
FILE SECTION.
FD StudentFile.
01 StudentDetails.
88 EndOfStudentFile VALUE HIGH-VALUES.
02 StudentId PIC 9(7).
02 StudentName.
03 Surname PIC X(10).
02 YOBirth PIC 9(8).
02 CourseCode PIC X(4).
02 gender pic x(1) .
02 malecount pic 9(3) value zeros.
02 femalecount pic 9(3) value zeros.
FD NSTUDENT.
01 Ndetail.
02 NId PIC 9(7).
02 NName.
03 NSurname PIC X(10).
02 NYOBirth PIC 9(8).
02 NCourseCode PIC X(4).
02 Ngender pic x(1) .
02 Nmalecount pic 9(3) value zeros.
02 Nfemalecount pic 9(3) value zeros.
PROCEDURE DIVISION.
Begin.
OPEN INPUT StudentFile
OPEN OUTPUT NSTUDENT
PERFORM until EndOfStudentFile
READ StudentFile
AT END SET EndOfStudentFile TO TRUE
MOVE StudentDetails to Ndetail
DISPLAY Ndetail
WRITE Ndetail
END-PERFORM
CLose NSTUDENT
CLose StudentFile.
STOP RUN.
Im learning cobol ( still a beginner) , i have written the above code trying to transfer data from a .txt file to another but nothing tranfers and i get one letter written 36 times on the new file .
thise is the result file : ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
The originzl file is 36 lines like this one : 8712351SMITH MS19671012LM51F.
There is no error showing before compiling .