ScopeObjects: Transactions Languages: .NET, Ruby, Java, RPG, Visual FoxPro, Cobol
PurposeTo return the last stored value of a given attribute.
SyntaxOld(Attribute)
Type Returned: Same as its argument
DescriptionReturns the last stored value of a given attribute = Attribute. The type definition returned is equal to the attribute's type definition. If attribute is a non-redundant formula, the returned value is the result of evaluating the formula by using the last stored values of the Attributes involved in the formula.
Example
If we want to simulate an ADD rule to update PrdStk (Product Stock) from a Receipt Transaction (where RcptQty (Receipt Quantity) is the quantity received of a certain product), it should be done as follows: // STOCK update (add simulation) PrdStk = PrdStk + RcptQty IF Insert; PrdStk = PrdStk + RcptQty - Old(RcptQty) IF Update; PrdStk = PrdStk - RcptQty IF Delete;
At insert time we add the quantity of the product purchased to the previous stock. At update time, we can modify such quantity, if necessary. To achieve this, we add the new quantity, but we have to subtract the one previously entered. We do this by subtracting the "old" value entered for RcptQty. Lastly, for cases where a delivery has been turned back, we have to perform a Delete operation (canceling the previous entry), and subtract the quantity indicated in the Receipt.
All this is functionally equivalent to the following ADD rule: Add(RcptQty, PrdStk);
See Also
GetOldValue Method
|