Hi All,
I have created a custom report in that i want to get the no. of copies functionality i have tried but it is not working perfectly can anyone help me, i am sharing my code and the output how it is coming, my doubt is how to and where i have to set the copy and page loop, if i set them correctly, or not due to those my output not coming.
report 50008 " Label Report"
{
ApplicationArea = All;
Caption = 'Label';
UsageCategory = ReportsAndAnalysis;
DefaultLayout = RDLC;
RDLCLayout = './source/layout/Labels.rdl';
dataset
{
dataitem("Sales Header"; "Sales Header")
{
RequestFilterFields = "No.";
column(No_; "No.") { }
column(Sell_to_Customer_No_; "Sell-to Customer No.") { }
column(Bill_to_Customer_Name; "Sell-to Customer Name" + ' ' + "Sell-to Customer Name 2")
{
}
column(Ship_to_Code; "Ship-to Code") { }
column(Ship_to_Name; "Ship-to Name") { }
column(Ship_to_Address; "Ship-to Address" + ' ' + "Ship-to Address 2") { }
column(Ship_to_City; "Ship-to City") { }
column(Ship_to_County; "Ship-to County") { }
column(Ship_to_Post_Code; "Ship-to Post Code") { }
column(SQIT_Country_of_Origin; "SQIT Country of Origin") { }
column(Sell_to_Contact; "Sell-to Contact") { }
column(External_Document_No_; "External Document No.") { }
column(CompanyPicture; companyinfo.Picture) { }
column(CompanyName; UpperCase(Companyinfo.Name)) { }
column(Comp_VATRegNo; Companyinfo."VAT Registration No.") { }
column(CompanyAddress; Address) { }
column(CompanyAddress1; Address1) { }
column(CompanyCity_Country; "City&Country") { }
column(PhoneNo; 'Tel : ' + Companyinfo."Phone No.") { }
column(Phone; Companyinfo."Phone No.") { }
column(FaxNo; 'Fax : ' + Companyinfo."Fax No.") { }
column(Fax; Companyinfo."Fax No.") { }
dataitem(copyloop; Integer)
{
DataItemTableView = sorting(Number);
dataitem(pageloop; Integer)
{
DataItemTableView = sorting(Number) where(Number = const(1));
column(OutputNoNo; OutputNoNo) { }
column(ReportTitleCopyText; StrSubstNo(Text004, CopyText)) { }
}
trigger OnAfterGetRecord()
var
myInt: Integer;
begin
if Number > 1 then begin
Copytext := FormatDocument.GetCOPYText();
OutputNoNo += 1;
end;
end;
trigger OnPreDataItem()
begin
NoofLoops := Abs(NoofCopies) + 1;
Copytext := '';
SetRange(Number, 1, NoofLoops);
OutputNoNo := 1;
end;
}
dataitem("Sales Line"; "Sales Line")
{
DataItemLink = "Document No." = field("No.");
DataItemLinkReference = "Sales Header";
column(ItemNo_; "Sales Line"."No.") { }
column(Line_No_; "Sales Line"."Line No.") { }
column(SQIT_Sampling_No_; "Sales Line"."SQIT Sampling No.") { }
column(Net_Weight; "Sales Line"."Net Weight") { }
dataitem("Warehouse Shipment Line"; "Warehouse Shipment Line")
{
DataItemLinkReference = "Sales Line";
DataItemLink = "Source No." = field("Document No."), "Item No." = field("No.");
dataitem("Sampling Details"; "Sampling Details")
{
DataItemLinkReference = "Warehouse Shipment Line";
DataItemLink = "Sampling No." = field("Sampling No.");
column(SamplingNo_SamplingDetails;
"Sampling No.")
{
}
column(ItemNo_SamplingDetails; "Item No.")
{
}
dataitem("Sampling Result Details"; "Sampling Result Details")
{
DataItemLinkReference = "Sampling Details";
DataItemLink = "Sampling No." = field("Sampling No.");
column(SamplingNo_SamplingResultDetails; "Sampling No.")
{
}
column(LineNo_SamplingResultDetails; "Line No.")
{
}
column(ElementCode_SamplingResultDetails; "Element Code")
{
}
column(ConcentrationQtyPPMwt_SamplingResultDetails; "Concentration Qty (PPM wt)")
{
}
column(ConcentrationPPMwt_SamplingResultDetails; "Concentration % (PPM wt)")
{
}
}
dataitem("Packing Details"; "Packing Details")
{
RequestFilterFields = "Package No.";
DataItemLinkReference = "Sales Line";
DataItemLink = "Source No." = field("Document No.");
column(Gross_Weight; "Gross Weight") { }
column(Net_WeightPackingDetails; "Net Weight") { }
column(Tare_Weight; "Tare Weight") { }
column(Package_No_; "Package No.") { }
column(Pallet_ID; "Pallet ID") { }
}
}
}
}
}
}
requestpage
{
layout
{
area(content)
{
group(Filters)
{
field(NoofCopies; NoofCopies)
{
Caption = 'No. of Copies';
ApplicationArea = All;
}
}
}
}
actions
{
area(processing)
{
}
}
}
trigger OnPreReport()
var
myInt: Integer;
begin
companyinfo.Get();
companyinfo.CalcFields(companyinfo.Picture);
Address := Companyinfo.Address + ',' + Companyinfo."Address 2";
Address1 := Companyinfo."Phone No." + ',' + Companyinfo."Fax No.";
Country.Reset;
Country.SetRange(Country.Code, Companyinfo."Country/Region Code");
if Country.FindFirst then CountryName := Country.Name;
"City&Country" := Companyinfo.City + ', ' + CountryName;
end;
var
companyinfo: Record "Company Information";
Address: Text[200];
Address1: Text[200];
"City&Country": Text[200];
Country: Record "Country/Region";
CountryName: Text[100];
NoofCopies: Integer;
NoofLoops: Integer;
Copytext: Text[30];
OutputNoNo: Integer;
Text004: Label 'Label %1';
FormatDocument: Codeunit "Format Document";
}
The output is coming like this when i try to print for 2 copies and in the layout i have kept the list and then given the group properties for outputNo and given the page breaks also, i am not using any set data for this one because i dont want names for the copies and page no. also.
then try to debug the problem, I am sure you will find the solution.
Hi Nitin,
Thank you for suggesting me the solution I have tried your code but the output is coming in the same way as I kept the screenshots before
Thanks & regards
Satish
Hi,
You can try this, I did a little bit changes.
report 66003 "Label Report" { ApplicationArea = All; Caption = 'Label'; UsageCategory = ReportsAndAnalysis; DefaultLayout = RDLC; RDLCLayout = './source/layout/Labels.rdl'; dataset { dataitem("Sales Header"; "Sales Header") { RequestFilterFields = "No."; column(No_; "No.") { } column(Sell_to_Customer_No_; "Sell-to Customer No.") { } column(Bill_to_Customer_Name; "Sell-to Customer Name" ' ' "Sell-to Customer Name 2") { } column(Ship_to_Code; "Ship-to Code") { } column(Ship_to_Name; "Ship-to Name") { } column(Ship_to_Address; "Ship-to Address" ' ' "Ship-to Address 2") { } column(Ship_to_City; "Ship-to City") { } column(Ship_to_County; "Ship-to County") { } column(Ship_to_Post_Code; "Ship-to Post Code") { } column(SQIT_Country_of_Origin; "SQIT Country of Origin") { } column(Sell_to_Contact; "Sell-to Contact") { } column(External_Document_No_; "External Document No.") { } column(CompanyPicture; companyinfo.Picture) { } column(CompanyName; UpperCase(Companyinfo.Name)) { } column(Comp_VATRegNo; Companyinfo."VAT Registration No.") { } column(CompanyAddress; Address) { } column(CompanyAddress1; Address1) { } column(CompanyCity_Country; "City&Country") { } column(PhoneNo; 'Tel : ' Companyinfo."Phone No.") { } column(Phone; Companyinfo."Phone No.") { } column(FaxNo; 'Fax : ' Companyinfo."Fax No.") { } column(Fax; Companyinfo."Fax No.") { } dataitem(copyloop; Integer) { DataItemTableView = sorting(Number); dataitem(pageloop; Integer) { DataItemTableView = sorting(Number) where(Number = const(1)); column(OutputNoNo; OutputNoNo) { } column(ReportTitleCopyText; StrSubstNo(Text004, CopyText)) { } } trigger OnAfterGetRecord() var myInt: Integer; begin if Number > 1 then begin Copytext := FormatDocument.GetCOPYText(); OutputNoNo = 1; end; CurrReport.PAGENO := 1; end; trigger OnPreDataItem() begin NoOfLoops := ABS(NoOfCopies) 1; IF NoOfLoops <= 0 THEN NoOfLoops := 1; CopyText := ''; SETRANGE(Number, 1, NoOfLoops); OutputNo := 1; end; } dataitem("Sales Line"; "Sales Line") { DataItemLink = "Document No." = field("No."); DataItemLinkReference = "Sales Header"; column(ItemNo_; "Sales Line"."No.") { } column(Line_No_; "Sales Line"."Line No.") { } column(SQIT_Sampling_No_; "Sales Line"."SQIT Sampling No.") { } column(Net_Weight; "Sales Line"."Net Weight") { } dataitem("Warehouse Shipment Line"; "Warehouse Shipment Line") { DataItemLinkReference = "Sales Line"; DataItemLink = "Source No." = field("Document No."), "Item No." = field("No."); dataitem("Sampling Details"; "Sampling Details") { DataItemLinkReference = "Warehouse Shipment Line"; DataItemLink = "Sampling No." = field("Sampling No."); column(SamplingNo_SamplingDetails; "Sampling No.") { } column(ItemNo_SamplingDetails; "Item No.") { } dataitem("Sampling Result Details"; "Sampling Result Details") { DataItemLinkReference = "Sampling Details"; DataItemLink = "Sampling No." = field("Sampling No."); column(SamplingNo_SamplingResultDetails; "Sampling No.") { } column(LineNo_SamplingResultDetails; "Line No.") { } column(ElementCode_SamplingResultDetails; "Element Code") { } column(ConcentrationQtyPPMwt_SamplingResultDetails; "Concentration Qty (PPM wt)") { } column(ConcentrationPPMwt_SamplingResultDetails; "Concentration % (PPM wt)") { } } dataitem("Packing Details"; "Packing Details") { RequestFilterFields = "Package No."; DataItemLinkReference = "Sales Line"; DataItemLink = "Source No." = field("Document No."); column(Gross_Weight; "Gross Weight") { } column(Net_WeightPackingDetails; "Net Weight") { } column(Tare_Weight; "Tare Weight") { } column(Package_No_; "Package No.") { } column(Pallet_ID; "Pallet ID") { } } } } } } } requestpage { layout { area(content) { group(Filters) { field(NoofCopies; NoofCopies) { Caption = 'No. of Copies'; ApplicationArea = All; } } } } actions { area(processing) { } } } trigger OnPreReport() var myInt: Integer; begin companyinfo.Get(); companyinfo.CalcFields(companyinfo.Picture); Address := Companyinfo.Address ',' Companyinfo."Address 2"; Address1 := Companyinfo."Phone No." ',' Companyinfo."Fax No."; Country.Reset; Country.SetRange(Country.Code, Companyinfo."Country/Region Code"); if Country.FindFirst then CountryName := Country.Name; "City&Country" := Companyinfo.City ', ' CountryName; end; var companyinfo: Record "Company Information"; Address: Text[200]; Address1: Text[200]; "City&Country": Text[200]; Country: Record "Country/Region"; CountryName: Text[100]; NoofCopies: Integer; NoofLoops: Integer; Copytext: Text[30]; OutputNoNo: Integer; Text004: Label 'Label %1'; FormatDocument: Codeunit "Format Document"; }
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,219 Super User 2024 Season 2
Martin Dráb 230,056 Most Valuable Professional
nmaenpaa 101,156