As everybody says, we need to know what PERFORM 800-WRITECSV-XYZINV.
does...
but I have worked in a similar solution for write CSV files
*...
*acces to you table and it fills the variables WS-A WS-B and WS-C
*build heather
STRING "A" ","
"B" ","
"C" DELIMITED BY SIZE
INTO WS-LINE
END-STRING
* write header
WRITE FILE FROM WS-LINE
...
Then for each file from the table, you can:
INITIALIZE WS-LINE
*build line whit the values
STRING WS-A ","
WS-B ","
WS-C DELIMITED BY "SIZE" <-- it will print all spaces that each variable have
INTO WS-LINE
END-STRING
* write line
WRITE FILE FROM WS-LINE
...