Hello ,
im trying to convert sequential cobol file to csv using data i found online.
I looking for a way to replace the first space with a coma and delete the others , is it possible ?
im trying to convert sequential cobol file to csv using data i found online.
Code:
IDENTIFICATION DIVISION.
PROGRAM-ID. CPYFILES.
AUTHOR. M.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT MY-INPUT-FILE ASSIGN TO
"C:\Users\Hp\Documents\my_input.txt"
ORGANIZATION IS LINE SEQUENTIAL.
SELECT MY-OUTPUT-FILE ASSIGN TO
"C:\Users\Hp\Documents\my_output.txt"
ORGANIZATION IS LINE SEQUENTIAL.
DATA DIVISION.
FILE SECTION.
FD MY-INPUT-FILE.
01 MY-INPUT-LINE PIC X(180).
FD MY-OUTPUT-FILE.
01 MY-OUTPUT-LINE PIC X(181).
WORKING-STORAGE SECTION.
01 END-OF-FILE PIC X VALUE SPACE.
88 END-OF-INPUT-FILE VALUE 'T'.
88 NOT-END-OF-INPUT-FILE VALUE 'F'.
01 i pic 9(3) value zero .
01 j pic 9(3) value 1 .
01 k pic 9(3) value 1 .
PROCEDURE DIVISION.
OPEN INPUT MY-INPUT-FILE
OPEN EXTEND MY-OUTPUT-FILE
SET NOT-END-OF-INPUT-FILE TO TRUE
PERFORM UNTIL END-OF-INPUT-FILE
READ MY-INPUT-FILE
NOT AT END
PERFORM VARYING i from 1 by 1 until i>180
If MY-INPUT-LINE(i:1)= SPACE
continue
ELSE
MOVE MY-INPUT-LINE(i:1) to MY-OUTPUT-LINE (j:1)
END-IF
END-PERFORM
WRITE MY-OUTPUT-LINE
AT END
SET END-OF-INPUT-FILE TO TRUE
END-READ
END-PERFORM
CLOSE MY-INPUT-FILE
CLOSE MY-OUTPUT-FILE
STOP RUN.