Class methods and Creating methods in SAP classes

Creating a method in SAP Classes using Object Oriented ABAP programming

A+ A-

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.

Creating a method in SAP class

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).

Creating a method in SAP class

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.

Creating a method in SAP class

This is how we create methods in SAP classes, we will learn some advanced concepts of using methods in next lessons.

Learner Questions

No Questions by learners, be first one to ask ..!!

    Please Sign in to ask a question

    Was this lesson helpful to you? Yes No 176 People out of 178 think this lesson helpful

    Lesson Navigation

    Introduction and Concepts of Object Oriented ABAP← Previous Lesson
    Next Chapter →