How to Print Multiple Copies in Report in AL of Microsoft Dynamics 365 Business Central

 

How to Print Multiple Copies in Report in AL of Microsoft Dynamics 365 Business Central (MSDYN365BC)?

There are two parts in report

  1. AL Code
  2. RDL Layout (Similar to NAV).

AL Code

I have pasted the AL code for the Item List report.

 report 50129 ItemListReport
{
    UsageCategory = ReportsAndAnalysis;
    ApplicationArea = All;
    CaptionML = ENU = 'AL Item List ';
    DefaultLayout = RDLC;
    RDLCLayout = './ItemListReport.rdl';
    dataset
    {
        dataitem(Item; Item)
        {
            dataitem(CopyLoop; "Integer")
            {
                DataItemTableView = SORTING(Number);
                dataitem(PageLoop; "Integer")
                {
                    DataItemTableView = SORTING(Number) WHERE(Number = CONST(1));
                    column(ItemNo; Item."No."){}
                    column(ItemName; Item.Description){ }
                    column(ItemUOM; Item."Base Unit of Measure"){ }
                    Column(ItemCost; Item."Unit Cost"){ }
                    column(ItemPrice; Item."Unit Price"){ }
                    column(ShowUnitCost; ShowUnitCost){ }
                    column(Outputno; OutputNo){}
                    column(CopyText; CopyText){}
                }
                trigger OnAfterGetRecord();
                begin
                    if Number > 1 then begin
                        CopyText := FormatDocument.GetCOPYText;
                        OutputNo += 1;
                    end;
                end;
                trigger OnPreDataItem();
                begin
                    NoOfLoops := ABS(NoOfCopies) + 1;
                    CopyText := '';
                    SETRANGE(Number, 1, NoOfLoops);
                    OutputNo := 1;
                end;
            }
        }
    }
    requestpage
    {
        layout
        {
            area(Content)
            {
                group(GroupName)
                {
                    field("Show Unit Cost"; ShowUnitCost)
                    {}
                    field(NoOfCopies; NoOfCopies)
                    {
                        ApplicationArea = Advanced;
                    }
                }
            }
        }
        actions
        {
            area(processing)
            {
                action(ActionName)
                {
                    ApplicationArea = All;
                }
            }
        }
    }
    var
        ShowUnitCost: Boolean;
        NoOfCopies: Integer;
        NoOfLoops: Integer;
        CopyText: Text[30];
        OutputNo: Integer;
        FormatDocument: Codeunit "Format Document";
} 

As you can see i have added CopyLoop and PageLoop as a dataitem after the Item Dataitem similar to that in C/AL, Logic remains the same (Syntax changes).

I have added the code which is bold in above AL Code.

RDL Layout (Similar to NAV).

We have created RDL Layout in prev blog and we will be modfying the same for printing multiple copies in AL.

Add list to Layout MSDYN365BC

Let insert a List by Right click on the empty space as shown above. we will add group on OutputNo and Pagebreak for the same as shown in below screenshot

Add group and Page Break to layout MSDYN365BC

Now place the Table inside the List

Add List and Report MSDYN365BC

Thats it your report is ready.

SAVE and CLOSE the SQL Server Report Builder.

Back in Visual Studio Code, press Ctrl+F5 to compile and run the report in Dynamics 365 Business Central.

Open Mordern Client search for AL ITEM LIST report and select Report, specify filter if required and run Report.

Add NoOfCopies as 1 and adding filter on Item No. to reduce the Records and Print.

Request page with NoOfCopies MSDYN365BC

Below is the output of the report having 2 copies.

NoOfCopies in AL MSDYN365BC

So we have created a RDL Layout Report with Multiple Copies in AL for Microsoft Dynamics 365 Business Central.

Source: https://divyeshchittenavbc.wordpress.com/msdyn35bc-2019-wave-2/


Comentarios

Entradas populares de este blog

Join two or more PDFs into one in Business Central

Connect An External Database To Business Central

How to open any document in OneDrive from Business Central