Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class dxcFileExporter
- {
- commaStreamIo iO;
- custInvoiceTrans custInvoiceTrans;
- Filename filename;
- int limit = 50;
- public static void main(Args args)
- {
- dxcFileExporter dxcFileExporter = new dxcFileExporter();
- dxcFileExporter.run();
- }
- void new()
- {
- iO = commaStreamIo::constructForWrite();
- filename = "CustInvoiceExport.csv";
- }
- void run()
- {
- if (Box::yesNo("Do you wish to extract Customer Invoice info to a CSV file?",DialogButton::Yes))
- {
- container header = ["Invoice number",
- "Invoice Date",
- "Item Id",
- "Price",
- "Qty",
- "Line Amount"];
- iO.writeExp(header);
- header = conNull();
- while select custInvoiceTrans
- order by InvoiceId,LineNum
- {
- container line = [custInvoiceTrans.InvoiceId,
- custInvoiceTrans.InvoiceDate,
- custInvoiceTrans.ItemId,
- custInvoiceTrans.SalesPrice,
- custInvoiceTrans.Qty,
- custInvoiceTrans.LineAmount];
- iO.writeExp(line);
- limit--;
- if (!limit) break;
- }
- System.IO.Stream stream = iO.getStream();
- stream.Position = 0;
- System.IO.StreamReader reader = new System.IO.StreamReader(stream);
- str csvFileContent = reader.ReadToEnd();
- File::SendStringAsFileToUser(csvFileContent, filename);
- Info(strFmt("invoice Records CSV file %1 Sent to user",filename ));
- }
- }
- }
Add Comment
Please, Sign In to add comment