Skip to content

Local DD Relationships

Previous: Null Parent Support
Next: Better Alias Table DD Support

Table relationships can now be defined locally within a DD class or object. Any DD can now use global relates, which are defined within your table, or use the new local relates, which are defined within the DD. The pbUseDDRelates property controls this behavior. If local relates are used, you must define the relationships with a new message, Set Field_Related_FileField.

It is not expected or recommended that you replace all of your global relationships with local DD relationships. Usually, relationships are global and therefore they are best defined globally. Local DD relationships are useful when you need to define views that have special relationships. Until now, the best approach in dealing with these views was to reset the global relationships as you entered and exited the views, which was often done in Entering_Scope and Exiting_Scope. An alternate mechanism was to create alias tables that had custom relationships established when the table was opened. The use of local DD relationships should be a better approach than either of the above strategies.

Local DD relationships can be defined at the DD class or object level.

Local DD Relationship Interface

Get / Set pbUseDDRelates to bBool
Get / Set pbNoCascadeDeleteStrict to bBool
Set Field_Related_FileField iField to iRelatesToFile iRelatesToField
Get Field_Related_File iField to iRelatesToFile
Get Field_Related_Field iField to iRelatesToField
Send ClearDDRelates

Usage

This shows how you could create all local relationships in the order entry view. As mentioned, you normally would not want or need to do this, and this is shown as a sample only. You do not need to set all of the DDOs as done in this sample; you could actually set any single DDO in this example to use local relates.

Object Vendor_DD is a Vendor_DataDictionary
    Set pbUseDDRelates to True
End_Object    // Vendor_DD

Object Invt_DD is a Invt_DataDictionary
    Set DDO_Server to Vendor_DD
    // define local relationship
    Set pbUseDDRelates to True
    Set Field_Related_FileField Field Invt.Vendor_ID to File_Field Vendor.ID
End_Object    // Invt_DD

Object Customer_DD is a Customer_DataDictionary
    Set pbUseDDRelates to True
End_Object    // Customer_DD

Object SalesP_DD is a Salesp_DataDictionary
    Set pbUseDDRelates to True
End_Object    // SalesP_DD

Object OrderHea_DD is a OrderHea_DataDictionary
    Set DDO_Server to Customer_DD
    Set DDO_Server to SalesP_DD
    // define local relationship
    Set pbUseDDRelates to True
    Set Field_Related_FileField Field OrderHea.SalesPerson_ID to File_Field SalesP.ID
    Set Field_Related_FileField Field OrderHea.Customer_Number to File_Field Customer.Customer_Number
End_Object    // OrderHea_DD

Object OrderDtl_DD is a OrderDtl_DataDictionary
    Set DDO_Server to OrderHea_DD
    Set DDO_Server to Invt_DD
    Set Constrain_File to OrderHea.File_Number
    // define local relationship
    Set pbUseDDRelates to True
    Set Field_Related_FileField Field OrderDtl.Item_ID to File_Field Invt.Item_ID
    Set Field_Related_FileField Field OrderDtl.Order_Number to File_Field OrderHea.Order_Number
End_Object    // OrderDtl_DD

The pbUseDDRelates Property

Within any DD object, relates can now either be defined by the Table or by the DD. Until now, relationships could only be defined globally by the Table. A property named pbUseDDRelates determines if relates are defined by the Table (False) or the DD (True). By default, this is False, so relates are controlled by the Table and everything should work exactly as it does now.

If pbUseDDRelates is set to True, then relationships defined by the Table are ignored and you will set your own relationships within the DD class or object. If you do not set these, there will be no defined relationships. Local relationships are defined using the Set Field_Related_FileField message.

Set Field_Related_FileField Field OrderHea.Customer_Number to File_Field Customer.Customer_Number

A DD relationship is only respected by DD operations - in particular, the find operations (Request_Find, Request_Read, Request_Clear, etc.). Any finds that are performed outside of the DD (e.g., a find/relate performed with the find and relate command) are global commands and therefore they use the Table relationships and not the DD relationships.

At runtime, you are either using DD relationships or Table relationships, and this is controlled by pbUseDDRelates. You cannot mix these within a single DDO. For example, there is no automatic way to copy all of the Table relationships to the DD at runtime. If you are managing your relates within the DD, you must manage them all yourself (which is actually good because it gives you complete control over your environment).

This property is applied to a single DD class or object. Within a single DDO structure, you are allowed to use a mix of Table and local DD relationships.

The Set [Field_Related_FileField](../VdfClassRef/WebAndWindows/BaseData_Set-Property-Field_Related_FileField.md) message is used to define a local DD relationship. It sets a relationship for a field in your DD to a relating parent File.Field.

For example:

Set Field_Related_FileField Field OrderHea.SalesP_ID to File_Field SalesP.ID

This only applies to the local DD relationships. If pbUseDDRelates is false, these settings will be ignored and the global table relationships will be used instead. Therefore, it only makes sense to assign these relationships when pbUseDDRelates is true.

Field_Related_File and Field_Related_Field return the value of the local DD relationships and are similar to the API Get_Attribute commands for DF_FIELD_RELATED_FILE and DF_FIELD_RELATED_FIELD. They return the settings that have been assigned using the Set Field_Related_FileField message.

Note that this returns the values of the local DD relationships, which may not be the same as the current relationships. If pbUseDDRelates is false, this will still return the relationships defined locally, even if these are not the relationships currently being used.

Send ClearDDRelates

ClearDDRelates clears all local DD relationships, allowing you to start with a blank slate. This is a helper method which will be rarely used.

Compatibility Issues

By default, global table relationships are used and your applications should work without change. Again, note that we are not recommending that you change all of your table relationships to DD relationships. You should only do this as needed.

See Also

Data Dictionary Improvements 17.0