Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Suggested answer

Error while printing

Posted on by 151

Hello All

while trying to Print Purchase Return Order, am getting the Error "The PostPurchCrMemo report does not have a DataItem that uses the table (Table 38 Purchase Header) specified in the function SetTableView."

what will tbe issue. while checking the code its Purchase Header is there

prr.jpg

  • Suggested answer
    Mohana Yadav Profile Picture
    Mohana Yadav 59,139 Super User 2024 Season 2 on at
    RE: Error while printing

    DataItemTableView = SORTING("No.") WHERE("document Type" = FILTER(Invoice));

    You are filtering the report with Document Type Invoice and running for Return Order Type

  • aryaps Profile Picture
    aryaps 151 on at
    RE: Error while printing

    yes, line of items are there. you can see the items in the above screenshot also. can't able to find any error in the above shared code.

  • Suggested answer
    Mohana Yadav Profile Picture
    Mohana Yadav 59,139 Super User 2024 Season 2 on at
    RE: Error while printing

    This error seems to be different and as per the error, there are no documents to print with those filters.

  • aryaps Profile Picture
    aryaps 151 on at
    RE: Error while printing

    2 report option is there..both are not working. its wokring fine previously

    prrr.jpg

    prrrrr.jpg

  • Suggested answer
    Mohana Yadav Profile Picture
    Mohana Yadav 59,139 Super User 2024 Season 2 on at
    RE: Error while printing

    But the report name in the error is different? PostPurchCrMemo

    Did you update the report selections setup to run this new report?

  • aryaps Profile Picture
    aryaps 151 on at
    RE: Error while printing

    yes, it is same only

    report 60009 "Purchase Invoice Test"
    {
        DefaultLayout = RDLC;
        RDLCLayout = './ReportLayouts/PurchInvTest.rdl';
        Caption = 'Purchase Invoice - Test';

        dataset
        {
            dataitem("Purchase Header"; "Purchase Header")
            {
                DataItemTableView = SORTING("No.") WHERE("document Type" = FILTER(Invoice));
                RequestFilterFields = "No.", "Buy-from Vendor No.", "No. Printed";
                RequestFilterHeading = 'Purchase Invoice';
                column(Pay_to_Vendor_No_; "Pay-to Vendor No.")
                {

                }
                column(Pay_to_Name; "Pay-to Name")
                {

                }
                column(Pay_to_Address; "Pay-to Address")
                {

                }
                column(Pay_to_Address_2; "Pay-to Address 2")
                {

                }
                column(Pay_to_City; "Pay-to City")
                {

                }
                column(Pay_to_Post_Code; "Pay-to Post Code")
                {

                }
                column(VAT_Registration_No_; "VAT Registration No.")
                {

                }
                column(PaymentTermsName; PaymentTermsName)
                {

                }
                column(No_; "No.")
                {

                }
                column(Document_Date; "Document Date")
                {

                }
                column(Personname; Personname)
                {

                }
                column(Vendor_Shipment_No_; "Vendor Shipment No.")
                {

                }
                column(Vendor_Invoice_No_; "Vendor Invoice No.")
                {

                }
                column(currencytxt; currencytxt)
                {

                }
                column(CompInfo_TRN; CompInfo."VAT Registration No.")
                {

                }
                column(CompInfo_picture; CompInfo.Picture)
                {

                }
                column(GrandTotalInText; GrandTotalInText)
                {

                }
                column(paymentname; paymentname)
                {

                }
                column(g_txtCommentsArr1; g_txtCommentsArr[1])
                {

                }
                column(g_txtCommentsArr2; g_txtCommentsArr[2])
                {

                }
                column(username; username)
                {

                }

                column(Location_Code; "Location Code")
                {

                }
                column(LocName; LocName)
                {

                }
                column(currencyfactor; currencyfactor)
                {

                }
                column(totalfx; totalfx)
                {

                }
                column(TotalDisc; TotalDisc)
                {

                }
                column(totalvatbaseamt; totalvatbaseamt)
                {

                }
                column(totallcyamt; totallcyamt)
                {

                }
                column(totalvatfive; totalvatfive)
                {

                }
                column(totallcywithvat; totallcywithvat)
                {

                }
                column(ReverseVat; ReverseVat)
                {

                }
                column(TotAmt; TotAmt)
                {

                }

                dataitem("Purchase Line"; "Purchase Line")
                {

                    DataItemLink = "Document No." = FIELD("No.");
                    DataItemLinkReference = "Purchase Header";

                    column(Line_No_; "Line No.")
                    {

                    }
                    column(Type; Type)
                    {

                    }

                    column(Item_No_; "No.")
                    {

                    }
                    column(Description; Description)
                    {

                    }
                    column(Unit_of_Measure_Code; "Unit of Measure Code")
                    {

                    }
                    column(Quantity; Quantity)
                    {

                    }
                    column(Direct_Unit_Cost; "Direct Unit Cost")
                    {

                    }
                    column(Line_Amount; "Line Amount")
                    {

                    }
                    column(VAT_Base_Amount; "VAT Base Amount")
                    {

                    }

                    column(DiscAmt; DiscAmt)
                    {

                    }
                    column(lcyamt; lcyamt)
                    {

                    }
                    column(vatamt; vatamt)
                    {

                    }
                    column(lcyamtwithvat; lcyamtwithvat)
                    {

                    }
                    trigger OnAfterGetRecord()
                    begin
                        Clear(DiscAmt);
                        DiscAmt := "Inv. Discount Amount" + "Line Discount Amount";
                        Clear(lcyamt);
                        Clear(vatamt);
                        Clear(lcyamtwithvat);
                        lcyamt := "VAT Base Amount" * currencyfactor;
                        vatamt := lcyamt * ("VAT %" / 100);
                        lcyamtwithvat := lcyamt + vatamt;
                    end;
                }
                trigger OnAfterGetRecord()
                begin
                    Clear(PaymentTermsName);
                    PaymentTermRec.Reset();
                    PaymentTermRec.SetRange(Code, "Purchase Header"."Payment Terms Code");
                    if PaymentTermRec.FindFirst() then
                        PaymentTermsName := PaymentTermRec.Description;
                    Clear(Personname);
                    SalespersonRec.Reset();
                    SalespersonRec.SetRange(Code, "Purchase Header"."Purchaser Code");
                    if SalespersonRec.FindFirst() then
                        Personname := SalespersonRec.Name;
                    Clear(currencyfactor);
                    Clear(currencytxt);
                    if ("Currency Code" <> 'AED') and ("Currency Code" <> '') then begin
                        currencyfactor := 1 / "Purchase Header"."Currency Factor";
                        currencyfactor := Round(currencyfactor, 0.001, '=');
                        currencytxt := "Purchase Header"."Currency Code";
                    end else begin
                        currencyfactor := 1;
                        currencytxt := "Purchase Header"."Currency Code";
                    end;
                    Clear(LocName);
                    if locrec.Get("Purchase Header"."Location Code") then
                        LocName := locrec.Name;
                    Clear(paymentname);
                    paymentMethodrec.Reset();
                    paymentMethodrec.SetRange(Code, "Purchase Header"."Payment Method Code");
                    if paymentMethodrec.FindFirst() then;
                    paymentname := paymentMethodrec.Description;
                    Clear(totalfx);
                    Clear(TotalDisc);
                    Clear(totalvatbaseamt);
                    Clear(totalvatfive);
                    Clear(totallcyamt);
                    Clear(totallcywithvat);
                    Clear(TotAmt);
                    PurchLine.Reset;
                    PurchLine.SetRange("Document Type", PurchLine."Document Type"::Invoice);
                    PurchLine.SetRange("Document No.", "Purchase Header"."No.");
                    if PurchLine.FindSet then
                        repeat
                            totalfx := totalfx + PurchLine."Line Amount";
                            TotalDisc := TotalDisc + (PurchLine."Inv. Discount Amount" + PurchLine."Line Discount Amount");
                            totalvatbaseamt := totalvatbaseamt + PurchLine."VAT Base Amount";
                            totallcyamt := totallcyamt + (PurchLine."VAT Base Amount" * currencyfactor);
                            //totalvatfive := totalvatfive + totallcyamt * (PurchLine."VAT %" / 100);
                            totalvatfive := totalvatfive + ((PurchLine."VAT Base Amount" * currencyfactor) * (PurchLine."VAT %" / 100));
                        until PurchLine.Next = 0;
                    //totalvatfive := totallcyamt * 0.05;
                    TotAmt := totallcyamt + totalvatfive;
                    Clear(ReverseVat);
                    /*if (PurchLine."VAT Bus. Posting Group" = 'IMPORT') or (PurchLine."VAT Bus. Posting Group" = 'INTERCO') then begin
                        totallcywithvat := totallcyamt;
                        ReverseVat := Round(totalvatfive, 0.01, '=');
                    end
                    else begin
                        ReverseVat := 0.00;
                        totallcywithvat := totallcyamt + totalvatfive;
                    end;*/
                    //
                    PurchLine1.Reset;
                    PurchLine1.SetRange("Document Type", PurchLine."Document Type"::Invoice);
                    PurchLine1.SetRange("Document No.", "Purchase Header"."No.");
                    if PurchLine1.FindSet then
                        repeat
                            if VATPostingSetup.Get(PurchLine1."VAT Bus. Posting Group", PurchLine1."VAT Prod. Posting Group") then begin
                                If VATPostingSetup."VAT Calculation Type" = VATPostingSetup."VAT Calculation Type"::"Reverse Charge VAT" then begin
                                    ReverseVat := ReverseVat + (PurchLine1."VAT Base Amount" * currencyfactor) * (VATPostingSetup."VAT %" / 100);
                                    totalvatfive := totalvatfive + (PurchLine1."VAT Base Amount" * currencyfactor) * (VATPostingSetup."VAT %" / 100);
                                end;
                            end;
                        until PurchLine1.Next = 0;
                    //
                    ReverseVat := -Round(ReverseVat, 0.01, '=');
                    //
                    if ReverseVat = 0 then
                        totallcywithvat := totalvatfive + totallcyamt
                    else
                        totallcywithvat := totallcyamt + totalvatfive + ReverseVat;
                    //
                    Clear(g_txtCommentsArr);
                    PurchCommentLine.Reset();
                    PurchCommentLine.SetRange("No.", "Purchase Header"."No.");
                    PurchCommentLine.SetRange("Document Type", PurchCommentLine."Document Type"::Invoice);
                    PurchCommentLine.SetRange("Document Line No.", 0);
                    if PurchCommentLine.FindFirst() then begin
                        i := 0;
                        repeat
                            i += 1;
                            g_txtCommentsArr[i] := PurchCommentLine.Comment;
                        until (PurchCommentLine.Next = 0) or (i = 2);
                    end;
                    userid.Reset();
                    Clear(username);
                    if userid.Get(SystemCreatedBy) then
                        username := userid."User Name";

                    checkReportData.InitTextVariable();
                    PurchLine.setrange("Document No.", "Purchase Header"."No.");
                    if PurchLine.Findset then
                        totallcywithvat := totallcywithvat;
                    checkReportData.FormatNoText(GrandTotalInTextArr, Round(totallcywithvat, 0.01), 'AED');
                    GrandTotalInText := GrandTotalInTextArr[1];
                end;

            }
        }
        trigger OnInitReport()

        begin
            CompInfo.get();
            CompInfo.CalcFields(Picture);
        end;

        var

            vatamt: Decimal;
            CompInfo: Record "Company Information";
            totalAmtSum: Decimal;
            checkReportData: Report 1401;
            GrandTotalInTextArr: Array[2] of Text[180];
            GrandTotalInText: Text[80];
            TotAmt: Decimal;
            PurchLine: Record "Purchase Line";
            PurchLine1: Record "Purchase Line";
            PurchCommentLine: Record "Purch. Comment Line";
            g_txtCommentsArr: array[2] of text[80];
            i: Integer;
            userid: Record User;
            username: Text;
            DimensionID: Record "Dimension Set Entry";
            DiscAmt: Decimal;
            TotalDisc: Decimal;
            LocName: Text;
            lcyamt: Decimal;
            lcyamtwithvat: Decimal;
            totalfx: Decimal;
            totalvatbaseamt: Decimal;
            totallcyamt: Decimal;
            totalvatfive: Decimal;
            totallcywithvat: Decimal;
            currencyfactor: Decimal;
            currencytxt: Text;
            locrec: Record Location;
            paymentname: Text;
            paymentMethodrec: Record "Payment Method";
            ReverseVat: Decimal;
            Personname: Text;
            SalespersonRec: Record "Salesperson/Purchaser";
            CurrExchRate: Record "Currency Exchange Rate";
            CurrExAmt: Decimal;
            CurrExName: Code[20];
            VenRec: Record Vendor;
            PaymentTermsName: Text[120];
            PaymentTermRec: Record "Payment Terms";
            VATPostingSetup: REcord "VAT Posting Setup";

    }
  • Suggested answer
    Mohana Yadav Profile Picture
    Mohana Yadav 59,139 Super User 2024 Season 2 on at
    RE: Error while printing

    Purchase Header dataitem should be the first data item of the report.

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!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans