Skip to main content

Notifications

Microsoft Dynamics NAV (Archived)

Can't retrieve all the values in a matrix report.

Posted on by Microsoft Employee

  Hello,

              I have been asked to create a matrix report with 'Description' & 'Quantity' fields. Those fields are existed & fetch data from two different tables named 'Item Journal Line' & 'Item Ledger Entry'.

              For that I have declared two record variables(RecIJL, RecILE) & 'Description' & 'Quantity' variable . I have declared only one DataItem i.e. Production Entry Header. Then I took all required fields along with 'Description' & 'Quantity' variable.

              Now I want when a user selects a 'Document No.' the report will shows all Description values as column header caption along with quantity as their body. But my code doesn't retrieve all the values except only the last one. I have written the following code:

Production Entry Header  -   OnAfterGetRecord()

RecIJL.RESET;

RecIJL.SETRANGE(RecIJL."Document No.","Production Entry Header"."Document No.");

RecIJL.SETFILTER(RecIJL."Item Type", '%1' ,RecIJL."Item Type"::Scrap);

CLEAR(Description);

Quantity:=0;

IF RecIJL.FINDFIRST THEN BEGIN REPEAT

Description:=RecIJL.Description;

Quantity:=RecIJL.Quantity;

UNTIL  RecIJL.NEXT=0;

END Else

RecILE.RESET;

RecILE.SETRANGE(RecILE."Document No.","Production Entry Header"."Document No.");

RecILE.SETRANGE(RecILE."Item Type", RecILe."Item Type"::Scrap);

IF RecILE.FINDFIRST THEN BEGIN REPEAT

Description:=RecILE.Description;

Quantity:=RecILE.Quantity;

UNTIL  RecIJL.NEXT=0;

END;

                                    Can anyone help me?? Thanking You,

*This post is locked for comments

  • RE: Can't retrieve all the values in a matrix report.

    Hi Rajat,

    Can you move these lines on top before RecIJL.RESET; and check?

    CLEAR(Description);

    Quantity:=0;

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Can't retrieve all the values in a matrix report.

    Thank You fr the reply Sir..but still it doesn't work..I can only get the last record..!

  • Suggested answer
    RE: Can't retrieve all the values in a matrix report.

    Hi,

    In your ELSE code, after UNTIL you have coded as RecIJL.NEXT=0;, but it seems to be, you have to use RecILE.NEXT = 0;.

    Please recheck the code.

    Rectified code:

    RecIJL.RESET;

    RecIJL.SETRANGE(RecIJL."Document No.","Production Entry Header"."Document No.");

    RecIJL.SETFILTER(RecIJL."Item Type", '%1' ,RecIJL."Item Type"::Scrap);

    CLEAR(Description);

    Quantity:=0;

    IF RecIJL.FINDFIRST THEN

    BEGIN

       REPEAT

           Description:=RecIJL.Description;

           Quantity:=RecIJL.Quantity;

       UNTIL  RecIJL.NEXT=0;

    END ELSE

       RecILE.RESET;

       RecILE.SETRANGE(RecILE."Document No.","Production Entry Header"."Document No.");

       RecILE.SETRANGE(RecILE."Item Type", RecILe."Item Type"::Scrap);

       IF RecILE.FINDFIRST THEN

       BEGIN

           REPEAT

               Description:=RecILE.Description;

               Quantity:=RecILE.Quantity;

           UNTIL RecILE.NEXT=0;

    END;

    Hope it helps.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans