Monday, September 17, 2018

CALLING INTERFACE METHOD IN YOUR PROGRAM.

INTERFACES:-It is similar to normal class but it contains only method definition it does not contain implementation of those methods.
it basically provides skeleton for class which implements it .You cannot create  object for the interface.
You can use it as a reference for class which implements it.

steps for creating interface:

Go to se24 , write the name of your interface , it must start with ZIF , it tells the system that this is an interface.







then fill in the details





now create the method  you want , for example i have created 2 method to get material by number and get material by description .



now click on parameters and  fill the details  :







for the second method








Then , we activate it.
 
Now we will create class to implement the method of interface


Then go to interface , write the name of your  interface , you will see that in the method section, you could see the 2 method you defined in interface .


 

The two methods are as follows :
 
Now double click or click on code to write the logic in the method .

Now the second method logic,

Now activate the whole class.

Now go to se38 and create a program ,


NOW CALLING THE MATHOD, GO to pattern ->abap object pattern->call method  and write the following things:

Now activate the whole program and execute it ,


Then the final output is :