I've done this a few times. I use a string statement with a pointer something like this:
First set the pointer to the beginning of your comma delimited record.
MOVE 1 TO PTR.
Build a record by repeating as needed:
Case type of variable to be include
when string
STRING QUOTE DELIMITED BY SIZE
STRING-VAR DELIMITED BY " "
in case string contains blanks
QUOTE DELIMITED BY SIZE
INTO COMMA-DELIM-REC
WITH POINTER PTR.
when integer
STRING INT-VALUE DELIMITED BY SIZE
INTO COMMA-DELIM-REC
WITH POINTER PTR.
when decimal number
STRING INTEGER-PORTION
"."
DECIMAL-PORTION DELIMITED BY SIZE
INTO COMMA-DELIM-REC
WITH POINTER PTR.
end case
If this is not the last entry
STRING "," DELIMITED BY SIZE
INTO COMMA-DELIM-REC
WITH POINTER PTR.
endif
end repeat
That's it more or less. Of course, you could get fancy and take off the leading zeros with an inspect and some reference modification, same for trailing zeros on the decimals, but most applications that would read the file would handle them, so removing them is probably optional.. Betty Scherber
Brainbench MVP for COBOL II