export sales invoice posted to .txt

kanikakanika 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!!

Comments

  • tinoruijstinoruijs Member Posts: 1,226
    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 specialist
  • kanikakanika Member Posts: 247
    Ohh yes! of course..................... #-o

    thank you very much.
  • tinoruijstinoruijs Member Posts: 1,226
    :-) You're welcome.

    Tino Ruijs
    Microsoft Dynamics NAV specialist
  • kanikakanika Member Posts: 247
    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 again
  • tinoruijstinoruijs Member Posts: 1,226
    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 specialist
  • kanikakanika Member Posts: 247
    not working :(
    the result is the same
  • tinoruijstinoruijs Member Posts: 1,226
    Did you call the function before run?
    Like this;
    ReportForExport.SetInvoiceNo("Sales Invoice Header"."No.");
    ReportForExport.Run;
    

    Tino Ruijs
    Microsoft Dynamics NAV specialist
  • kanikakanika Member Posts: 247
    tinoruijs wrote:
    Did you call the function before run?
    Like this;
    ReportForExport.SetInvoiceNo("Sales Invoice Header"."No.");
    ReportForExport.Run;
    

    No, where?
  • tinoruijstinoruijs Member Posts: 1,226
    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 specialist
  • kanikakanika Member Posts: 247
    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 Run
  • tinoruijstinoruijs Member Posts: 1,226
    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 specialist
Sign In or Register to comment.