One way of creating a derived field is simply creating one in your Operation Code. The standard used in WOW for creating derived fields is starting the field name with “D_”. This is a great way to spot a derived field immediately in your SQL code or running Operation.
An example of creating a derived field for my Employee table would be if I created a field called “status”. “Status” will represent if the employee is currently employed still or is no longer with the company. To do this I will write it as such: D_STATUS. After creating the derived field in the Operation Code as in the example below:
example: create derived field
The derived fields will be easily recognizable in the running Operation because it will have a red FD icon. The next step is to click on the red FD icon to create the derived field descriptor.
example: derived FD icon in red
Once I click on the red FD icon, a Message Box will appear as such:
example: Message Box to create derived field descriptor
Next, you click the OK button.
After you click the OK button, it will open up the derived field descriptor page so that you can further edit this field if you wish to do so at this time.
example: derived FD page opens
When you are done, simply click the Insert button in the top right corner. Once you are finished, the descriptor page will close for this derived field. Now it is set up to be manipulated just like any other field so that the next time you click on the red derived FD icon, it will open up the descriptor page for this derived field. Here I will change my external name to something more appropriate for the end user view.
example: change external name to end user appropriate name
Creating the descriptor for this derived field will allow you to assign its default values, associations, field classes, and so on. A derived field descriptor differs from a normal field descriptor in really only one way: its Field Descriptor Type is set to ‘Derived’. This allows WOW to handle it appropriately. Also, a field descriptor for a derived field will not automatically generate by clicking the ‘Create FDs’ button in the Field Descriptor Manager. Thus, you must manually create derived field descriptors.
The easiest way to do this is to simply copy another field that is of the desired data type. For instance, if your derived field was a calculation that returned a decimal number, you would copy an existing field descriptor for a field of type DECIMAL or NUMERIC. To continue our example from the previous section, here are the steps to creating a derived field descriptor for D_DETAILS:
Create a Field Descriptor
Since the only value that D_DETAILS will hold is the string 'Details', a good field descriptor to copy (rather than creating one from scratch) would be a simple CHAR field. Now, navigate to the Database Settings section of this new field descriptor and change the values to reflect those shown in the figure below. In particular, the Library and Table Names are the same as specified in the SQL statement listed above. Also, SQL Type and SQL Type Name specify the CHAR field type and the Column Size is 7 since we only need 7 characters (ie. Details).
Set the Field Descriptor's Settings
Besides the Database Settings given in Step 1, there are two other Field Descriptor settings that are key to success. The first is the Field Name field under the Basic Settings section. In this example, the Field name is D_DETAILS.
The second is the Field Descriptor Type under the Advanced Settings section. This must be set to ‘Derived’.
Update and Run Application
Click Update and run the application. If everything has been done correctly, the column label will say 'Details' rather than 'D_DETAILS'. This means the derived field has successfully been linked with the derived field descriptor and is picking up the External Name.
TAGS: logical fields, non physical fields