Hello Im learning COBOL and have a text file that has a bunch of works and numbers separated by “,”. I need it to stop when it hits the comma and then move to the next variable and so on. here is my file
1001,John,Doe,Engineer,85000
Heres my current code:
`
IDENTIFICATION DIVISION.
PROGRAM-ID. PayRoll.
AUTHOR. TheodoreRoche.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT EMPLOYEE ASSIGN TO "COBOLT_Test_File.csv"
ORGANIZATION IS LINE SEQUENTIAL.
DATA DIVISION.
FILE SECTION.
FD EMPLOYEE.
01 EMPLOYEE-FILE.
02 EMPLOYEE-ID PIC 9(4).
02 FIRST-NAME PIC X(30).
02 LAST-NAME PIC X(30).
02 EMPLOYEE-POSITION PIC X(30).
02 SALARY PIC 9(10).
WORKING-STORAGE SECTION.
01 WS-EOF PIC A(1).
01 WS-EMPLOYEE.
02 WS-EMPLOYEE-ID PIC 9(4).
02 WS-FIRST-NAME PIC X(30).
02 WS-LAST-NAME PIC X(30).
02 WS-EMPLOYEE-POSITION PIC X(30).
02 WS-SALARY PIC 9(10).
PROCEDURE DIVISION.
OPEN INPUT EMPLOYEE.
PERFORM UNTIL WS-EOF='Y'
READ EMPLOYEE INTO WS-EMPLOYEE
AT END MOVE 'Y' TO WS-EOF
NOT AT END
DISPLAY "ID #: " WS-EMPLOYEE-ID
DISPLAY "First Name: " WS-FIRST-NAME
DISPLAY "Last Name: " WS-LAST-NAME
DISPLAY "Position: " WS-EMPLOYEE-POSITION
DISPLAY "Salary: " WS-SALARY
END-READ
END-PERFORM.
CLOSE EMPLOYEE.
STOP RUN.
`
this is an example of what Im getting as an output:
ID #: 1001
First Name: John Doe Engineer 85000
Last Name:
Position:
Salary:
Im really stuck and have tried looking online and even going to chatGPT, but Im really confused right now.