You will use the Clear or Clear_All messages to clear DDOs. The Clear message will clear the DDO and all connected parent DDOs. If parent DDOs have a relates-to constraint between them the clear activity will be blocked by the constraint (i.e. the parent and any of its parents will not be cleared).
Clear_All unconditionally clears all DDOs in a structure.
After a Clear or Clear_All any attached DEOs will be notified of the change.
A Clear performs the following steps:
Clear main DDO and all Parent DDOs on up the Parent DDO tree (Clear_Main_File).
If a relates-to-constraint is in effects stop the upward clear propagation
If a related-to child exists, clear the child (Clear_Main_File) and all of its parents.
Send OnNewCurrentRecord to all cleared DDOs
Send Refresh to all DEOs attached to DDOs that were cleared
A Clear_All performs the following steps:
Clear every DDO in the structure (Clear_Main_File).
Send OnNewCurrentRecord to all cleared DDOs
Send Refresh to all DEOs attached to DDOs that were cleared
A clear operation may be programmed within a Web Object or Business Process object as follows:
Function ClearUser Returns integer
Handle hoDD
Move oCustomer_DD to hoDD
Send Clear of hoDD
End_Function // SearchUser
The clear operation is often combined with other operations.
Function FindUser String sCustNo Returns RowId
RowId riRecId
Handle hoDD
Move oCustomer_DD to hoDD
Send Clear of hoDD
Move sCustNo to Customer.Customer_Number
Send Find of hoDD EQ 1
Get CurrentRowId of hoDD to riRecId
Function_Return riRecId
End_Function // SearchUser
The above sample shows how to use clears in batch processes. The Clear and Clear_All operations are built into Data Entry Objects allowing the user to direct the operation. A Clear (or Clear_All) is started when the user a presses a key (F5), clicks on a button or selects a menu option. This sends the message Request_Clear (or Request_Clear_All) to the DEO. The DEO will then
Checks if any changes exist, and if they do, verify a data-loss condition
Send Clear (or Clear_All) to the DDO
Below is an example of a simplified DEO Request_Clear procedure. These are the types of methods and functionality built directly into DEOs.
// The DEO Clear Process
Procedure Request_Clear
Handle hoDDO
Boolean bChanged bError
Get Server to hoDDO
Get Should_Save of hoDDO to bChanged // are there changes?
If bChanged begin
Get Verify_Data_Loss to bError // do we really want to clear?
If bError Procedure_Return // user decided not to clear
End
Send Clear of hoDDO // this will clear and notify all DEOs
End_Procedure
Find and Clear Operations in DDOs