User:anonymousLog inRegister
Recents:
Old Function

Scope

Objects: Transactions
Languages: .NET, Ruby, Java, RPG, Visual FoxPro, Cobol

Purpose

To return the last stored value of a given attribute.

Syntax

Old(Attribute)

Type Returned:
Same as its argument

Description

Returns 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

Created: 07/28/08 02:08 PM by dmarquez Last update: 08/03/10 04:46 PM by blima ginzo
 
Page
Categories
Group
 
Powered by GXwiki 3.0 (generated with GeneXus X Evolution 1 U3)