Structured Data Type editor

As you may already know, the Structured Data Type is the GeneXus object for defining complex data structures.

But, how and where do we define the structure of this object?

By using the SDT Editor. In order to display this editor, we need to create a new SDT object, or just open an existing one.

While creating a SDT object, you may define a multilevel structure, quite similar to the transactions structure. Each level can have one or more members (elements or items). These members may be classified into:

While working with SDTs you can define some properties related to each kind of element, in order to have control over the SDT serialization to different formats, such as XML. When working with a simple element (a member) you will see the following XML properties:

XmlType

XML Namespace

These properties allow you to have control over the XML that will be generated.

XmlType Property

This property may have one of the following values:

Element: Is the default value. The element (member) will be serialized as an XML Element.

Attribute: The member will appear as an XML attribute but in the last level of the parent element.

CData: The member will be serialized as an element with a CDATA. It is usually used with values that contain XML.

Compound elements have the same properties as do simple elements, but the Data Type property is not enabled.

In the following example you can see a Structured Data Type named Customers with some simple and compound elements:

Now look at the corresponding Properties windows:

When a substructure defines a collection, besides the data type created with the SDT name, there will be another data type created with Name.SubstructureName, and they will be selectable as data types in any variable definition. This means that two data types will be created. Following with our example, while defining variables in a procedure, you may see:

Let's stop and take a look again at the image of the Collection properties window. Can you see the Collection Serialization property?

The purpose of this property is to help solve the problem of how to serialize a collection. Its possible values are:

Locate in Folder View: Shows you where the SDT object is located within the Folder View.

Note: When you need to insert a new member in the structure, you may use the corresponding option in this secondary menu shown above, or you may also drag the attribute to the structure. Look at the following image:

Another method for inserting members in the SDT structure is to use the Insert Menu from the GeneXus main toolbar.
The available menu options are :

Insert Attribute : inserts a member with the same name and with type based on the selected attribute

Insert Domain : inserts a member with the same name and with type based on the selected domain

Insert Object (only transactions can be selected) : inserts one member for each attribute in the transaction structure, with the same name and type based on it. Note: If the description of an attribute of the transaction changes, it also changes in the SDT structure (as since GeneXus 15 upgrade 3).

If the focus is on the SDT structure root, the new members added with the Insert menu will be placed on the end of the structure, if the focus is on one existing member, the new member will be added inmediately after the selected one.

By working with the SDT Editor you may define collections as shown in the following image:

However, you will not be able to define a collection based on any Data Type (Numeric, Character, another SDT data type, BC, etc). In order to solve this situation you must work with Collection Domains, or you may even define a Collection Variable based on the corresponding Data Type, as shown below.