OnBeforeExportRecord()
// *
// Get the REAL DEMAND quantity
// *
SalesLine.SETRANGE("No.", "No.");
// Clear the counters
SalesLineQuantity := 0;
RealInventoryTotal := 0;
// Add Sales Lines Quantities
IF SalesLine.FINDSET THEN REPEAT
SalesLineQuantity := SalesLineQuantity + SalesLine.Quantity;
UNTIL SalesLine.NEXT = 0;
Item.GET("No."); // This doesn't seem to matter since at EXPORT time we are already on the current Item
RealInventoryTotal := SalesLineQuantity - Item.Inventory; // Output is the same whether I use the Item. or not
// *
// End REAL DEMAND quantity
// *
I have the following global variables:
SalesLine Rec Sales Line
SalesLineQuantity Decimal
RealInventoryTotal Decimal
I am using RealInventoryTotal as a dataport field under dataport fields.
The problem is the math doesn't seem to be performed for some reason.
If Item.Inventory = 46 and SalesLineQuantity = 1, my ouput in my export file shows 1, it should be 45.
I'm baffled here.
Half-empy or half-full how do you view your database?
Thanks.
0
Answers
Thanks.
It is a function you have to call before using a FlowField in your code (the Inventory field is a FlowField) so that the value of the field is calculated.
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog
The Dataport fields do have a property called Autocalcfield, which I guess does the calcfields for you... if you are exporting the flowfield field... but in this case, he's not exporting directly the Inventory field, he's doing some calculation with that field, and exporting the result, so this property won't work, he needs to put the calcfields function on his code anyway
Edit: ok, I've just seen that de DataItem also has a CalcFields property. Didn't know about that one.
CALCFIELDS(Inventory);
Just before I do my math?
Thanks.
I got it.
I added CALCFIELDS(Inventory); just before my math and that did the trick.
Now my problem is that if Inventory = 46 and SalesLineQuantity = 1 my end result comes out to -45 instead of 45.
Do I have to first determine which number is greater and then do my math with different equations.
Thanks.
if you want positive numbers if the inventory is grater than qty on documents, just revert the operators of your subtraction...
EDIT: i mean that if A - B = -C then B - A = C
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog
Solved!
Thanks.