Start of Content Area

Syntax documentation Type Definitions  Locate the document in its SAP Library structure

The data roots that are used in an ST program can – but do not have to be – assigned type specifications. As a rule, types from the Repository (ABAP Dictionary, types of global classes) are used, although you can make type definitions in the ST program. An ST program outside of a template can contain one or more definitions of types with statement tt:type. The syntax is:

 

<tt:type name="..." [[line-]type="..." [length="..."] [decimals="..."]]
  [extensible
=extensible_flag]>
  [<tt:front>
     <tt:node name="..."
[[line-]type="
..."
[...]]
       [extensible
=extensible_flag]>
       [...]
     </tt:node>
     ...

  
</tt:front>]
  [<tt:node name="..."
[[line-]type="..." [...]]
     [extensible
=extensible_flag]>
     [...]
   </tt:node>
  ...]
</tt:type>

 

The attribute name declares a symbolic name, with which the defined type for typing data roots and in other type definitions can be used.

Elementary, structured and tabular types can be defined that can be partly or completely generic. Moreover, the reference to globally defined data types of the Repository and to types of the same ST program that are defined using tt:type is possible.

Namespaces

The following XML namespaces in asXML format have to be used to specify types from the Repository and the same ST program:

     http://www.sap.com/abapxml/types/dictionary identifies the ABAP Dictionary.

     http://www.sap.com/abapxml/types/type-pool/name identifies the type group name.

     http://www.sap.com/abapxml/types/class-pool/class identifies the global class class.

     http://www.sap.com/abapxml/types/defined/name identifies the type that is defined in the current ST program with tt:type.

The type name that is specified in [line-]type then has to have the form p:NAME, where the namespace prefix p has to be bound to one of these URIs and NAME is the name of the actual type in uppercase letters. p therefore specifies where the type is defined.

Definition of Elementary Types

For the definition of elementary types, elementary ABAP types C, D, F, I, N, P, STRING, T, X or XSTRING (in uppercase letters) are specified for the value of attribute typeafter tt:type or tt:node.

For types C, N, P and X, the length can also be specified in attribute length, and for type P the number of decimal places can be specified in attribute decimals. If decimals is specified without length, then decimals has no effect. If length or decimals are not specified, then length and decimal places are generic.

C without a length specification corresponds to the generic ABAP type csequence, that is, it includes c with any length and string. The same applies to X without a length specification and xsequence.

The name of an elementary type from the Repository ort he ST program can also be specified fort he value of attribute type.

Definition of Structured Types

Statement tt:node as an element of tt:type is used to define structured types, where the name of a component is determined by the value of attribute name and its type is determined using the value of attribute [line-]type. Statement tt:node, which is an element of a different statement tt:node, defines a substructure. Element tt:type or tt:node, which contains subelements tt:node, must not contain any type specifications except [line-]type="?". In this case, line-type="?" is used to define a tabular type with a structured line type.

The types of a component can be structured as elementary (see above), tabular (see below) or via a reference to a structured type of the Repository or the ST program itself using type specification [line-]type after tt:node.

The type of a component can be partly or completely generic. In addition, a structured type is generic by default in terms of the number and sequence of its components. This means that a data root that is typed with a structured type can be bound to an ABAP structure that contains the specified components in a different sequence and/or additional components.

To write the number and sequence of the components of the initial part of a structured type or the whole structured type permanently and without gaps, the corresponding component definitions tt:nodecan be listed as subelements of statement tt:front. Statement tt:type or tt:node may have exactly one tt:front statement as the first subelement.

To restrict the number of components in a structure to the components that are defined in the ST program, you can use the extensible attribute of statements tt:type or tt:node. The following values can be specified for the attribute:

 

... on|deep|off|deep-off″ ...

 

The value on states that the current element may have direct subelements that are not explicitly specified. The value deep states that the current element and its subelements are extensible. This is the standard setting. With the value off, the extensibility is deactivated for the current element but not its subelements. In other words, it cannot be extended by direct subelements, although its (specified) subelements can be. The value deep-off switches off extensibility for the current element and its subelements. These settings can be overwritten locally in individual subelements.

Definition of Tabular Types

Attribute line-type after tt:type or tt:nodeis used for the definition of tabular types. This attribute defines the type or the component as a table of the line type that is specified as the attribute’s value.

Elementary types (see above) or any Repository or ST program types can be specified as the line type. A structured line type can also be declared by specifying "?" as the value of line-type. If the current element then contains tt:node statements as subelements, then these define the line type’s components.

The line type of a tabular type can be partly or completely generic. The latter is defined by making the type specification line-type="?" without defining components using tt:node.

Definition of Generic Types

All types whose properties have not been fully defined are generic in terms of the missing properties.

     A type is completely generic if the attribute type is either not specified at all, or is specified with the value "?". The specification type="?" has the same meaning if there is no specification, although it should always be specified so the program is easier to understand. line-type="?" is also required to define a tabular type directly with a structured line type.

     An elementary type N or P is partly generic if the length is not specified, or if decimal places are not specified for P.

     Individual components can be generic in structured types and the number of components is also generic.

     Tabular types can be partly or completely generic in terms of the line type.

Example

The type T1 that is defined below is a structure containing at least component C, which is an internal table whose line type contains at least components C1 (with Dictionary type DDT1) and C2 (with defined type T2). Structure type T2 contains component D whose subcomponent D1 is an internal table with any line type.

<tt:transform xmlns:tt="http://www.sap.com/transformation-templates"

 xmlns:ddic="http://www.sap.com/abapxml/types/dictionary"
 xmlns:def="http://www.sap.com/abapxml/types/defined" >

  <tt:type name="T1">
    <tt:node name="C" line-type="?">
      <tt:node name="C1" type="ddic:DDT1"/>
      <tt:node name="C2" line-type="def:T2"/>
    </tt:node>
  </tt:type>

  <tt:type name="T2">
    <tt:node name="D">
      <tt:node name="D1" line-type="?"/>
    </tt:node>
  </tt:type>

 

 

End of Content Area