Operands can be elementary or made up of components. Composite operands are:
Accordingly, labels for operands are either elementary names or grouped from several names separated by component selectors. An elementary name is used for addressing:
Naming conventions apply for the elementary names. Composite names with component selectors are used for addressing individual components. A component can itself be a superunit of further components. Subcomponents can be addressed through concatenation of several names.
A component comp of a structured data type or a structure struct is accessed using the label struct-comp. In this case, the character - is the structure component selector. The label struct of a structured data type or a structure must be to the left of the structure component selector. The label struct can be combined itself. The name comp of the component must be to the right of the structure component selector.
Declaration of a structure struc with the structured data
type spfli from the ABAP Dictionary and access to their
component carrid. DATA struc TYPE spfli.
...
... struc-carrid ...
The label ref->comp is used to access a component comp of an object. The character -> is the object component selector. The label ref of a reference variable must be to the left of the object component selector. The label ref can itself be combined. The name comp of the component must be to the right of the object component selector. If an attempt is made to access an object component with a reference variable that contains the null reference, an exception that cannot be handled occurs. Dereferencing of a data reference in the statement ASSIGN is an exception to this.
The object component selector dereferences the reference variable ref and makes the components of the referenced object accessible.
If ref is an object reference variable, the components comp of the object (attributes and methods) to which the object reference variable points are addressed using the object component selector.
If ref is a data reference variable that is typed as a structure, the components comp of the structure to which the data reference variable points are addressed using the object component selector - as of Release 6.10.
If ref is a data reference variable, the character * can be specified after the object component selector ->. Through this, the general dereferencing operator ->* is created. The expression ref->* labels the entire data object to which the data reference variable points. The dereferencing operator is the only way to dereference data references. Prior to Release 6.10 and in the case of untyped data reference variables, this was only possible using the statement ASSIGN. After object reference variables, the dereferencing operator cannot be specified. The instance components of classes can only be accessed using the expression ref->comp.
Access to the public attribute a1 of a class c1 through an object reference variable oref.
The data reference variable dref is typed as a structure and the component carrid of the referenced structure is accessed using the object component selector. The expression dref->carrid has the same meaning as the concatenation dref->*-carrid.
The label
class=>comp
can be used to access a static component comp of a class without an instance of the class having to be created. The character => is the class component selector. The label class of a class must be to the left of the class component selector. The name comp of the component must be to the right of the object component selector.
The class component selector can also be used to access the data types and constants of an interface.
intf=>type, intf=>const
The label intf of an interface must be to the left of the class component sector. The name type of a data type defined with TYPES or a constant defined with CONSTANTS must be to the right of the object component selector.
It is also possible to access the static components of a class using the object component selector if an instance of the class was created.
Declaration of a class factory and access to its static attribute oref.
The label
intf~comp
is used to access a component comp of an interface. The character ~ is the interface component selector. The label intf of an interface must be to the left of the interface component selector. The name comp of the component must be to the right of the object component selector.
The label intf~comp identifies the components of interfaces in classes or component interfaces in combined interfaces.
An interface contains each component exactly once - regardless of its combination of component interfaces. All the interface components are at the same hierarchical level. The name of an interface component is uniquely defined through intf~comp. intf is always the interface in which the component is declared. A direct concatenation of interface names intf1~...~intfn~comp is not possible.
Declaration of interfaces and access to their components.
Whenever operands are grouped together from components, which in turn contain components, the labels of these components are set up from concatenations with several component selectors. The following rules apply:
The labels to the left of each structure component selector must, as a combined group, address a structured data type or a structure.
The labels to the left of each object component selector must, as a combined group, address a reference variable.
The class component selector can occur in a label exactly once as the first selector.
The interface component selector can only occur several times in a label if other component selectors are listed between the individual interface component selectors.
Declaration of a nested structured data type struc2 in struc1 and a structure struc3 in an interface i1.
The component comp of struc3 is a data reference variable of the static type struc1. The i1 interface is the component interface of i2 und the latter is implemented in c1. In c2, a static attribute is declared as the object reference of the static type c1. The expression in the last line can be at an operand position that expects a data object, and labels the component comp of the structure struc2 in a concatenation that starts at class c2. A prerequisite for use of the expression is that both reference variables, oref and dref, point to the respective instances.
The character ! can be written directly before a name in order to distinguish it from an ABAP word of the same name in a statement. With the exception of the first word, each word of a statement that is preceded by the escape character is interpreted as an operand, and not as an ABAP word, in program generation. The escape character itself is not part of a name and is ignored when the statement is executed.
The escape character may be required on rare occasions in which the compiler cannot tell the difference between an operand and a reserved word of the same name. Otherwise, it can be used for the documentation of operands in the source code.
Without the escape character ! before CHANGING after USING, the following program extract would be syntactically incorrect, because a formal parameter must be entered after USING. Although the second escape character is not necessary, it serves to document USING after CHANGING as a formal parameter.