Get Example source ABAP code based on a different SAP table
ID METHOD • METHOD ABAP Statement
METHOD> Short Reference >
ABAP_SYNTAX METHOD meth.> ...> ENDMETHOD.>
What does it do? Between the statements METHOD> and ENDMETHOD> , the functionality of a method> meth> declared using $[CLASS-$]>> METHODS>> is implemented in a class. The implementation of a method is only possible in an implementation part of a class that was initiated using CLASS class IMPLEMENTATION>>. Local data types and data objects can be declared within the method. It is also possible to access the formal parameters of the method as well as all components of all instances of its own class. In instance methods>, all components of the class and instance of the method can be addressed explicitly using the self-reference> me->>, besides their names. In addition, all components of other instances of the class of the method can be addressed using reference variables. A method can be called statically> or dynamically>. For static calls, there is a standalone and a functional call form. Dynamic calls are always standalone calls.
Latest notes:
During the implementation of a method of an interface intf>, either the name declared in the prefix with intf~> or an alias name of the class defined with ALIASES>>, can be specified for meth>. The method must exist in the interface, otherwise a syntax error occurs. If intf~> is used, a syntax warning occurs for global interfaces only if an unused methods is deleted from the global interface, so that initial classes do not immediately become invalid because of this.
The addition BY DATABASE PROCEDURE> > transforms a method that is implemented in a database-specific language and not in ABAP and is executed in the database system into an AMDP method>. NON_V5_HINTS ABAP_HINT_END
ABAP_EXAMPLE_VX5 In this example, the two methods m1> and m2> of the class c1> between METHOD> and ENDMETHOD> are implemented. Although the local data object a1> hides the attribute of the same name, the attribute a1> can be addressed using me->a1>. ABEXA 00412 ABAP_EXAMPLE_END