Skip to main content

Notifications

Announcements

No record found.

Business Central forum
Suggested answer

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

Posted on by 221

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;
  • Suggested answer
    pankaj.k Profile Picture
    pankaj.k 962 on at
    RE: Urgent Help :need to calculate Item Quantity only once in Purchase invoice line dataitem

    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

  • DineshM Profile Picture
    DineshM 221 on at
    RE: Urgent Help :need to calculate Item Quantity only once in Purchase invoice line dataitem

    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
    pankaj.k 962 on at
    RE: Urgent Help :need to calculate Item Quantity only once in Purchase invoice line dataitem

    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

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

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

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

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,564 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,651 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans