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...
Unanswered

Xmlport Lines Reapeating issue

(1) ShareShare
ReportReport
Posted on by 221
Dear all ,
i have created Xmpport For Gl Entries data Extration bsed on posting date filter and Dimensions filter on Request page 
but Repeating lines as GL entries has 10 lines it will Repeating 10 Times in text File but I want Only One Line for GL accounts if Dimesions single value and if Same GL with two different Value then two Lines 
Currently Repeating as lines avialble in GL ie:10 lines in GL it will Reporating 10 Times 
can anyone help ...urgent 
 
Thanks in advance !!!!! Thank you for Help and time 
 
Please Find Following Code For Ref
 
xmlport 50005 ExtractSAPFI
{
    Caption = 'ExtractSAPFI';


 
    Direction = Export;
    Format = VariableText;
    FormatEvaluate = Legacy;
    PreserveWhiteSpace = false;
    UseRequestPage = true;
    FieldDelimiter = '<None>';
    TableSeparator = '<NewLine>';
    FieldSeparator = ' ';
 
    schema
    {
        textelement(RootNodeName)
        {
            tableelement(/GLEntry/; /G/L Entry/)
            {
                SourceTableView = SORTING(/G/L Account No./, /Global Dimension 1 Code/, /Global Dimension 2 Code/, /Posting Date/);
                textelement(StringArray1)
                { }
                textelement(StringArray2)
                { }
                textelement(StringArray3)
                { }
 
                textelement(StringArray4)
                { }
                textelement(StringArray5)
                { }
                textelement(StringArray6)
                { }
                textelement(StringArray7)
                { }
                textelement(StringArray8)
                { }
                textelement(StringArray9)
                { }
                trigger OnPreXmlItem()
                begin
                    clear(amtvar);
                    clear(GLvar);
                    /GLEntry/.SETRANGE(/GLEntry/./Posting Date/, ConsolidStartDate, ConsolidEndDate);
                end;
 
                trigger OnAfterGetRecord()
                var
                    StringArray: array[9] of Text;
                    StringToWrite: Text[1024];
                    i: Integer;
                    GLEntrySum: Record /G/L Entry/;
                begin


 
                    IF (LastDimValue <> GLEntry./Global Dimension 1 Code/) OR (LastGLAccount <> GLEntry./G/L Account No./) THEN BEGIN
 
                        LastDimValue := GLEntry./Global Dimension 1 Code/;
                        LastGLAccount := GLEntry./G/L Account No./;
                        GLEntrySum.RESET;
                        GLEntrySum.SetCurrentKey(/G/L Account No./, /Global Dimension 1 Code/, Amount);
                        GLEntrySum.SETRANGE(/Posting Date/, ConsolidStartDate, ConsolidEndDate);
                        GLEntrySum.SETRANGE(/Global Dimension 1 Code/, GLEntry./Global Dimension 1 Code/);
                        GLEntrySum.SETRANGE(/G/L Account No./, GLEntry./G/L Account No./);
                        GLEntrySum.CALCSUMS(Amount);
 
                        CLEAR(StringArray);
                        StringArray1 := FORMAT(ConsolidationSetup./Company Code for Kohler/, 4);  //Company Code CHAR4
                        StringArray2 := FORMAT(FORMAT(ConsolidEndDate, 0, '<Month,2><Day,2><Year4>'), 8);  //Posting Date CHAR8
                        StringArray3 := FORMAT(LeftPad(FORMAT(AccountingPeriod.Name), 2, '0'));              //Period CHAR2
                        StringArray4 := FORMAT(GLSetup./LCY Code/, 5);                           //Currency CHAR5
                        StringArray5 := PADSTR(GetAccNo(GLEntry, GLEntrySum), 10, ' ');
                        GLvar := StringArray5;        //Account No. CHAR10
                        StringArray6 := FORMAT(GetProfCenter(GLEntry), 10);                    //Profit Center CHAR10
                        StringArray7 := FORMAT('', 4);                                            //Functional Area CHAR4
                        StringArray8 := LeftPad(GetLocalCurrencyAmount(GLEntrySum), 16, ' ');
                        amtvar := StringArray8;   //Amount in local currency CHAR16
                        StringArray9 := LeftPad(GetGroupCurrencyAmount(GLEntrySum), 16, ' ');         //Amount in group currency CHAR16
                        GLvar := StringArray5;
                        amtvar := StringArray8;
                        CLEAR(StringToWrite);
                        FOR i := 1 TO 9 DO BEGIN
 
                            StringToWrite += StringArray[i];
 
                        END;
                        if (StringArray8 = amtvar) and (StringArray5 = GLvar) then
                            currXMLport.Skip();
 
                    END;
                end;



 
            }
        }
    }
    requestpage
    {
        layout
        {
            area(content)
            {
                group(GroupName)
                {
                    field(StartDate; ConsolidStartDate)
                    {
                        Caption = 'Starting Date';
                        ClosingDates = true;
                    }
                    field(EndDate; ConsolidEndDate)
                    {
                        Caption = 'Ending Date';
                        ClosingDates = true;
                    }
                    field(/Profit Centre Dimension/; ProfitDim)
                    {
                        Caption = 'Profit Centre Dimension';
                        TableRelation = Dimension.Code;
                    }
 
                }
            }
        }
        actions
        {
            area(processing)
            {
 
            }
        }
    }
    trigger OnPreXmlPort()
    begin
 
        // /GLEntry/.SETRANGE(/GLEntry/./Posting Date/, ConsolidStartDate, ConsolidEndDate);
 
        IF ProfitDim = '' THEN
            ERROR(ProfitDimError);
 
        IF ConsolidStartDate = 0D THEN
            ERROR(Text001);
 
        IF ConsolidEndDate = 0D THEN
            ERROR(Text002);
        GLSetup.get;
        ConsolidationSetup.GET;
        AccountingPeriod.RESET;
        AccountingPeriod.SETRANGE(/Starting Date/, 0D, ConsolidStartDate);
        AccountingPeriod.FINDLAST;
 
    end;
 
    var
        GLSetup: Record 98;
        ConsolidStartDate: Date;
        ConsolidEndDate: Date;
        ProfitDim: Code[20];
        LastGLAccount: Code[20];
        LastDimValue: Code[20];
        ConsolidationSetup: Record 50006;
        AccountingPeriod: Record 50;
        CurrencyExchangeRate: Record 330;
        CurrencyCode2: array[2] of Code[10];
        Date2: array[2] of Date;
        CurrencyExchRate2: array[2] of Record 330;
        CurrencyExchRate3: array[3] of Record 330;
        amtvar: Text;
        GLvar: Text;
 
        ProfitDimError: Label 'Profit Dimension must be filled in';
        Text001: Label 'Enter the starting date for the consolidation period.';
        Text002: Label 'Enter the ending date for the consolidation period.';


 
    local procedure TruncateString(StrIn: Text; Length: Integer): Text
    begin
        IF STRLEN(StrIn) > Length THEN
            EXIT(COPYSTR(StrIn, 1, Length));
        EXIT(StrIn);
    end;
 
    local procedure GetAccNo(var GLEntry: Record 17; GLEntrySum: Record 17): Code[20]
    var
        GLAcc: Record 15;
    begin
        IF GLAcc.GET(GLEntry./G/L Account No./) THEN BEGIN
            IF GLEntrySum.Amount > 0 THEN BEGIN
                IF GLAcc./Consol. Debit Acc./ <> '' THEN
                    EXIT(GLAcc./Consol. Debit Acc./);
            END ELSE
                IF GLEntrySum.Amount < 0 THEN BEGIN
                    IF GLAcc./Consol. Credit Acc./ <> '' THEN
                        EXIT(GLAcc./Consol. Credit Acc./);
                END;
        END;
        EXIT(GLEntry./G/L Account No./);
    end;
 
    local procedure GetProfCenter(var GLEntry: Record 17): Code[10]
    var
        DimMgt: Codeunit 408;
        TempDimSetEntry: Record 480 temporary;
        Dimension: Record 348;
        DimValue: Record 349;
    begin
        TempDimSetEntry.DELETEALL;
        DimMgt.GetDimensionSet(TempDimSetEntry, GLEntry./Dimension Set ID/);
        TempDimSetEntry.SETRANGE(/Dimension Code/, ProfitDim);
        IF TempDimSetEntry.FINDFIRST THEN BEGIN
            IF DimValue.GET(TempDimSetEntry./Dimension Code/, TempDimSetEntry./Dimension Value Code/) THEN BEGIN
                IF DimValue./Consolidation Code/ <> '' THEN
                    EXIT(TruncateString(DimValue./Consolidation Code/, 10));
                EXIT(TruncateString(DimValue.Code, 10));
            END;
        END;
    end;
 
    local procedure GetLocalCurrencyAmount(var GLEntry: Record 17): Text
    begin
        EXIT(DELCHR(FORMAT(ROUND(GLEntry.Amount, 0.01, '='), 0, '<Sign><Integer Thousand><Decimals,3>'), '=', ','));
    end;
 
    local procedure GetGroupCurrencyAmount(var GLEntry: Record 17): Text
    var
        CurrencyExchange: Record 330;
    begin
        EXIT(DELCHR(FORMAT(ROUND(ExchangeAmtLCYToFCY(ConsolidEndDate, ConsolidationSetup./Kohler Currency Code/, GLEntry.Amount, 0), 0.01, '='), 0, '<Sign><Integer Thousand><Decimals,3>'), '=', ','));
    end;
 
    local procedure LeftPad(StrIn: Text; Length: Integer; Character: Text) StrOut: Text
    var
        LoopInt: Integer;
        i: Integer;
    begin
        IF STRLEN(StrIn) > Length THEN
            EXIT(COPYSTR(StrIn, 1, Length));
 
        LoopInt := Length - STRLEN(StrIn);
 
        FOR i := 1 TO LoopInt DO BEGIN
            StrIn := Character + StrIn;
        END;
 
        EXIT(StrIn);
    end;
 
    procedure ExchangeAmtLCYToFCY(Date: Date; CurrencyCode: Code[10]; Amount: Decimal; Factor: Decimal): Decimal
    begin
        FindCurrency(Date, CurrencyCode, 1);
        WITH CurrencyExchangeRate DO BEGIN
            IF CurrencyCode = '' THEN
                EXIT(Amount);
 
            TESTFIELD(/Exchange Rate Amount/);
            TESTFIELD(/Relational Exch. Rate Amount/);
            IF /Relational Currency Code/ = '' THEN
                Amount := (Amount / /Relational Exch. Rate Amount/) * /Exchange Rate Amount/;
            EXIT(Amount);
        END;
    end;
 
    procedure FindCurrency(Date: Date; CurrencyCode: Code[10]; CacheNo: Integer)
    begin
        WITH CurrencyExchangeRate DO BEGIN
            IF (CurrencyCode2[CacheNo] = CurrencyCode) AND (Date2[CacheNo] = Date) THEN
                CurrencyExchangeRate := CurrencyExchRate2[CacheNo]
            ELSE BEGIN
                IF Date = 0D THEN
                    Date := WORKDATE;
                CurrencyExchRate2[CacheNo].SETRANGE(/Currency Code/, CurrencyCode);
                CurrencyExchRate2[CacheNo].SETRANGE(/Starting Date/, 0D, Date);
                CurrencyExchRate2[CacheNo].FINDLAST;
                CurrencyExchangeRate := CurrencyExchRate2[CacheNo];
                CurrencyCode2[CacheNo] := CurrencyCode;
                Date2[CacheNo] := Date;
            END;
        END;
    end;
}

 
  • DineshM Profile Picture
    DineshM 221 on at
    Xmlport Lines Reapeating issue
    Any Help ....from anyone
  • DineshM Profile Picture
    DineshM 221 on at
    Xmlport Lines Reapeating issue
    Output with Reapeating Lines as Follows

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,494 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,305 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans