How to process child collection rows
This ‘How-to’ provides information on how to process rows in a child collection.
The following development process demonstrates how to set an attribute of a property on all the rows in a child class.
Code to process rows in a child collection should go under the 'CURPTH' class path for the corresponding child collection, rather than under the main class. For example:
If the class path is the child class (CURPTH = "[child class]"), the supervisor executes these events once per collection row:
$METHODS
Case CURPTH
When "[child class]"
Case ACTION
When "AREAD_AFTER"
Gosub ACTIVATE_FIELDS
Endcase
Endcase
Return
$ACTIVATE_FIELDS
ASTATUS = fmet this.ASETATTRIBUTE("PROPERTY",...
Return
If the class path is the main class (CURPTH = "" for example, blank = main class), the code is complex. The supervisor executes these events once for the entire entity:
$METHODS
Case CURPTH
When ""
Case ACTION
When "AREAD_AFTER"
Gosub ACTIVATE_FIELDS
Endcase
Endcase
Return
$ACTIVATE_FIELDS
For I = 1 To maxtab(this.CHILD)
If this.CHILD(I)<>null and find(this.ASTALIN,[V]CST_ADEL,[V]CST_ANEWDEL)=0
ASTATUS = fmet this.CHILD(I).ASETATTRIBUTE("PROPERTY",...
Endif
Next
Return
It is recommended to use the first method to avoid unnecessary loops and avoid dealing with indexes in a collection.