web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

Export XMLPort txt file from data of several companies

(0) ShareShare
ReportReport
Posted on by

Hello, I'm trying Export XMLPort txt file from data of several companies and it works but I need that between companies

when  XMLItem pass to the next company don't let blank spaces between rows in the text file exported.

This is the code

textelement(Root)
        {
            tableelement(Companys; Company)
            {                
                tableelement(CustLE; "Cust. Ledger Entry")
                {
                    SourceTableView = SORTING("Customer No.", Open, Positive, "Due Date", "Currency Code");
                    CalcFields = "Original Amt. (LCY)", "Remaining Amt. (LCY)", "Amount (LCY)";
                    RequestFilterFields = "Customer No.", "Posting Date", "Document No.", "Doc. Status";

                    fieldelement(PostingDate; CustLE."Posting Date") { }
                    fieldelement(DocumentType; CustLE."Document Type") { }
                    fieldelement(DocumentNo; CustLE."Document No.") { }
                    fieldelement(BillNo; CustLE."Bill No.") { }
                    fieldelement(DocumentSituation; CustLE."Document Situation") { }
                    fieldelement(DocumentStatus; CustLE."Document Status") { }
                    fieldelement(CustomerNo; CustLE."Customer No.") { }
                    textelement(RazonSocial) { }
                    textelement(Bloqueado) { }
                    fieldelement(Description; CustLE."Description") { }
                    fieldelement(Delegacioncobro; CustLE."Delegacion cobro") { }
                    fieldelement(CurrencyCode; CustLE."Currency Code") { }
                    fieldelement(OriginalAmtLCY; CustLE."Original Amt. (LCY)") { }
                    fieldelement(AmountLCY; CustLE."Amount (LCY)") { }
                    fieldelement(RemainingAmtLCY; CustLE."Remaining Amt. (LCY)") { }
                    fieldelement(DueDate; CustLE."Due Date") { }
                    fieldelement(OnHold; CustLE."On Hold") { }
                    fieldelement(Reversed; CustLE."Reversed") { }
                    fieldelement(EntryNo; CustLE."Entry No.") { }
                    textelement(FormaDePago) { }
                    fieldelement(ClosedatDate; CustLE."Closed at Date") { }
                    fieldelement(Open; CustLE."Open") { }
                    textelement(PrimerPlazoPago) { }
                    fieldelement(AvisoFaltaPago; CustLE."Aviso Falta Pago") { }
                    fieldelement(CreditoyCaución; CustLE."Crédito y Caución") { }
                    textelement(CuentaVentas) { }
                    fieldelement(SubCliente; CustLE."SubCliente") { }
                    //fieldelement(Dotado; custle."Doc. Status") { }
                    //FDG-28/12/21-Inicio
                    textelement(Company_Name) { }
                    //FDG-28/12/21-Fin

                    trigger OnPreXmlItem()
                    /*var
                        CompanyCarreras: Record "Company Carreras";*/
                    begin
                        //FDG-28/12/21-Inicio
                        /*if NOT CompanyCarreras.Get(Companys.Name) then
                            currXMLport.Skip();*/

                        //CustLE.ChangeCompany(Companys.Name);
                        Company_Name := Companys.Name;
                        //FDG-28/12/21-Fin

                        IF optEstado = optEstado::Pendientes THEN
                            CustLE.SETRANGE(Open, TRUE);
                        IF optEstado = optEstado::Cerrados THEN
                            CustLE.SETRANGE(Open, FALSE);
                    end;


                    trigger OnAfterGetRecord()
                    var
                        GLEntry: Record "G/L Entry";
                        pCliente: Record Customer;
                        pTerminos: Record "Payment Terms";
                        pFacturas: Record "Sales Invoice Header";
                        pAbonos: Record "Sales Cr.Memo Header";
                        pCartera: Record "Cartera Doc.";
                        pCarteraPosted: Record "Posted Cartera Doc.";
                        pCarteraClosed: Record "Closed Cartera Doc.";
                    begin
                        FormaDePago := '';
                        RazonSocial := '';
                        Bloqueado := '';
                        PrimerPlazoPago := '0';

                        pCliente.RESET;
                        IF pCliente.GET(CustLE."Customer No.") THEN BEGIN
                            RazonSocial := pCliente.Name;
                            Bloqueado := FORMAT(pCliente.Blocked);
                            IF pCliente."Payment Terms Code" <> '' THEN BEGIN
                                pTerminos.RESET;
                                pTerminos.SETRANGE(pTerminos.Code, pCliente."Payment Terms Code");
                                IF pTerminos.FINDFIRST THEN BEGIN
                                    IF FORMAT(pTerminos."Due Date Calculation") <> '' THEN BEGIN
                                        //CONASA - 26-01-10
                                        PrimerPlazoPago := FORMAT(pTerminos."Due Date Calculation");
                                        IF COPYSTR(PrimerPlazoPago, STRLEN(PrimerPlazoPago), 1) = 'D' THEN
                                            PrimerPlazoPago := COPYSTR(PrimerPlazoPago, 1, STRLEN(PrimerPlazoPago) - 1);

                                        IF COPYSTR(PrimerPlazoPago, STRLEN(PrimerPlazoPago), 1) = 'M' THEN BEGIN
                                            EVALUATE(PrimerPlazo, COPYSTR(PrimerPlazoPago, 1, STRLEN(PrimerPlazoPago) - 1));
                                            PrimerPlazo := PrimerPlazo * 30;
                                            PrimerPlazoPago := FORMAT(PrimerPlazo);
                                        END;
                                    END;
                                END;
                            END;
                        END;

                        CASE CustLE."Document Type" OF
                            CustLE."Document Type"::Invoice:
                                IF pFacturas.GET(CustLE."Document No.") THEN
                                    FormaDePago := pFacturas."Payment Method Code";
                            CustLE."Document Type"::"Credit Memo":
                                IF pAbonos.GET(CustLE."Document No.") THEN
                                    FormaDePago := pAbonos."Payment Method Code";
                            CustLE."Document Type"::Bill:
                                BEGIN
                                    pCartera.RESET;
                                    pCartera.SETRANGE(Type, pCartera.Type::Receivable);
                                    pCartera.SETRANGE("Entry No.", CustLE."Entry No.");
                                    IF pCartera.FINDFIRST THEN
                                        FormaDePago := pCartera."Payment Method Code"
                                    ELSE BEGIN
                                        pCarteraPosted.RESET;
                                        pCarteraPosted.SETRANGE(Type, pCarteraPosted.Type::Receivable);
                                        pCarteraPosted.SETRANGE("Entry No.", CustLE."Entry No.");
                                        IF pCarteraPosted.FINDFIRST THEN
                                            FormaDePago := pCarteraPosted."Payment Method Code"
                                        ELSE BEGIN
                                            pCarteraClosed.RESET;
                                            pCarteraClosed.SETRANGE(Type, pCarteraClosed.Type::Receivable);
                                            pCarteraClosed.SETRANGE("Entry No.", CustLE."Entry No.");
                                            IF pCarteraClosed.FINDFIRST THEN FormaDePago := pCarteraClosed."Payment Method Code";
                                        END;
                                    END;
                                END;
                        END;

                        //CONASA - Añadir la cuenta de ventas del movimiento (si tiene)
                        CuentaVentas := '';
                        GLEntry.RESET;
                        GLEntry.SETCURRENTKEY("Document No.", "Posting Date");
                        GLEntry.SETRANGE("Document No.", CustLE."Document No.");
                        GLEntry.SETRANGE("Posting Date", CustLE."Posting Date");
                        GLEntry.SETFILTER("G/L Account No.", '7*');
                        IF GLEntry.FINDFIRST THEN CuentaVentas := GLEntry."G/L Account No.";
                    end;

                }

                //FDG-28/12/21-Inicio
                trigger OnAfterGetRecord()
                begin
                    Clear(CompanyCarreras);
                    if NOT CompanyCarreras.Get(Companys.Name) then
                        currXMLport.Skip();

                    CustLE.ChangeCompany(Companys.Name);
                end;
                //FDG-28/12/21-Fin 
            }
        }

Do you know any property can help me. Thanks

I have the same question (0)
  • Suggested answer
    JAngle Profile Picture
    133 on at

    An alternative approach could be to have a codeunit fill in a temporary set of tables which is then populated with all the data from each company. The xmlport then exports solely from the purpose built tables with all the data already present.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 3,143

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 1,694 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,067 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans