Hi Expert
I would like to know if it possible to generate multiple files in BC Cloud using XML port called from either Report or codeunit.
The goal is to export sales invoice header information into CSV file, one file for each day.
In the previous version I can do this by creating an XML port to handle the export and code unit/Report to call supply the daily data to the XML Port
The code unit
datefilter: Record Date;
FileInstream: InStream;
TempBlob: Record TempBlob;
FileName: Text;
MyOutStream: OutStream;
MyInStream: InStream;
outputFileName: Text;
MyXMLPort: XmlPort "My Export";
datefilter.SetRange("Period Type", datefilter."Period Type"::Date);
datefilter.SetRange("Period Start", 20190501D, 20190509D);
IF datefilter.FindSet then
REPEAT
TempBlob.Blob.CreateOutStream(MyOutStream);
CLEAR(XMLPort);
MyXMLPort.SetFilter(datefilter."Period Start"); //SETFilterinXML Port
MyXMLPort.SetDestination(MyOutStream);
MyXMLPort.Run();
TempBlob.Blob.CreateInStream(MyInStream);
outputFileName := 'FileName' + '-' + FORMAT(dateFilter."Period Start", 0, '<Month,2><Day,2><Year4>') + '.txt';
DownloadFromStream(MyInStream, '', '', '', outputFileName);
UNTIL datefilter.Next = 0;
end;
When I run this in BC Cloud, I am only getting the file for the last date in my date range which is 20190509D