Q:

How to write data to CSV file in ABL coding

I populated a temp from a query, and the temp table looks like, 
ttcomp.inum
ttcomp.iname
ttcomp.iadd

There are 5000 records in this temp table and now i wanted to write in a CSV file. I think it could be done with output stream but i don't know how to implement this. Please someone help me in getting this. 

A:

Export does the trick:
/* Define a stream */
DEFINE STREAM str.

/* Define the temp-table. I did some guessing according datatypes... */
DEFINE TEMP-TABLE ttcomp
    FIELD inum  AS INTEGER
    FIELD iname AS CHARACTER
    FIELD iadd  AS INTEGER.

/* Fake logic that populates your temp-table is here */
DEFINE VARIABLE i AS INTEGER     NO-UNDO.
DO i = 1 TO 5000:
    CREATE ttComp.
    ASSIGN 
        ttComp.inum  = i
        ttComp.iname = "ABC123"
        ttComp.iadd  = 3.

END.
/* Fake logic done... */

/* Output the temp-table */
OUTPUT STREAM str TO VALUE("c:\temp\file.csv").
FOR EACH ttComp NO-LOCK:
    /* Delimiter can be set to anything you like, comma, semi-colon etc */
    EXPORT STREAM str DELIMITER "," ttComp.
END.
OUTPUT STREAM str CLOSE.
/* Done */

