Sending Messages to DDOs
Data dictionary objects are manipulated by sending them messages. These messages tend to fall into two categories:
-
DDO Properties: These messages are sent to DDOs to either retrieve data about the DDO or to change DDO data. Often you will be getting or setting data about a field. This data might be the field’s current value (the most frequently used property message) or it might be other field data such as a field’s changed state, its data type, or its label name. Sometimes you will retrieve data about an entire table such as the table’s current RowId or the table’s changed state.
-
DDO Operations: These messages are sent to DDOs to perform operations on your data. Those operations include finding, clearing, saving, deleting, and validating records.
Custom methods will often combine the use of DDO property messages and DDO operation methods. For example, you might change the value of a record by:
- Sending a find operation message.
- Changing a field value by sending property Set messages.
- Sending a validation operation message.
- Sending a save operation message.
In all cases, these messages are sent from your custom function or procedure to the appropriate DD object.
Sending Messages to Objects
The mechanism for sending messages to objects is described in the Language Guide under the section titled Sending Messages to Objects. In case you are not familiar with the syntax for sending messages, you are encouraged to review this section.
Before a message can be sent to a DDO, its handle must be obtained. Typically, this is done by moving the object’s ID to a handle and using that variable as the object ID.
Move oSomeObject to hoHandle
Send MyMessage of hoHandle
This method works quite well within methods inside WBOs. You define a local handle variable, move your DD object handle into this variable, then send all your DDO messages using this variable. The following example demonstrates how this is done.
Function LoginUser String sCustNo String sLoginName Returns integer
Boolean bLoginOK
Handle hoDD
Move oCustomer_DD to hoDD // move object ID to handle variable
Send Clear of hoDD
Move sCustNo to Customer.Customer_Number
Move sLoginName to Customer.Login_Name
Send Find of hoDD EQ 4
Get HasRecord of hoDD to bLoginOK
Send Clear of hoDD
Function_Return bLoginOK
End_Function // LoginUser
Alternatively, you can send the message directly to the object as follows.
Function LoginUser String sCustNo String sLoginName Returns integer
Integer bLoginOK
Send Clear of oCustomer_DD
Move sCustNo to Customer.Customer_Number
Move sLoginName to Customer.Login_Name
Send Find of oCustomer_DD EQ 4
Get HasRecord of oCustomer_DD to bLoginOK
Send Clear of oCustomer_DD
Function_Return bLoginOK
End_Function // LoginUser
See Sending Messages to Objects for a comparison of these two techniques. You will find that the sample applications use both techniques.