Guest User

Untitled

a guest
Dec 16th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. class dxcFileExporter
  2. {
  3. commaStreamIo iO;
  4. custInvoiceTrans custInvoiceTrans;
  5. Filename filename;
  6. int limit = 50;
  7.  
  8. public static void main(Args args)
  9. {
  10. dxcFileExporter dxcFileExporter = new dxcFileExporter();
  11. dxcFileExporter.run();
  12. }
  13.  
  14. void new()
  15. {
  16. iO = commaStreamIo::constructForWrite();
  17. filename = "CustInvoiceExport.csv";
  18. }
  19.  
  20. void run()
  21. {
  22. if (Box::yesNo("Do you wish to extract Customer Invoice info to a CSV file?",DialogButton::Yes))
  23. {
  24. container header = ["Invoice number",
  25. "Invoice Date",
  26. "Item Id",
  27. "Price",
  28. "Qty",
  29. "Line Amount"];
  30. iO.writeExp(header);
  31. header = conNull();
  32. while select custInvoiceTrans
  33. order by InvoiceId,LineNum
  34. {
  35. container line = [custInvoiceTrans.InvoiceId,
  36. custInvoiceTrans.InvoiceDate,
  37. custInvoiceTrans.ItemId,
  38. custInvoiceTrans.SalesPrice,
  39. custInvoiceTrans.Qty,
  40. custInvoiceTrans.LineAmount];
  41. iO.writeExp(line);
  42. limit--;
  43. if (!limit) break;
  44. }
  45. System.IO.Stream stream = iO.getStream();
  46. stream.Position = 0;
  47. System.IO.StreamReader reader = new System.IO.StreamReader(stream);
  48. str csvFileContent = reader.ReadToEnd();
  49. File::SendStringAsFileToUser(csvFileContent, filename);
  50. Info(strFmt("invoice Records CSV file %1 Sent to user",filename ));
  51. }
  52. }
  53.  
  54. }
Add Comment
Please, Sign In to add comment