Purchase Order Report in D365 BC:
(1) Development of New report already explained in the previous blog. In this blog, we will develop a new “Purchase Order Report”. Follow the below screenshot and develop a report for the client. The report includes- No. of Copies and Document No. filter.


















(2) RDLC Format for designing.

(3) After publish and attached. See the result in the below screenshot.


Source Code:
report 50001 “Purchase Order Report” { UsageCategory = Administration; ApplicationArea = All; DefaultLayout = RDLC; RDLCLayout = ‘./PurchaseOrderReport.rdl’; dataset { dataitem(Integer; Integer) { DataItemTableView = SORTING(“Number”); column(Number_Copies; Number) { } column(Copy_Text; CopyText) { } dataitem(“Purchase Header”; “Purchase Header”) { DataItemTableView = SORTING(“No.”); DataItemLinkReference = Integer; column(CompanyInformation_Name; CompanyInformation.Name) { } column(CompanyInformation_Picture; CompanyInformation.Picture) { } column(CompanyInformation_POSign; CompanyInformation.POSignature) { } column(CompanyInformation_Address; CompanyInformation.Address) { } column(CompanyInformation_Address_2; CompanyInformation.”Address 2″) { } column(CompanyInformation_Post_Code; CompanyInformation.”Post Code”) { } column(CompanyInformation_City_Code; CompanyInformation.”City”) { } column(CompanyInformation_GST_No; CompanyInformation.”GST Registration No.”) { } column(CompanyInformation_State_Code; CompanyInformation.”State Code”) { } column(CompanyInformation_Email_Id; CompanyInformation.”E-Mail”) { } column(CompanyInformation_Phone_No; CompanyInformation.”Phone No.”) { } column(CompanyInformation_PAN_No; CompanyInformation.”P.A.N. No.”) { } column(CompanyInformation_Industrial_Classification; CompanyInformation.”Industrial Classification”) { } column(CompanyInformation_Bank_Name; CompanyInformation.”Bank Name”) { } column(CompanyInformation_Bank_Account_No; CompanyInformation.”Bank Account No.”) { } column(CompanyInformation_Bank_Branch_No; CompanyInformation.”Bank Branch No.”) { } column(Document_No_; “No.”) { } column(Order_Date; format(“Order Date”)) { } column(Buy_from_Vendor_No; “Buy-from Vendor No.”) { } column(Buy_from_Vendor_Name; “Buy-from Vendor Name”) { } column(Buy_from_Address; “Buy-from Address”) { } column(Buy_from_Address_2; “Buy-from Address 2”) { } column(Buy_from_City; “Buy-from City”) { } column(Buy_from_Post_Code; “Buy-from Post Code”) { } column(Buy_from_Contact_No; “Buy-from Contact No.”) { } column(Buy_from_GST_No; GetVendor.”GST Registration No.”) { } column(Buy_from_PAN_No; GetVendor.”P.A.N. No.”) { } column(Buy_from_Ph_No; GetVendor.”Phone No.”) { } column(Buy_from_State_Code; GetVendor.”State Code”) { } column(Buy_from_Country_Code; GetVendor.”Country/Region Code”) { } column(Ship_to_Name; “Ship-to Name”) { } column(Ship_to_Address; “Ship-to Address”) { } column(Ship_to_Address_2; “Ship-to Address 2”) { } column(Ship_to_City; “Ship-to City”) { } column(Ship_to_Post_Code; “Ship-to Post Code”) { } column(Total_CGST_Amount; TotalCGSTAmount) { } column(Total_SGST_Amount; TotalSGSTAmount) { } column(Total_IGST_Amount; TotalIGSTAmount) { } column(CGST_Percentage; CGSTPercentage) { } column(SGST_Percentage; SGSTPercentage) { } column(IGST_Percentage; IGSTPercentage) { } column(Total_Invoice_Value; TotalInvoiceValue) { } column(AmountInWords_1; AmountInWords[1]) { } column(AmountInWords_2; AmountInWords[2]) { } column(Header_Comment; HeaderComment) { } column(Payment_Terms_Description; GetPaymentTerms.Description) { } dataitem(“Purchase Line”; “Purchase Line”) { DataItemTableView = SORTING(“Document No.”, “Line No.”); DataItemLinkReference = “Purchase Header”; DataItemLink = “Document No.” = FIELD(“No.”); column(Sr_No; SrNo) { } column(Line_No_; “No.”) { } column(Line_Description; “Description”) { } column(Line_Description_2; “Description 2”) { } column(Line_Quantity; “Quantity”) { } column(Unit_of_Measure_Code; “Unit Of Measure Code”) { } column(Unit_Price; “Direct Unit Cost”) { } column(Line_Amount; “Line Amount”) { } column(HSN_SAC_Code; “HSN/SAC Code”) { } column(Line_Comment; LineComment) { } trigger onafterGetRecord() var myInt: Integer; begin SrNo += 1; Clear(LineComment); Clear(LineCommentCounter); PurchCommentLine.reset; PurchCommentLine.setfilter(“Document Type”, ‘%1’, PurchCommentLine.”Document Type”::Order); PurchCommentLine.setrange(“No.”, “Document No.”); PurchCommentLine.Setrange(“Document Line No.”, “Line No.”); if PurchCommentLine.FindSet() then begin repeat LineCommentCounter += 1; if LineCommentCounter> 1 then LineComment := LineComment + ‘ ‘ + PurchCommentLine.Comment else LineComment := PurchCommentLine.Comment; Until PurchCommentLine.next = 0; end; end; } trigger OnPreDataItem() var myInt: Integer; begin CompanyInformation.get(); CompanyInformation.CalcFields(Picture); CompanyInformation.CalcFields(POSignature); end; trigger OnAfterGetRecord() var myInt: Integer; begin SrNo := 0; TotalCGSTAmount := 0; TotalSGSTAmount := 0; TotalIGSTAmount := 0; GetVendor.get(“Buy-from Vendor No.”); DetailedGSTEntryBuffer.reset; DetailedGSTEntryBuffer.setrange(“Document No.”, “No.”); if DetailedGSTEntryBuffer.FindSet() then begin repeat if DetailedGSTEntryBuffer.”GST Component Code” = ‘CGST’ then TotalCGSTAmount += DetailedGSTEntryBuffer.”GST Amount”; if DetailedGSTEntryBuffer.”GST Component Code” = ‘SGST’ then TotalSGSTAmount += DetailedGSTEntryBuffer.”GST Amount”; if DetailedGSTEntryBuffer.”GST Component Code” = ‘IGST’ then TotalIGSTAmount += DetailedGSTEntryBuffer.”GST Amount”; until DetailedGSTEntryBuffer.next = 0; end; TotalInvoiceValue := 0; PurchaseLine.reset; PurchaseLine.Setrange(“Document No.”, “No.”); if PurchaseLine.FindSet() then begin Repeat TotalInvoiceValue += PurchaseLine.”Line Amount”; Until PurchaseLine.next = 0; end; TotalInvoiceValue += TotalCGSTAmount + TotalSGSTAmount + TotalIGSTAmount; Clear(HeaderComment); Clear(HeaderCommentCounter); PurchHeaderCommentLine.reset; PurchHeaderCommentLine.setrange(“No.”, “No.”); PurchHeaderCommentLine.Setfilter(“Document Line No.”, ‘%1’, 0); if PurchHeaderCommentLine.FindSet() then begin repeat HeaderCommentCounter += 1; if HeaderCommentCounter> 1 then HeaderComment := HeaderComment + ‘ ‘ + PurchHeaderCommentLine.Comment else HeaderComment := PurchHeaderCommentLine.Comment; Until PurchHeaderCommentLine.next = 0; end; GetPaymentTerms.get(“Payment Terms Code”); IndianReportCheck.InitTextVariable(); IndianReportCheck.FormatNoText(AmountinWords, TotalInvoiceValue, “Currency Code”); end; } trigger OnPreDataItem() var myInt: Integer; begin if NoOfPrint> 1 then Setrange(Number, 1, NoOfPrint) else Setrange(Number, 1, 1); end; trigger OnAfterGetRecord() var myInt: Integer; begin end; } } requestpage { layout { area(Content) { group(Options) { Caption = ‘Options’; field(NoOfPrint; NoOfPrint) { ApplicationArea = Basic, Suite; Caption = ‘No. of Prints’; ToolTip = ‘Specifies how many copies of the document to print.’; } } } } actions { area(processing) { action(ActionName) { ApplicationArea = All; } } } } var CopyText: Text; CompanyInformation: Record “Company Information”; NoOfPrint: Integer; SrNo: Integer; GetVendor: Record Vendor; DetailedGSTEntryBuffer: record “Detailed GST Entry Buffer”; TotalCGSTAmount: Decimal; TotalSGSTAmount: Decimal; TotalIGSTAmount: Decimal; CGSTPercentage: Decimal; SGSTPercentage: Decimal; IGSTPercentage: Decimal; LineComment: Text; LineCommentCounter: Integer; PurchCommentLine: Record “Purch. Comment Line”; PurchHeaderCommentLine: Record “Purch. Comment Line”; HeaderComment: Text; HeaderCommentCounter: Integer; TotalInvoiceValue: Decimal; PurchaseLine: Record “Purchase Line”; IndianReportCheck: Report 18041; AmountinWords: array[2] of Text[80]; GetPaymentTerms: Record “Payment Terms”; } |