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

Urgent Help :need to calculate Item Quantity only once in Purchase invoice line dataitem

(0) ShareShare
ReportReport
Posted on by 238

Hi Experts,

I was trying to calulate quantiy id same item taken twice in line level , or  trice for by using Record Variable RecPurchaseLine1 and Repeat until for that item total quantity will calaculated for   single item single quantity taken no need to use Repeat now problem is Repeated item  in linewasie it will again add value in quantity and makes it double if same item comes trice it will triple total quantity can i calculate quantity only once if  item repeated for next same item iteration it will not calculate value as double or tiple

dataitem("Purchase Header"; "Purchase Header")
            {
                DataItemLink = "Order Date" = field("Period Start");
                DataItemTableView = where("No." = filter(<> 'PO-160019' & <> 'PO-160022' & <> 'PO-160021' & <> 'D/L-180008' & <> 'PO-160098' & <> 'IMPORD-160117' & <> 'T/I-170046'), Status = filter(<> "Pending Approval"));
                RequestFilterFields = "Buy-from Vendor No.";
                
                column(Txt; Txt)
                {
                }
                column(No_PurchaseHeader; "Purchase Header"."No.")
                {
                }
                column(PostingDate_PurchaseHeader; "Purchase Header"."Posting Date")
                {
                }
                column(OrderDate_PurchaseHeader; "Purchase Header"."Order Date")
                {
                }
                column(Location; Loc)
        dataitem("Purch. Inv. Line"; "Purch. Inv. Line")
        {
            DataItemTableView = where("Location Code" = filter(<> ''), Type = filter(Item));
            RequestFilterFields = "Posting Date", "Location Code";

            column(LineAmount_PurchInvLine; "Purch. Inv. Line"."Line Amount")
            {
            }
            column(DocumentNo_PurchInvLine; "Purch. Inv. Line"."Document No.")
            {
            }
            column(No_PurchInvLine; Recitem.Description)
            {
             trigger OnAfterGetRecord();
                Clear(PurchLineQty);
                        RecPurchaseLine1.Reset();
                        RecPurchaseLine1.SetRange(RecPurchaseLine1."Document No.", "Document No.");
                        RecPurchaseLine1.SetRange(RecPurchaseLine1.Type, RecPurchaseLine1.Type::Item);
                        RecPurchaseLine1.SetRange(RecPurchaseLine1."No.", "No.");
                        
                        if RecPurchaseLine1.FindFirst() then
                       
                            repeat
                              
                                PurchLineQty += RecPurchaseLine1.Quantity;
                            until RecPurchaseLine1.next = 0;
I have the same question (0)
  • Suggested answer
    pankaj.k Profile Picture
    994 on at

    Hi Dinesh

    i check you requirement as per your requirement you need to skip your  same item.

    PFA based on screenshot you need to Modify your code and Sort Data Item No. Wise 

    3582.Capture3.PNG

    Step1: Create one variable For storing Last Item No.

    Step2: Sort Data  based on Item No wise.

    Step3. put the IF Condition based on Screenshot 

    Have a great day!

    Don't forget to help the community by verifying the answer if your question has been answered. It will let others know that the topic has verified answer.

    Thanks,

    Contact Info: kuwalpankaj97@gmail.com

  • DineshM Profile Picture
    238 on at

    Hi Pankaj ,

    thanks for Response but i am not able to understand how to sort and why we need variable so i add same code in Rep but not able to getting can you please elaborate

  • Suggested answer
    pankaj.k Profile Picture
    994 on at

    Hi Dinesh,

    you need to use Rec.Setcurrentkey("Item No."); in the Report OnPreDataItem after use the same code that will definitely work.

    if you face issue then mail me your contact detail i will help you on call.

    Have a great day!

    Don't forget to help the community by verifying the answer if your question has been answered. It will let others know that the topic has verified answer.

    Thanks,

    Contact Info: kuwalpankaj97@gmail.com

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,177

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 2,467 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,435 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans