web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

Report needs to print from Card page - print all lines on Qty basis

(6) ShareShare
ReportReport
Posted on by 291
Hello,
I want to print report for all lines on basis of qty. To receive.
Means 2 items in 2 lines.
10 qty. To receive. For each then
Total 20 pages/sticker (10 for each)
& have to run this report from PO card page   -- but I am getting this as blank only, in layout I have used table to group on basis of Outputno and PurchHeader.No , So please suggest me what to do ? I am using action from PO card page to run this report.
 
    ApplicationArea = All;
    Caption = 'Purchase Item Labels';
    UsageCategory = ReportsAndAnalysis;
    DefaultLayout = RDLC;
    RDLCLayout = './ReportLayout/PurchaseLabels.rdl';
 
    dataset
    {
        dataitem(PurchHeader; "Purchase Header")
        {
            column(No; "No.") { }
            dataitem(PurchOrderLine; "Purchase Line")
            {
                DataItemLink = "Document No." = field("No."), "Document Type" = field("Document Type");
                DataItemTableView = sorting("Document Type", "Document No.");
                //RequestFilterFields = "Document No.";
                dataitem(copyloop; "Integer")
                {
                    DataItemTableView = SORTING(Number);
                    dataitem(PageLoop; "Integer")
                    {
                        DataItemTableView = SORTING(Number) WHERE(Number = CONST(1));
                        column(ProductCode; PurchOrderLine."No.") { }
                        column(ItemNo; PurchOrderLine."No.") { }
                        column(purchaseorderNo; PurchOrderLine."ORDER No.") { }
                        column(Description; PurchOrderLine.Description) { }
                        column(Qty; PurchOrderLine."quantity") { }
                        column(Barcode_Text; ItemNoBarCode) { }
                        column(Outputno; OutputNo) { }
                        column(CopyText; CopyText) { }
                        column(Bin_Code; PurchOrderLine."Bin Code") { }
                        column(supplierproductcode; supplierproductcode) { }
                        column(contactNumber; contactNumber) { }
                        column(contactmail; contactmail) { }
                        column(itemdescription; itemdescription) { }
                        column(contactText; contactText) { }
                    }
                    // Trigger: OnAfterGetRecord of PageLoop
                    trigger OnAfterGetRecord()
                    begin
                        if Number > 1 then begin
                            CopyText := FormatDocument.GetCOPYText;
                            OutputNo += 1;
                        end;
                    end;
 
                    trigger OnPreDataItem();
                    begin
                        if LabelstoPrint = 0 then
                            NoOfLoops := ABS(PurchOrderLine."Qty. to receive")
                        else
                            NoOfLoops := ABS(LabelstoPrint);
                        SETRANGE(Number, 1, NoOfLoops);
                        CopyText := '';
                    end;
                }
                //  Trigger: OnAfterGetRecord of CopyLoop
                trigger OnAfterGetRecord()
                var
                    BarcodeString: Text;
                    BarcodeFontProvider2d: Interface "Barcode Font Provider 2D";
                    BarcodeFontProvider: Interface "Barcode Font Provider";
                    PG: PAGE "Posted Purchase Receipt";
                    PG2: PAGE "Posted Purchase Rcpt. Subform";
                begin
                    GetItemData(PurchOrderLine."No.");
                   
                    contactText := contactmail + '     ' + contactNumber;
                    BarcodeFontProvider2d := Enum::"Barcode Font Provider 2D"::IDAutomation2D;
                    BarcodeSymbology2d := Enum::"Barcode Symbology 2d"::"QR-Code";
                    BarcodeString := "No.";
                    BarcodeString := BarcodeString.Replace('?', '');
                    BarcodeString := BarcodeString.Replace('_', '');
                    BarcodeString := BarcodeString.Replace('|', '');
                    //BarcodeFontProvider.ValidateInput(BarcodeString, BarcodeSymbology);
                    ItemNoBarCode := BarcodeFontProvider2d.EncodeFont(BarcodeString, BarcodeSymbology2d);
 
                end;
 
                trigger OnPreDataItem()
                begin
                    // CurrReport.SetTableView(PurchOrderLine);  // ✅ respect filters and marks
                    // PurchOrderLine.MarkedOnly(true);          // ✅ only print marked records
                end;
 
                trigger OnPostDataItem()
                begin
                    // PurchOrderLine.MarkedOnly(false);         // cleanup
                end;
            }
            trigger OnAfterGetRecord()
            var
            begin
 
            end;
        }
    }
    requestpage
    {
        layout
        {
            area(Content)
            {
                group(Options)
                {
                    Caption = 'Qty to Print';
                    field(LabelstoPrint; LabelstoPrint)
                    {
                        ApplicationArea = Basic, Suite;
                        Caption = 'Qty to Print';
                        ToolTip = 'Specifies the number of labels to be printed';
                    }
                }
            }
        }
        actions
        {
            area(Processing)
            {
            }
        }
    }
    var
        BarcodeSymbology: Enum "Barcode Symbology";
        BarcodeSymbology2D: Enum "Barcode Symbology 2D";
        ItemNoBarCode: Text;
        ItemNoQRCode: Text;
        PackingNote: Text;
        //new --------------
        FormatDocument: Codeunit "Format Document";
        NoOfCopies: Integer;
        NoOfLoops: Integer;
        CopyText: Text[30];
        OutputNo: Integer;
        Location: text; //doubt for the field to use
        supplierproductcode: text;
        contactmail: text;
        contactNumber: text;
        contactText: text;
        itemdescription: text;
        LabelstoPrint: Integer;
        tg: record "Purchase Line";
 
        VarQTYTORecv: integer;
 
    trigger OnInitReport()
    begin
        BarcodeSymbology := BarcodeSymbology::Code39;
        BarcodeSymbology2D := BarcodeSymbology2D::"QR-Code";
    end;
 
    Procedure GetItemData(ItemNo: code[20])
    var
        ItemRec: Record Item;
        RecRef: RecordRef;
        NoteText: Text[250];
    begin
        ItemRec.Reset();
        ItemRec.SetRange("No.", ItemNo);
        if ItemRec.FindFirst() then begin
            supplierproductcode := ItemRec."Vendor Item No.";
            itemdescription := ItemRec.Description;
        end;
    end;
 
 
    var
        ProductCode: text;
        Item_No: text;
 
        purchaseorderNo: text;
        description: text;
        qty: Decimal;
        Bin_code: text;
I have the same question (0)
  • Suggested answer
    OussamaSabbouh Profile Picture
    11,297 Super User 2026 Season 1 on at
    Hello,
     
    Simplify your report to use PurchHeader → PurchLine → Integer loop.
    In OnPreDataItem of Integer, set:
     
    SetRange(Number,1,Abs(PurchLine."Qty. to Receive"));
     
    Then run the report from the PO card with:
     
    Report.RunModal(Report::"Purchase Item Labels", true, true, Rec);
     
    This prints one label per Qty. to Receive, no blanks.
     
    Regards,
    Oussama Sabbouh
  • Suggested answer
    YUN ZHU Profile Picture
    98,231 Super User 2026 Season 1 on at
    That's what I was thinking too. Why use Integer?
    You can refer to the standard code.
    report 1322 "Standard Purchase - Order":
     
     
    Thanks.
    ZHU
  • Suggested answer
    CU03020606-0 Profile Picture
    46 on at
    Hello

    Please refer to the below code i have tried it myself.
    I am printing lines on the basis of quantity you can change it to qty to receive.
    I am only printing item no you can take whatever info you need from purch line.
    Add groups and page breaks as per your need.

    Thank you
     
    report 50128 deleteReport
    {
        UsageCategory = ReportsAndAnalysis;
        ApplicationArea = All;
        DefaultRenderingLayout = LayoutName;
     
        dataset
        {
            dataitem("Purchase Header"; "Purchase Header")
            {
                dataitem("Purchase Line"; "Purchase Line")
                {
                    DataItemLink = "Document No." = field("No.");
                    dataitem(Integer; Integer)
                    {
                        column(no; "Purchase Line"."No.")
                        {
     
                        }
                        trigger OnPreDataItem()
                        begin
                            Integer.SetRange(Number, 1, LoopCount);
                        end;
                    }
                    trigger OnAfterGetRecord()
                    begin
                        LoopCount := 0;
                        LoopCount := "Purchase Line".Quantity;
                    end;
                }
            }
        }


     
        rendering
        {
            layout(LayoutName)
            {
                Type = RDLC;
                LayoutFile = 'mySpreadsheet.rdlc';
            }
        }
     
        var
            myInt: Integer;
            LoopCount: Decimal;
    }

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,960 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,084 Super User 2026 Season 1

#3
Dhiren Nagar Profile Picture

Dhiren Nagar 1,047 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans