The REFORMAT function returns a type object that results from replacing the syntax of the input type with the syntax of the output type.

The initiator and terminator of the output type are built. The content result rules are determined based on the Input type and the Output type. Groups and Items can be used with REFORMAT.

REFORMAT cannot be used as an argument to a function, operator, or functional map.

REFORMAT (single-object-expression)
REFORMAT (type-to-convert)
A type object

REFORMAT returns a type object whose content matches the input type object, but whose syntax matches the output type object. The following table details the expected results based on the input and output.

Input Type Output Type Result
Group Group The content for each output component results from the content of the corresponding input group component content. For example, output component 1 is matched with input component 1, output component 2 is matched with input component 2, and so on. The components of the groups must be items, not another group. If there is no matching input component for an output component, the output component's required occurrences are built as "none"S. If there is no matching output component for an input component, the data of that input component is ignored.

When a component occurrence is built, the delimiter (if any) of the contained output group is built and an object of the component's output type is built from the corresponding input type using the REFORMAT algorithm.

Group Item The text of a corresponding input group content.
Item Group The input item content is applied as though it were the first component of the output group.
Item Item The input item content is applied to the output item content.


  • MyXMLPurchaseOrder = REFORMAT(MyCOBOL_PurchaseOrder)

    This function is useful when the same type structure might come from different type trees, such as different versions of the same EDI, or when converting traditional formats to XML.