procedure WritetoExcel(vExportSageT: Record "TExport Sage")
var
TempBlob: Codeunit "Temp Blob";
OutStream: OutStream;
InStream: InStream;
FileName: Text;
Line: Text;
FileMgmt: Codeunit "File Management";
RecZenSetup: Record "ZEN Setup";
RecGenLedgSetup: Record "General Ledger Setup";
CRLF: Text[2];
AmountText: Text;
begin
if RecZenSetup.Get() then;
if RecGenLedgSetup.Get() then;
FileName := 'Interface Sage X3.txt';
CRLF[1] := 13;
CRLF[2] := 10;
TempBlob.CreateOutStream(OutStream);
if vExportSageT.FindSet() then
repeat
AmountText := Format(vExportSageT.Amount);
AmountText := AmountText.Replace(' ', '');
Message('%1', Format(vExportSageT.Amount));
//AmountText := DelChr(AmountText, ' ', ',');
Line := vExportSageT.Ref + ';' + vExportSageT."Ticket No" + ';' + vExportSageT."Store No" + ';'
+ vExportSageT.Type + ';' + RecZenSetup."Client Code" + ';' + RecGenLedgSetup."LCY Code" + ';'
+ Format(RecZenSetup."Timbre Fiscal") + ';' + Format(vExportSageT.Amount) + ';' + Format(vExportSageT.Date) + ';'
+ vExportSageT."Item Code" + ';' + RecZenSetup.UV + ';' + '1;' + RecZenSetup.NTaxe + ';' + Format(vExportSageT.Amount) + ';' + vExportSageT."Payment Method";
OutStream.WriteText(Line + CRLF);
until vExportSageT.Next() = 0;
TempBlob.CreateInStream(InStream);
FileName := 'ExportedData.txt';
DownloadFromStream(InStream, '', '', '', FileName);
end;