Domains

Domains are reusable data definitions that store basic features of a specific control, table field or database column. In this section aims to introduce domains and its usage.

What is Domain?

In large business applications, programmers have to use numerous text fields, table columns to store, read and show same kind of data for different table and forms. So they have to make same metadata definitions like length, formatters, description texts etc. in different forms and tables. For example, assume a textfield that stores/shows “customer name” information on an invoice document. Most probably, we must have same “customer name” fields in your related data tables and a “customer name” field in our printable invoice report. More importantly, there are tens of “customer name” field in your other dialogs, reports of your other transactions. All this fields have same metadata definitions to have identical behaviour and appearance.

In a large business application scenario; if we can not overcome such a problem it dramatically increases our development and maintenance cost. It is not easy to find and modify some features of all controls that handles “customer name” in whole application interface. Briefly, it is a must to deal with this hard problem for an enterprise level programmer to reduce development and maintenance costs.

It is very hard to manage such a problem in an efficient way. The most common way to overcome this problem is developing and using, reusable custom types, components. Even more, that is the only way for the programmers who the mostly used programming languages.

Domain Data

The first type of domain data is mostly used for database fields and ui controls. All this information is same for all the database fields and controls that share same domain data. In other words, if you change one of these information, all fields and controls starts to use the new data in those related features after a simple convert/save and table convert operation in ODBA.

Field Name

It is just a guide for developers for naming table columns, it is not used by TROIA interpreter

Field Type

Stores data type ODBA or virtual table column that extend this domain. It is used on runtime to create dynamic form controls.

Def Sub Type

It is control sub type for dynamic controls. It is used on runtime to create dynamic form controls.

Field Length

Stores field length for ODBA or virtual table column. (for only valid types like string (varchar)). It is used on runtime and convert time

Field Decimal

Stores number of decimal digits for ODBA columns that extend domain. It is used on runtime while appending domain related column.

Check Table / Zoom Dialog / Zoom Field / Zoom Filter

Stores related zoom information for zooming operations. They are used on runtime for dynamic form fields and on convert time while setting zoom information of domain related textfields

Read/Zoom Only

Shows ui control or table cell is read only or zoom only. It is used on runtime for table fields/dynamic form controls and on convert time

Case Sensitivity

Shows ui control or table cell is upper case/lower case. It is used on runtime for table fields/dynamic form controls and on convert time

Field Picture

Stores required data for virtual table column information, for columns that extend domain. It is used on runtime for table fields/dynamic form controls and on convert time

Set-Get Id

Stores setgetid, for textfields. (Enabling/disabling “set” and “get” are configured for each control. It is used on runtime for table fields/dynamic form controls and on convert time

SLabel / MLabel / LLabel

Stores label data for domain related controls. Domain related controls contains a flag data to select appropriate label between these labels. They are used on runtime for dynamic form fields and on convert time while setting zoom information of domain related textfields.

HLabel

Header label for domain related table columns. It is used on runtime for dynamic table fields and on compile time for tables that has static column info

Options

Option values for combobox type domain related table fields and dialog controls. It is used on runtime and on compile time

Tooltip (FYI Text)

Tooltip Texts for controls and columns. It is used on runtime and on compile time

All these information can be overridden by the programmer for specific controls, ODBA fields and virtual table fields. To use values defined in domain string values must be defined as {D} and integer values must be defined as -10, otherwise values given in control, odba table or virtual table overrides the value that comes from domain. These {D} and -10 values are special values that are also used while inheriting domains from some base domains. We will discuss it, in next titles.

Domain Codes

Regular Event Codes

It is also possible to define some regular event codes on domain instead of defining them for each control. So, when it is needed, if programmer change the code defined for domain, this change affect behaviour for all control events whose control uses the domain.

Codes defined in domain affect all controls that don’t have a corresponding event implementation on control level. This means that there is no need to add a {D} like wildcard. And also it means, it is possible to add alternative behaviors for controls that extend same domain, on different dialogs and forms and components.

TEXTCHANGED, ZOOMBEFORE, ZOOMAFTER, LOSEFOCUS, GAINFOCUS, RIGHTCLICKMENU, DRAG , DROP, PASTE are the events that programmers can define on a domain. For more up to date list of events for a domain, please see actual domain definition transaction that we will discuss in next sections.

All domain codes used on runtime for dynamic form fields and table columns and convert time for dialog components related with domains.

Transfer Codes

In some special cases, programmers may need to store data in different formats on server and client side. Domain has two codes to transform data while transferring it between server and client. These codes are “CLIENT TO SERVER CODE” and “SERVER TO CLIENT CODE”. While implementing these functions you must be careful that they must be inverse functions of each other, otherwise there will be data loss risks during data transfer.

Here is two sample functions for transferring a decimal value. In this example, unit in the client is kilometers and unit in the server side is meter, so “SERVER TO CLIENT CODE” converts meter to kilometer.

/* SERVER TO CLIENT CODE */
PARAMETERS:
        DECIMAL PARAM;,

RETURN PARAM * 0.001;
/* CLIENT TO SERVER CODE */
PARAMETERS:
        DECIMAL PARAM;,

RETURN PARAM * 1000;

Transfer codes can be used with all data types such as decimals, integers, strings etc, but parameter type and return type must same with the variable type of the domain.

Validation Code

Validation code must get a parameter with same data type of variable. After checking data validity it must return 1 for valid values, and 0 for invalid values. Here is a sample validity code just checks whether given value is greater than 0.001. It is also possible to use database operations to check data availability in database.

/* VALIDITY CODE */
PARAMETERS:
        DECIMAL PARAM;

/* do validation check and return 1 or 0 */

RETURN PARAM > 0.001;

Defining Domains

To define domains you must use “DEVT10 System Domains” transaction. With this transaction it is also view and manage existing domains.

For more information please see transaction documentation.

How are Domains Stored?

Domains are stored on database tables. Here are the database tables that TROIA Interpreter reads domains.

SYSDOMAINS

Stores domain information.

SYSDOMAINSX

Domain description for different languages. This table is for documentation purposes and is not read by troia interpreter.

SYSDOMAINSTXT

Stores texts of domains such as captions, field pictures or column header labels.

SYSDOMAINLINK

Links for the domain.

SYSDOMAINLINKX

Link texts for the domain.

TROIA Interpreter reads domain data both on compile process and on runtime for dynamically created table fields and dynamic form components. So it is very important to have all and up to date domain information both on live and development environments.