Changing the Properties of a Data Class Using an Operation
This document provides information on how to use an operation to change the properties (fields) of a data class from another data class.
The development process described below demonstrates how to add a simple script to a data class (MYCLASS1) to create an operation called from a different data class (MYCLASS2).
$PROPERTIES
and $METHODS
labels are called in the event. You can also manually enter the running order.$Structure MYCLASS1###########################################METHODS ###########################################$METHODSCase CURPTHWhen ""Case ACTIONWhen "MYMETHOD" Gosub MYMETHOD # Update MYPROP1 method Endcase EndcaseReturn# Update MYPROP1 using MYPRAM1 which is passed# KEY1 and MYPARM1 are passed and used in this operation$MYMETHOD# Use standard method CRUD to read MYCLASS1ASTATUS=fmet THIS.AREAD(KEY1) If ASTATUS<>[V]CST_AOK ARET_VALUE= CST_AFALSEReturnEndif# Update PROP1 using MYPARM1THIS.PROP1 = MYPARM1# Update MYCLASS1ASTATUS=fmet THIS.AUPDATEIf ASTATUS<>[V]CST_AOK # check status after updateARET_VALUE= CST_AFALSEReturnEndifARET_VALUE= CST_ATRUE Return
############################################### Data Class - MYCLASS2 ##############################################################################################METHODS ###############################################$METHODSCase CURPROWhen ""Case ACTIONWhen "AINSERT_AFTER" : Gosub AINSERT_AFTEREndcaseEndcaseReturn# Action After insert$AINSERT_AFTER# Declaration new instance of MYCLASS2 data classLocal Instance MYCLASS Using C_MYCLASS2MYCLASS = NewInstance C_MYCLASS2 AllocGroup NullASTATUS=fmet MYCLASS.MYMETHOD(KEYID,MYPARM1)If ASTATUS<>[V]CST_ATRUEASTATUS = fmet THIS.ASETERROR ("", "Not updated.", [V]CST_AERROR) Endif# Free instancesFreeGroup MYCLASSReturn