DataPort OnBeforeExportRecord() math not being performed???

emulsifiedemulsified Member Posts: 139
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.

Answers

  • crisnicolascrisnicolas Member Posts: 177
    You are probably missing the CALCFIELDS on the Inventory field.
  • emulsifiedemulsified Member Posts: 139
    ? is that in properties somewhere I can't remember.
    Half-empy or half-full how do you view your database?

    Thanks.
  • crisnicolascrisnicolas Member Posts: 177
    No, it is not a property.
    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.
  • BeliasBelias Member Posts: 2,998
    No, it is not a property.
    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.
    it's a property of the dataitem, too!
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • crisnicolascrisnicolas Member Posts: 177
    Belias wrote:
    No, it is not a property.
    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.
    it's a property of the dataitem, too!

    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.
  • emulsifiedemulsified Member Posts: 139
    So I would do:

    CALCFIELDS(Inventory);

    Just before I do my math?
    Half-empy or half-full how do you view your database?

    Thanks.
  • emulsifiedemulsified Member Posts: 139
    Okay.

    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.
    Half-empy or half-full how do you view your database?

    Thanks.
  • BeliasBelias Member Posts: 2,998
    It all depends on what do you want to achieve...
    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 :mrgreen:
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • emulsifiedemulsified Member Posts: 139
    Thank you.

    Solved!
    Half-empy or half-full how do you view your database?

    Thanks.
Sign In or Register to comment.