SaveasFormattedText will add the separator character after the last column.
If this is the main issue you want to avoid you may test saveas like that:
<your datawindow>.saveas("<your filename>", CSV!, true, EncodingUTF8!)
This will have a similar output with:
<your datawindow>.saveasFormattedText("<your filename>", EncodingUTF8!, ",", "")
But saveas will show data values and not display values. So if your datawindow includes dropdowndatawindows or composite columns etc. and you want to save the displayed data you may need to modify your sql.
There is also another difference: saveasFormattedText will show header as it's displayed while saveas places column names as header columns.
Saveas allows you to provide an empty string for filename. In that case the user will be able to choose the filename and location where to save file.
Conclusion:
If you want to correct result of saveasFormattedText I think you will have to programmatically handle it. You may also open a support case for an enhancement in saveasFormattedText to make the separator character optional at the end of the line. But for enhancements there is no guarantee they will be implemented and in what time frame.
Andreas.