hello, I've created a report that runs over the sales line table. I have the user filter request set up so that "shipment date" defaults. however, when I enter a range of dates: "11/12/07..11/30/07", it only prints the data for the first date in the range. has anyone seen this happen before?
thanks
0
Comments
Something is wrong with your code. Post your code on here so people can take a look.
AP Commerce, Inc. = where I work
Getting Started with Dynamics NAV 2013 Application Development = my book
Implementing Microsoft Dynamics NAV - 3rd Edition = my 2nd book
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;
Do you need to filter the SalesInvLine basicly of the insertet filter in field "Shipment Date" from Sales Line :?:
But here you filter SalsInvLine."Shipment date" with the value of "Shipment Date" from a located Rec in SalesLine. So you need to filter.
The same issue for the other "Shipment date" Filters .....
Regards
SalesInvLine.RESET;
SalesInvLine.SETCURRENTKEY(Type,"Shipment Date");
SalesInvLine.SETRANGE(Type,SalesInvLine.Type::Item);
SalesInvLine.SETFILTER("Shipment Date", GETFILTER("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.SETFILTER("Shipment Date", GETFILTER("Shipment Date"));
SalesInvLine.SETRANGE ("Sell-to Customer No.", "Sell-to Customer No.");
TotalLines := SalesInvLine.COUNT;
SalesInvLine.CALCSUMS(Quantity);
TotalPieces := SalesInvLine.Quantity;
SalesInvLine.SETFILTER("Shipment Date", GETFILTER("Shipment Date"));
IF SalesInvHead.FINDSET THEN
TotalInvoicesDay := SalesInvHead.COUNT;
SalesInvLine.SETFILTER("Shipment Date", GETFILTER("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;
John,
the code you posted here is NOT the code that is causingthe problem. The filter you are applying is (I will have to assume since you seem to be holding out on us :evil: ) on "Sales Inv. Line"."Shipment date".
that being the record in the Report section. We need to see how you are filtering that one, its irrelevant what you do withthe SalesInvLine table, since that is not the record in the loop.
By the way, you could use a C/AL syntax primer. Some statements are repeated that don't need to be repeated. For instance, once you set a filter on a field, it keeps the filter, you don't have to set it twice when you add a filter on another field. Also, you don't have to say IF FINDSET THEN COUNT, you can leave out the IF FINDSET part. If there are no records the system will return 0. Now you're getting the COUNT as well as the entire record set for every record. Lots of overhead in that code .
RIS Plus, LLC
If you need to output the located SalesInvLines you need a seperate DataItem. I think you source is behind the OnAfterGetRecord Trigger of DataItem Sales Line or?
@DenSter: In his first post he wrote, that he go over the Sales Line. With the CalcSums Function, my opinion was, that he only need the SalesInvLine to calculate some fields basicly on Shipment Filter, etc. That the code is not the best, is an other part ;-)
Regards
can you please post the dataitems you have in this report and their dataitemindent and DataItemLinkReference ?
Cause maybe we're not getting it right!
RIS Plus, LLC
Create two new variable. StartDate, EndDate.
OnPrereport
Copy the getrangemin and getrangemax to the variable. and in your code add
StartDate := "Sales Line".GetRANGEMIN("SHipment Date");
EndDate := "Sales Line".GetRANGEMAX("SHipment Date");
SalesInvLine.SETFILTER("Shipment Date", StartDate,EndDate);
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
The only way to really see what is going on is to see the object.
RIS Plus, LLC
I'll try to export the code based on the instructions of one of you previously...
SalesInvLine.RESET;
SalesInvLine.SETCURRENTKEY(Type,"Shipment Date");
SalesInvLine.SETRANGE(Type,SalesInvLine.Type::Item);
SalesInvLine.SETFILTER("Shipment Date", GETFILTER("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.SETFILTER("Shipment Date", GETFILTER("Shipment Date"));
SalesInvLine.SETRANGE ("Sell-to Customer No.", "Sell-to Customer No.");
TotalLines := SalesInvLine.COUNT;
SalesInvLine.CALCSUMS(Quantity);
TotalPieces := SalesInvLine.Quantity;
SalesInvLine.SETFILTER("Shipment Date", GETFILTER("Shipment Date"));
IF SalesInvHead.FINDSET THEN
TotalInvoicesDay := SalesInvHead.COUNT;
SalesInvLine.SETFILTER("Shipment Date", GETFILTER("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;
You define some fields twice? any reason?
Did you try one than the other? Are these really key's? Or did you make new keys?
http://www.BiloBeauty.com
http://www.autismspeaks.org
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
RIS Plus, LLC
RecVariable.setfilter(Somefield,OtherRecVariableOrDataItemVariable.getfilter(SomeField));
It works. It is the same like getrangemin, getrangemax <- but these have troube if you use a filter like 01.01.08.. or ..31.12.08. Its work only for 01.01.08..31.12.08
Regards
The Name of you used DataItem is realy SalesInvLine :?:
If yes, why you reset the filters :?:
johnsogj
if no, forgett this post ....