Thunder Special Fields

XML and JSON Thunder make use of “special fields” to:


Thunder provides 5 special fields.


A special field exists in the program data fields (IDS) that make up the API into the Handler, but they do not exist in the XML structure. Below is an IDS containing all 5 special field types.

Image

Counter Field

The counter special field is used to control repeating structures. A counter field is automatically inserted into the IDS for each repeating structure in the Handler Design. The counter field is:


Optional Flag Field

When the Optional Flag Field property is set to “true” for a node, then the generated IDS will contain an additional “flag field” that is associated with the node. This property can only be set for non-repeating optional nodes. For an optional repeating node, the count special field can be used. An optional flag field is:


Length Field

The length field is used to control the length of a variable length field. If the variable length property is set to “true” for a node, then a length field is automatically inserted into the IDS for the corresponding program data field. The length field is:


Track Pointers

Track Pointers are used to indicate the start position of the open tag and the end position of a closing tag for a node.  If the Track Pointers property is set to “true”, then 2 fields (one for the starting position and one for the end) will be automatically inserted in the IDS for the corresponding program data field. Track pointers are only used by Readers.  The Reader will return the start and end position of the particular JSON/XML node.

Extended Precision

The extended precision special field is used by a Writer to control the decimal precision for a numeric field containing decimals. When the property is set to “true”, an extended precision field is automatically inserted into the IDS and the original field is converted to an integer definition (with no decimal places). For example, a field with a COBOL declaration of PIC 9(11)V9(2) will convert to two fields:
The extended precision field is returned by a Reader to indicate how many decimal positions were found in the document.

%%%%EditSectionPlaceHolder%%%%

Turning Special Field Settings On»

Special fields can be controlled at the Toolset level, Handler level and node level. The Count special field is always added to a Handler for repeating structures. All other special fields can be turned on or off.

Toolset Level

Toolset level settings apply to all new handlers that are created. Changing a toolset setting does not affect Handlers that have already been created. There are two special fields that can be set as toolset defaults – Optional Field Flags and Extended Precision fields. These can be set by going to Tools -> Default Properties - > Code Generation -> General.

Image

Handler Level

Handler level settings apply to the currently opened handler. Changing a Handler setting changes the default settings for the Handler. The special field settings that can be changed are extended precision and Optional Flags. This is done by going to XML Handler -> Properties -> Code Generation -> General

Image

Node Level

Node level settings apply only to the selected XML/JSON node. The Variable Length, Optional Flag and Track Pointer special fields can be selected at the node level. This is done by selecting a node and changing the setting under Generation Settings.

Image



%%%%EditSectionPlaceHolder%%%%

Generating Special Fields to a Separate Area in the IDS»

Thunder allows you to control how the special fields are generated into the IDS. By default, they are generated directly above their associated field as shown below.

Image

If desired, Thunder provides a setting to generate the special fields to a separate area in the IDS. This can be set at the Toolset or Handler level.

To generate special fields to a separate area at the Handler level, go to Handler -> Properties -> Code Generation and choose “More Options”

Image

You can also do this from the Code Generation panel (you need to check “copybook” to enable “More Options”)

Image

Change the Special field setting to “Generate as a separate structure”.

Image

The result will be that that the special fields will be generated to their own separate 01 level in the IDS.

Image

%%%%EditSectionPlaceHolder%%%%

Summary»

Thunder Special Fields can be used for greater program control over XML / JSON messages. For more information about Thunder Special Fields, please contact us at support@canamsoftware.com