Local DD Relationships

Table relationships can be defined locally within a DD class or object. Any DD can use global relates, which are defined within your table, or use local relates, which are defined within the DD. The pbUseDDRelates property controls this behavior. If local relates are used, you must define the relationships via 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.

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

 

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

 

Object Customer_DD is a Customer_DataDictionary

    Set pbUseDDRelates to True

End_Object

 

Object SalesP_DD is a Salesp_DataDictionary

    Set pbUseDDRelates to True

End_Object

 

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

    

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

 

The pbUseDDRelates Property

Within any DD object, relates can either be defined by the Table or by the DD. 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.

If pbUseDDRelates is set 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.

Set Field_Related_FileField

The Set Field_Related_FileField 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

The 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.

Get  Field_Related_File / Get Field_Related_Field

This returns the value of the local DD relationships and is similar to the API Get_Attribute commands for DF_FIELD_RELATED_FILE and DF_FIELD_RELATED_FIELD. It returns 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 the relationships currently being used.

Send ClearDDRelates

This 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.