What is a method in a Class ?
Methods are coding blocks of a class, which can provide some business functionality (ex: read material data etc), these methods are similar to Function Modules.
Methods can access all attributes of a class (defined under attributes tab), can access user defined types ( declared under types tab).
The methods can be called using key word CALL METHOD in SAP ABAP programs.
Uses of methods in SAP classes?
These methods can be reusable in multiple ABAP programs, a class may contain more than one method.
We will define methods under methods tab of a class, to define a method provide a method name, level( instance or static), visibility (Public,Private,Protected) and method description.
The importing and exporting parameters of a method will defined under parameters area.
Add a method, click on parameter button and you will go to parameter interface where you can add parameters to a particular method. (Parameters are method specific).
To write source code, click on methods tab and double click on method name (METHOD in the above example), you will go to source code editor where you can add code.
This is how we create methods in SAP classes, we will learn some advanced concepts of using methods in next lessons.