getModified
This built-in method returns the list of properties that have been modified in an instance since the snapshot has been enabled.
Syntax
N_MODIFIED=MY_INSTANCE.getModified(NAMES, INDICES1, INDICES2, INDICES3)
The `NAMES` parameter is an array of strings. The method fills it with the names of the modified properties.
The INDICES1
parameter is an array of integers. This parameter is optional and is only needed if the instance contains properties of array type.
For each value modified in an array property, the method adds the name of the property to NAMES
and the index of the modified value to INDICES1
.
If several entries are modified in the same array property, the name of the property will appear several times in the NAMES
array and the corresponding values of INDICES1
will give the indices of the modified entries.
The INDICES2
and INDICES3
parameters are two additional optional arrays of integers. They are only relevant if the instance has multi-dimensional array properties, which is a rare scenario. They capture the second and third indices of the modified array entries for the multi-dimensional properties.
Example
# Recomputes a sales order instance if some of its properties have been modified.
Local Integer NB, RECOMPUTE
Local Char MODIFIED_PROPS(100)(1..), CURPROP(100)
# Get modified properties
NB=MYORDER.getModified(MODIFIED_PROPS)
# Check if some specific properties have been modified
For CURPROP = "CUSTOMER", "CURRENCY", "PAYMENTTERM", "AMOUNT", "DISCOUNT"
If find(CURPROP, MODIFIED_PROPS(1..NB)
RECOMPUTE=1
Break
Endif
Next CURPROP
# Recompute if one of the previous properties were modified
If RECOMPUTE=1
OK=Fmet SORDER.RECOMPUTE
Endif
The following is another example with indexes:# Get modified properties on a COMPUTATIONS instance with an array of AMOUNTS
Local Integer NB,I
Local Char MODIFIED_PROPS(100)(1..)
Local Integer MODIFIED_INDICES(1..)
Local instance COMPUTATION Using C_COMPUT
COMPUTATION=NewInstance C_COMPUT AllocGroup Null
For I=1 to dim(COMPUTATION.AMOUNT)
COMPUTATION.AMOUNT(I)=I
Next I
# Enable the snapshot
COMPUTATION.snapshotEnabled=1
# Double the amount entries 5 to 7
For I=5 to 7
COMPUTATION.AMOUNT(I)= 2*COMPUTATION.AMOUNT(I)
Next I
NB=COMPUTATION.getModified(MODIFIED_PROPS,MODIFIED_INDICES)
# NB is 3 because 3 entries have been modified
For I=1 to NB
# MODIFIED_PROPS(I) is "AMOUNT"
# MODIFIED_INDICES(I) varies from 5 to 7
Next I
Note
If an instance has child instances, references that have been freed or re-allocated will be reported by this method but changes to properties of child instances will not be reported. For all the changes on a graph of instances, you have to walk the graph and call getModified
on every node of the graph.
See also
revertToSnapshot, freeSnapshot, SnapshotEnabled, snapshot, Developer guide Snapshots
SnapshotEnabled, modified