Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  Declarations →  Declaration Statements →  Data Types and Data Objects →  Declaring Data Types →  TYPES →  TYPES - BEGIN OF MESH mesh_type 

TYPES - association

Short Reference

Other versions: 7.31 | 7.40 | 7.54

Syntax


... ASSOCIATION to_node TO node ON tcomp1 = scomp1 
                              [AND tcomp2 = scomp2
                              [AND ... ]]
                              [USING KEY key_name] ...

Extras


1. ... ON tcomp1 = scomp1 [AND tcomp2 = scomp2 [AND ... ]]

2. ... USING KEY key_name

Effect

Defines an association named to_node for a mesh node of a mesh type. Addition ASSOCIATION to TYPES can only be used in the definition of a mesh type between TYPES BEGIN OF MESH and TYPES END OF MESH. The mesh node, for which an association is defined, is the start node. The mesh node node specified after TO is the target node. Any node in the current mesh (including the start node) can be specified as the target node node. An association where the start node and target node are the same is referred to as a reflexive association.

The name of an association cannot be longer than 30 characters. It can only contain letters A-Z, numbers 0-9 and underscore "_" characters, and cannot begin with a number.


Notes

  • The associations defined for a mesh node are evaluated in expressions and statements for meshes in mesh paths.
  • It is not mandatory to define a target node before the start node to make the target node visible. However, the Code Completion function of the editor will only work properly if the target node is defined before the start node.
  • The prefix to_ is recommended as the naming convention for associations. The name that follows this prefix should contain the target node name (in non-reflexive associations). This convention makes it easier to read the mesh path.

Addition 1

... ON tcomp1 = scomp1 [AND tcomp2 = scomp2 [AND ... ]]

Effect

For every association, a condition must be specified after ON that consists of at least one comparison for equality. Additional comparisons for equality can be added using AND. The left operand tcomp of every comparison must be a directly specified column of the target node. The right operand scomp must be a directly specified column of the start node and this column must be compatible with the column of the target node.

An association represents the relationship between the start node and target node. It assigns all the rows of the target node, which fulfill the condition, to a row of the start node.

The associations are pure type properties and therefore affect the compatibility of mesh types. Associations are evaluated in mesh paths in expressions and in statements for meshes.


Notes

  • In the ON condition, the target node components are on the left and the start node components are on the right. This is the same as in other statements and expressions for internal tables, where the columns of the table to be searched are always listed on the left.
  • As a general rule, the target node components listed on the left of an ON condition should be key fields of the table key used for the condition. This ensures the best possible system performance when accessing data.

Addition 2

... USING KEY key_name

Effect

Using the addition USING KEY, a table key of the target node can be specified for the ON condition of an association. The target node is the one used in expressions and statements to evaluate meshes for accessing the mesh node:

  • a secondary key using its name
  • a primary key using its predefined name primary_key or using an alias. If the primary key is specified, the target node must be a sorted table or a hashed table.

The name of the table key must be specified directly. In other words, it cannot be dynamically specified in a data object. If the table key is explicitly specified, the ON condition must be defined to allow optimal key access.

  • If a sorted key or the primary key is specified, the conditions specified after ON must cover an initial left part of the key fields in the target table.
  • If a secondary hash key or a primary key of a hashed table is specified, the conditions specified after ON must cover all key fields in the target table.

If addition USING KEY is not specified, the primary key is used to access the mesh node, which means that access is not always optimal.


Note

When the association is used in a mesh path, the table key specified in the definition of the ON condition can be overridden by specifying USING KEY in an additional condition. In this case, the ON condition and the additional condition are combined to make one single condition, which must fulfill the above prerequisites.