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 #
##########################################
$METHODS
Case CURPTH
When ""
Case ACTION
When "MYMETHOD" Gosub MYMETHOD # Update MYPROP1 method
Endcase
Endcase
Return
# Update MYPROP1 using MYPRAM1 which is passed
# KEY1 and MYPARM1 are passed and used in this operation
$MYMETHOD
# Use standard method CRUD to read MYCLASS1
ASTATUS=fmet THIS.AREAD(KEY1)
If ASTATUS<>[V]CST_AOK
ARET_VALUE= CST_AFALSE
Return
Endif
# Update PROP1 using MYPARM1
THIS.PROP1 = MYPARM1
# Update MYCLASS1
ASTATUS=fmet THIS.AUPDATE
If ASTATUS<>[V]CST_AOK # check status after update
ARET_VALUE= CST_AFALSE
Return
Endif
ARET_VALUE= CST_ATRUE
Return##############################################
# Data Class - MYCLASS2 #
##############################################
##############################################
# METHODS #
##############################################
$METHODS
Case CURPRO
When ""
Case ACTION
When "AINSERT_AFTER" : Gosub AINSERT_AFTER
Endcase
Endcase
Return
# Action After insert
$AINSERT_AFTER
# Declaration new instance of MYCLASS2 data class
Local Instance MYCLASS Using C_MYCLASS2
MYCLASS = NewInstance C_MYCLASS2 AllocGroup Null
ASTATUS=fmet MYCLASS.MYMETHOD(KEYID,MYPARM1)
If ASTATUS<>[V]CST_ATRUE
ASTATUS = fmet THIS.ASETERROR ("", "Not updated.", [V]CST_AERROR)
Endif
# Free instances
FreeGroup MYCLASS
Return