Hey guys.
Using the Sales Shipment Header + Lines, I'm trying to write something that will show the difference, in days, between the ship date in the header and the planned shipment date in the lines. basically to see if we are shipping on time or not.
in the lines, i did
OnTime := "Sales Shipment Header"."Shipment Date" - "Planned Shipment Date"
I set "OnTime" to be an integer and dropped it in a custom report, in the lines body.
now when i run the report i get a date invalid error. where am i going wrong?
and is there a good C/Side book that i could buy? any help would be greatly appreciated!
-Adam
0
Comments
If wither of the dates are nto assigned you get the error. Either Sales header shipment date is blank ( 0D) or the salesline planned shipmnet date is blank ( 0D)
check if they are blank before you calculate.
clear(OnTime);
if (SH.shimentdate <> '' ) and (sl.plannedshimentdate <> '') then
OnTime := SH.shimentdate - l.plannedshimentdate ;
also:
are there any good cside books?
edit:
ok i pasted the code, and tried to define the variables.. i'm a noob, i'm sorry. i specified in the globals
sh / record / sales shipment header
sl / record / sales shipment line
then i got stuck defining the (sl.shipment <> ) part.
i'm sorry
there are a ton of helpful PDFs on the Navision installation disc, plus the often less than stellar C/side reference guide accessible from within Navision.
if ("Sales Shipment Header"."Shipment Date" <> 0D) AND
("Planned Shipment Date" <> 0D) then
OnTime := "Sales Shipment Header"."Shipment Date" - "Planned Shipment Date"
else
OnTime := 999999;
lets say 999999 indicating its a a invalid date.
I added some totals, and my report is really shaping up!
Is there any type of "count" function in Navision? Where I could "count" all the "lines" of the report, and "count" how many lines have a positive "OnTime" value?
And then divide them to come up with a OnTime %?
you guys have made my morning very successful
you could use a couple of incrementing integer c/al globals to count things as you find them...
like:
if ("Sales Shipment Header"."Shipment Date" <> 0D) AND
("Planned Shipment Date" <> 0D) then begin
OnTime := "Sales Shipment Header"."Shipment Date" - "Planned Shipment Date";
IF OnTime > 0 THEN
Counter1 += 1;
IF OnTime <0 THEN
Counter2 += 1;
end else begin
OnTime := 999999;
end;
at the end of the report you can do arithmetic with these integers you've calculated, like
If (Counter1 + Counter2) <> 0 THEN //just to handle potential divide by zero errors
"%OnTime" := ROUND(Counter1 / (Counter1 + Counter2),.02) *100;
you will have to program this to meet your needs, obviously. don't just copy and paste this.
I can do some basic things, but things get hairy when i need to start coding. but i'm doing my best! live and learn i suppose.
thanks so much!
~adam
i learn new things every day thanks to this forum, so definitely keep coming back to Mibuso if you are serious about learning Nav!
I make multi table reports all the time and all sorts of basic things, it's just the code that's killing me. Fortunately Nav will try and point out the error in the code so I can rewrite it until it works out correctly.
Although having a good understanding of "If Else Begin End Then" statements would definitely help me out. haha.
Thanks again
-adam
I was able to get the counter to work and got the % to work, all in the footer.
Is there anyway I can transplant that data into the header section? I mean it's perfect data, and I'm super happy, but when i put the fields in the header they came up as blank, T_T
the problem is that the data is not calculated until all of your data processing has been done (ie. at the footer, after the last record was prcessed). The report is created in real time, though, so the header is generated long before you have ever "done the math." you could use some integer data items after your existing data items to create the report sections after you have done all of the processing, but this will entail a lot more programming on your end. you would have to be writing values to temp tables and recalling those during the integer data item output.
it would be like:
data item 1
data item 2
data item 3
data item x
data item y
Integer (with all section output based on this)
maybe there is an easier way, but rookie me has not found it!