export sales invoice posted to .txt

kanika
Member Posts: 247
Hi experts!!
I'm trying to export an sales invoice posted to .txt and I have no problems with any field except with the value of "Amount" and "Amount Including VAT", both return me 0 but in the table (112) there are other value
I don't understand why I can't export the values if the report has the dataitem "Sales Invoice Header" and into this dataitem exists the fields with values <>0
this is my code:
report_50016_factura_electronica
OnPreReport=BEGIN
OutFile.TEXTMODE := TRUE;
OutFile.WRITEMODE := TRUE;
OutFile.CREATE(ExternalFile);
END;
}
DATAITEMS
{
{ PROPERTIES
{
DataItemTable=Table112;
NewPagePerRecord=Yes;
OnAfterGetRecord=BEGIN
company.RESET;
company.GET;
OutText := '33' +"Sales Invoice Header"."No.";
OutFile.WRITE(OutText);
{OutText := 'A:Tipo|33';
OutFile.WRITE(OutText);}
OutText := 'A:Folio Documento|'+FORMAT("Sales Invoice
Header"."No.");
OutFile.WRITE(OutText);
OutText := 'A:Fecha emision|'+FORMAT("Sales Invoice
Header"."Posting Date");
OutFile.WRITE(OutText);
OutText := 'A:Terminos del pago|'+FORMAT("Sales
Invoice Header"."Payment Terms Code");
OutFile.WRITE(OutText);
OutText := 'A:Fecha de vencimiento|'+FORMAT("Sales
Invoice Header"."Due Date");
OutFile.WRITE(OutText);
OutText:= 'A:Direcci¢n Origen|'+CompanyInfo.Address;
OutFile.WRITE(OutText);
OutText:= 'A:Comuna Origen|'+CompanyInfo.City;
OutFile.WRITE(OutText);
.
.
.
.
OutText := 'A:Monto neto|' +FORMAT("Sales Invoice
Header".Amount);
OutFile.WRITE(OutText);
OutText := 'A:Total|' +FORMAT("Sales Invoice
Header"."Amount Including VAT");
OutFile.WRITE(OutText);
END;
.
.
.
.
this is the result:
A:Folio Documento|103002
A:Fecha emisi¢n|02/12/14
A:Terminos del pago|CONTADO
A:Fecha de vencimiento|02/12/14
A:Dirección Origen|La Estera 668, Loteo Valle Grande
A:Comuna Origen|LAMPA
A:RUT receptor|03680941-8
A:Razón social receptor|MARLON MOLINA CARRASCO
A:Giro receptor|ARTICULOS ELECTRICOS
A:Dirección receptor|SAN DIEGO # 1128
A:Comuna receptor|SANTIAGO
A:Monto neto|0
A:Total|0
and these are the data in the table:
No. Bill-to Name Amount Amount Including VAT
103002 MARLON MOLINA CARRASCO 8.000 9.520
thanks!!
I'm trying to export an sales invoice posted to .txt and I have no problems with any field except with the value of "Amount" and "Amount Including VAT", both return me 0 but in the table (112) there are other value
I don't understand why I can't export the values if the report has the dataitem "Sales Invoice Header" and into this dataitem exists the fields with values <>0
this is my code:
report_50016_factura_electronica
OnPreReport=BEGIN
OutFile.TEXTMODE := TRUE;
OutFile.WRITEMODE := TRUE;
OutFile.CREATE(ExternalFile);
END;
}
DATAITEMS
{
{ PROPERTIES
{
DataItemTable=Table112;
NewPagePerRecord=Yes;
OnAfterGetRecord=BEGIN
company.RESET;
company.GET;
OutText := '33' +"Sales Invoice Header"."No.";
OutFile.WRITE(OutText);
{OutText := 'A:Tipo|33';
OutFile.WRITE(OutText);}
OutText := 'A:Folio Documento|'+FORMAT("Sales Invoice
Header"."No.");
OutFile.WRITE(OutText);
OutText := 'A:Fecha emision|'+FORMAT("Sales Invoice
Header"."Posting Date");
OutFile.WRITE(OutText);
OutText := 'A:Terminos del pago|'+FORMAT("Sales
Invoice Header"."Payment Terms Code");
OutFile.WRITE(OutText);
OutText := 'A:Fecha de vencimiento|'+FORMAT("Sales
Invoice Header"."Due Date");
OutFile.WRITE(OutText);
OutText:= 'A:Direcci¢n Origen|'+CompanyInfo.Address;
OutFile.WRITE(OutText);
OutText:= 'A:Comuna Origen|'+CompanyInfo.City;
OutFile.WRITE(OutText);
.
.
.
.
OutText := 'A:Monto neto|' +FORMAT("Sales Invoice
Header".Amount);
OutFile.WRITE(OutText);
OutText := 'A:Total|' +FORMAT("Sales Invoice
Header"."Amount Including VAT");
OutFile.WRITE(OutText);
END;
.
.
.
.
this is the result:
A:Folio Documento|103002
A:Fecha emisi¢n|02/12/14
A:Terminos del pago|CONTADO
A:Fecha de vencimiento|02/12/14
A:Dirección Origen|La Estera 668, Loteo Valle Grande
A:Comuna Origen|LAMPA
A:RUT receptor|03680941-8
A:Razón social receptor|MARLON MOLINA CARRASCO
A:Giro receptor|ARTICULOS ELECTRICOS
A:Dirección receptor|SAN DIEGO # 1128
A:Comuna receptor|SANTIAGO
A:Monto neto|0
A:Total|0
and these are the data in the table:
No. Bill-to Name Amount Amount Including VAT
103002 MARLON MOLINA CARRASCO 8.000 9.520
thanks!!
0
Comments
-
Those are flowfields. You will have to use "Sales Invoice Header".CALCFIELDS(Amount, "Amount incl. VAT"); before using the values.
Tino Ruijs
Microsoft Dynamics NAV specialist0 -
Ohh yes! of course..................... #-o
thank you very much.0 -
:-) You're welcome.
Tino Ruijs
Microsoft Dynamics NAV specialist0 -
Continuing with the same theme ....
I would like to export the file with the invoice number like name, but does not work me
Report - OnPreReport()
OutFile.CREATE(ExternalFile);
Request form - Oninit()
IF ExternalFile = '' THEN
ExternalFile := 'C:\E-invoice\'+FORMAT(STRSUBSTNO(Text011,"Sales Invoice Header"."No."));
C/AL globals:
Name ConstValue
Text011 INVOICE No %1 .txt
but the result is: C:\E-invoice\INVOICE No .txt
and I need: C:\E-invoice\INVOICE No103110.txt
Can you help me?
thanks again0 -
At OnInit request form "Sales Invoice Header"."No." is not yet retrieved from the database.
When calling the export report, you must first call a function you create on the report called SetInvoiceNo with parameter InvoiceNo.
Create a global InvNo in the report which gets assigned in SetInvoiceNo.InvNo := InvoiceNo;
And then in OnInit request form you can use InvNo.
Tino Ruijs
Microsoft Dynamics NAV specialist0 -
not working
the result is the same0 -
Did you call the function before run?
Like this;ReportForExport.SetInvoiceNo("Sales Invoice Header"."No."); ReportForExport.Run;
Tino Ruijs
Microsoft Dynamics NAV specialist0 -
How do you call the report for export? From a page? When it's from a page, you'll have to set the invoice no. from there using the newly created function.
Tino Ruijs
Microsoft Dynamics NAV specialist0 -
in a requeset form, don't you remember?
Request form - Oninit()
IF ExternalFile = '' THEN
ExternalFile := 'C:\E-invoice\'+FORMAT(STRSUBSTNO(Text011,"Sales Invoice Header"."No."));
then it would ExternalFile.Run?
but ExternalFile is not a record, is invalid for Run0 -
I remember.
You will need to call the report from a page/form or codeunit. Otherwise you won't be able to set the invoice no.
Tino Ruijs
Microsoft Dynamics NAV specialist1
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions