How Do I Export Data into a CSV File? (Magic xpa 2.x)
You can use the DataViewToText() function to export data from your program into a CSV file. All you need to do is use a comma for the delimiter, and double-quotes for the string identifier, as shown below.

For details on using DataViewToText(), see How Do I Export Data into a Text File?.
The Online and Rich Client Samples projects (program RP02 and RRP02)