report change needed. need help!!

johnsogj
Member Posts: 103
hi. i built this report over the sales invoice line table and it summarizes a bunch of information based on shipment date (when the user runs the report he selects the shipment date as a filter). I've attached a copy of the output. however, ideally, I'd like to use "Posting Date" from the sales invoice header table as that filter date. is this possible? Can anyone provide me with any suggestions? I've copied the current code below. how would I modify this to basically run off of the sales invoice header's "Posting Date"?
SalesInvLine.RESET;
SalesInvLine.SETCURRENTKEY(Type,"Shipment Date");
SalesInvLine.SETRANGE(Type,SalesInvLine.Type::Item);
SalesInvLine.SETRANGE ("Shipment Date", "Shipment Date");
TotalLinesDay := SalesInvLine.COUNT;
SalesInvLine.CALCSUMS(Quantity);
TotalPiecesDay := SalesInvLine.Quantity;
SalesInvLine.SETCURRENTKEY(Type,"Shipment Date","Sell-to Customer No.");
SalesInvLine.SETRANGE(Type,SalesInvLine.Type::Item);
SalesInvLine.SETRANGE ("Shipment Date", "Shipment Date");
SalesInvLine.SETRANGE ("Sell-to Customer No.", "Sell-to Customer No.");
TotalLines := SalesInvLine.COUNT;
SalesInvLine.CALCSUMS(Quantity);
TotalPieces := SalesInvLine.Quantity;
SalesInvHead.SETRANGE("Shipment Date", "Shipment Date");
IF SalesInvHead.FINDSET THEN
TotalInvoicesDay := SalesInvHead.COUNT;
SalesInvHead.SETRANGE("Shipment Date", "Shipment Date");
SalesInvHead.SETRANGE("Sell-to Customer No.", "Sell-to Customer No.");
IF SalesInvHead.FINDSET THEN
TotalInvoices := SalesInvHead.COUNT;
AvgLinesDay := TotalLinesDay/TotalInvoicesDay;
AvgPiecesDay := TotalPiecesDay/TotalInvoicesDay;
AvgLines := TotalLines/TotalInvoices;
AvgPieces := TotalPieces/TotalInvoices;
SalesInvLine.RESET;
SalesInvLine.SETCURRENTKEY(Type,"Shipment Date");
SalesInvLine.SETRANGE(Type,SalesInvLine.Type::Item);
SalesInvLine.SETRANGE ("Shipment Date", "Shipment Date");
TotalLinesDay := SalesInvLine.COUNT;
SalesInvLine.CALCSUMS(Quantity);
TotalPiecesDay := SalesInvLine.Quantity;
SalesInvLine.SETCURRENTKEY(Type,"Shipment Date","Sell-to Customer No.");
SalesInvLine.SETRANGE(Type,SalesInvLine.Type::Item);
SalesInvLine.SETRANGE ("Shipment Date", "Shipment Date");
SalesInvLine.SETRANGE ("Sell-to Customer No.", "Sell-to Customer No.");
TotalLines := SalesInvLine.COUNT;
SalesInvLine.CALCSUMS(Quantity);
TotalPieces := SalesInvLine.Quantity;
SalesInvHead.SETRANGE("Shipment Date", "Shipment Date");
IF SalesInvHead.FINDSET THEN
TotalInvoicesDay := SalesInvHead.COUNT;
SalesInvHead.SETRANGE("Shipment Date", "Shipment Date");
SalesInvHead.SETRANGE("Sell-to Customer No.", "Sell-to Customer No.");
IF SalesInvHead.FINDSET THEN
TotalInvoices := SalesInvHead.COUNT;
AvgLinesDay := TotalLinesDay/TotalInvoicesDay;
AvgPiecesDay := TotalPiecesDay/TotalInvoicesDay;
AvgLines := TotalLines/TotalInvoices;
AvgPieces := TotalPieces/TotalInvoices;
0
Comments
-
Hi John,
Yes is can be done but will not be as efficient as you will not be able to use the calcsums inside a loop. A sample of what you need to doSalesInvHead.SETRANGE("Posting Date", "Posting Date"); IF SalesInvHead.FINDSET THEN begin repeat SalesInvLine.RESET; SalesInvLine.SETRANGE("Document No.",SalesInvHead."No."); SalesInvLine.SETRANGE(Type,SalesInvLine.Type::Item); TotalLinesDay += SalesInvLine.COUNT; SalesInvLine.CALCSUMS(Quantity); TotalPiecesDay += SalesInvLine.Quantity; until SalesInvHead.NEXT = 0; end;
One observation - what about credit memos posted to cancel/re-invoice a shipment?0 -
thank you. I'm in the process of trying your suggestion. however, if "Sales Inv Line" is still my main data item, how can I use "Posting Date" (from the sales inv header) as a report filter?0
-
Hi,
You will probably have to re-structure the report but on the face of it you only print one section so you can use the invoice header as the dataitem.0 -
so would I have the sales inv header as the main data item and the sales inv line as a nested data item?0
-
Hi,
The key question is how many times you need to print the sections. It looks to me as if you print a summary for one day so even an integer dataitem with filter Number = const 1 would do as you are calculating all the information using record variables.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions