Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Class implementation for interface

Former Member
0 Kudos

Hello,

I am a beginner in ABAP Objects.

In the coding of method if_swf_ifs_workitem_exit~event_raised of class CL_SWF_UTL_EXIT_NEW

There is the instruction follow :

*Get the workflow container

irh_container ?= im_workitem_context-> get_wf_container()

Im_workitem_context is interface type "IF_WAPI_WORKITEM_CONTEXT"

If I execute in debug mode I see the implemtation class of this interface (im_workitem_context) is "CL_SWF_RUN_WORKITEM_CONTEXT"

But where this information of implementation is defined ? (I saw nothing)

Regards

Christine

Edited by: chris_75 on Sep 7, 2010 4:22 PM

4 REPLIES 4

Former Member
0 Kudos

This message was moderated.

uwe_schieferstein
Active Contributor
0 Kudos

Hello Christine

The first response to you thread is just nonsense or the replier neither read nor understood your question.

For me Interface programming represents the highest degree of object-oriented programming (of which I am still far away from).

In order to understand interface and how they are used you need to study the basics of OO-programming.

I try to give you a simple example based on the BAdI technology within SAP.

BAdIs are the most modern version of User-Exits and are usually represented by an interface which has to be implemented.

Implementing simply means you create one (or more) classes which include this interface.

Let's have a look at filter-dependent BAdIs. For each filter value (e.g. countries, DE, EN, US, etc.) you create a separate BAdI implementing class.

During runtime the system determines based on the filter value which of the classes has to be instantiated.

The fact that the calling program object determines at runtime which interface implementing class will be instantiated and, therefore, its specific coding being executed makes the programming highly flexible and extremly powerful.

The same principle is used in case of your workflow related classes.

Regards

Uwe

0 Kudos

>

> The first response to you thread is just nonsense or the replier neither read nor understood your question.

>

That response has now been removed.

Former Member
0 Kudos

Interfaces allow to implement highly scalable object oriented applications.

Interface is a kind of a template for a real class which forces this class to implement methods defined in an interface.

The main characteristics of an interfaces are:

- they DO NOT contain any implementations (so there is nothing like INTERFACE ... IMPLEMENTATION - they have only DEFINITIONS - implementations are within classes)

- they have only PUBLIC sections.

Why we need an interface. The answer is simple:

We want to handle some objects uniformly from one application compotent, whereas these objects may behave differently inside.

Example:

Let's say we need to build a sorting program for numbers.

The program would have an interface variable L_RIF_SORTER of an interface LIF_SORTER. LIF_SORTER has a method definition SORT with an C_TAB changing parameter.

Sorting application would call the sorting algorithm as follows:

L_RIF_SORTER->SORT( CHANGING c_tab = l_tab ).

Now is the main point:

We want to have 2 kinds of sorting algorithms implemented, let's say BUBBLE SORT and QUICK SORT.

To do so, we implement 2 classes: LCL_BUBBLE_SORT and LCL_QUICK_SORT.

Both classes implement interface using the statment INTERFACES in a public section.

The user would have to choose the algorithm from an input field. Depending on the content of this field the sorting application would instantiate one class or the other using the statement:

CREATE OBJECT l_rif_sorter TYPE (variable_with_class_name).

THis is the point where ABAP gets to know the real object and its type behind the interface.

This approach is generally called the STRATEGY PATTERN. See Wikipedia for this.

I hope I answered your question.

Regards,