Application Development and Automation 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: 
Read only

Regarding Interfaces

Former Member
0 Likes
1,091

Hi,

What are the interfaces? can we call a interface in a BAdI?

Please Reply.

Regards,

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,040

Hi,

Interfaces are independent structures that allow you to enhance the class-specific public points of contact by implementing them in classes.

Interfaces can be defined globally in the R/3 repository or locally in ABAP program

Can define exactly same components in Interfaces as in Classes

Unlike classes, Interfaces do not have instances, instead they are implemented by classes

Implemented using INTERFACES statement in the declaration part of the class

INTERFACES statement must be included in the PUBLIC SECTION of the class

Different classes that implement the same interface can all be addressed in the same way.

Interface references allow users to address different classes in the same manner.

Interfaces can also be nested.

Interfaces are the basis for polymorphism in classes, because they allow a single interface method to behave differently in different classes.

we use interfaces in badis all over implementation belongs to the interfaces only

in interfaces we have implemntation methods.

i am giving syntax for that

METHOD intf~meth.

ENDMETHOD.

regards,

satish.

reward it helpful.

7 REPLIES 7
Read only

Former Member
0 Likes
1,041

Hi,

Interfaces are independent structures that allow you to enhance the class-specific public points of contact by implementing them in classes.

Interfaces can be defined globally in the R/3 repository or locally in ABAP program

Can define exactly same components in Interfaces as in Classes

Unlike classes, Interfaces do not have instances, instead they are implemented by classes

Implemented using INTERFACES statement in the declaration part of the class

INTERFACES statement must be included in the PUBLIC SECTION of the class

Different classes that implement the same interface can all be addressed in the same way.

Interface references allow users to address different classes in the same manner.

Interfaces can also be nested.

Interfaces are the basis for polymorphism in classes, because they allow a single interface method to behave differently in different classes.

we use interfaces in badis all over implementation belongs to the interfaces only

in interfaces we have implemntation methods.

i am giving syntax for that

METHOD intf~meth.

ENDMETHOD.

regards,

satish.

reward it helpful.

Read only

0 Likes
1,040

hi Satish,

Thanks for ur reply, i have a doubt that

BAPI can be used as a interfaces,

so calling the BAPI is same like FM.

can we call a BAPI within a BAdI?

Read only

0 Likes
1,040

Hi saritha,

We can call bapi with in the badi.

first u have to understand one thing badi are nothing but enhancement points, bapi's are remote enabled function modules and business object.

usually for create, change disply the records we will use bapi's

Madhavi

Read only

0 Likes
1,040

S saritha u can call a bapi in a badi............

Read only

0 Likes
1,040

Hi,

Bapi is an inerface . but interface in ooabap and interface in bapi r different.

BAPI is a remote enabled finction module and connect the two systems.

ya i think when ever we want to do any enhancemnt at bapi we use badis. like adding parameters.

regards,

satish.

Read only

Former Member
0 Likes
1,040

Have a look at this link.

http://help.sap.com/saphelp_46c/helpdata/en/22/042427488911d189490000e829fbbd/content.htm

Other type of Interfaces are

http://help.sap.com/saphelp_nw70/helpdata/en/ec/d9ab291b0b11d295400000e8353423/content.htm

Check the forum links below:

INTERFACES

Reward points if its helpful.

Read only

Former Member
0 Likes
1,040

Hi Saritha

Pls find the below material.

Reward pts if help.

Regards

Deepanker.

BADI 2

A business add-in contains the components of an enhancement. Currently, each business add-in can contain the following components:

Program enhancements

Menu enhancements

In future releases, the other components included in customer exits will also be available as add-in components.

Several components are created when you define a business add-in:

Interface

Generated class (add-in adapter)

The generated class performs the following tasks:

Filtering: If you implement a filter-dependent business add-in, the adapter class ensures that only the relevant implementations are called

Control: The adapter class calls the active implementations.

This graphic shows the process flow of a program that contains a business add-in call. It enables us to see the possibilities and limitations inherent in business add-ins.

Not displayed: You must declare a reference variable in the declaration part.

In the first step, an existing service class, CL_EXITHANDLER, creates an object reference. We will discuss the precise syntax later on. This completes the preparations for using the program enhancement.

When you define a business add-in, the system generates an adapter class, which implements the interface. In call (2), the interface method of the adapter class is called. The adapter class searches for all of the implementations of the Business Add-In and calls the implemented methods.

First, you must define a reference variable with reference to the business add-in interface. The name of the reference variable does not necessarily have to contain the name of the business add-in.

In the first step (1), an object reference is created. This creates an instance of the generated adapter class, restricted to the methods of the interfaces ("narrowing cast").

You can use this object reference to call the required methods (2).

There are various ways of searching for business add-ins:

You can search in a relevant application program for the string "CL_EXITHANDLER". If a business add-in is called from the program, the "GET_INSTANCE" method of this class must be called.

You can then reach the definition of the business add-in using forward navigation. The definition also contains documentation and a guide for implementing the Business Add-In.

You can also use search tools: Since SAP provided fewer than 50 Business Add-Ins in Release 4.6A, even a list of them all is still manageable.

However, you can also use the application hierarchy to restrict the components in which you want to search. Start the Repository Information System, then choose Environment -> EXIT techniques -> Business Add-Ins" to start the relevant search program.

To implement business add-ins, use transaction SE19 (Tools -> ABAP Workbench -> Utilities -> Business Add-Ins ->Implementation).

Enter a name for the implementation and choose Create. A dialog box appears. Enter the name of the business add-in. The maintenance screen for the business add-in then appears.

Alternatively, you can use the Business Add-In definition transaction to reach its implementations. The menu contains an entry "Implementation", which you can use to get an overview of the existing implementations. You can also create new implementations from here.

You can assign any name to the implementing class. However, it is a good idea to observe the proposed naming convention. The suggested name is constructed as follows:

Namespace prefix, Y, or Z

CL_ (for class)

IM_ (for implementation)

Name of the implementation

To implement the method, double-click its name. The system starts the Class Builder editor.

When you have finished, you must activate your objects.

In the implementing class, you can create your own methods that you then call from the interface method.

You cannot create them using forward navigation. Instead, you must define a regular method in the Class Builder (along with its interface). Specify a visibility for the method, and implement it.

Use the "Activate" icon to activate the implementation of a Business Add-In. From now on, the methods of the implementation will be executed when the relevant calling program is executed.

If you deactivate the implementation, the methods will no longer be called. However, the corresponding calls in the application program are still processed. The difference is that the instance of the adapter class will no longer find any active implementations. Unlike the "CALL CUSTOMER-FUNCTION" call, the "CALL METHOD CL_EXITHANDLER=>GET_INSTANCE" call is still executed even if there are no implementations. The same applies to the statement calling the method of the adapter class.

You can only activate or deactivate an implementation in its original system. Changing it anywhere else constitutes a modification. The activation or deactivation must be transported into subsequent systems.

If a business add-in can only have one implementation, there can still be more than one implementation in the same system. However, only one can be active at any time.

As with customer exits, you can use menu enhancements with Business Add-Ins. However, the following conditions must be met:

The developer of the program you want to enhance must have planned for the enhancement.

The menu enhancement must be implemented in a BAdI implementation.

Function codes of menu enhancements begin with a plus sign '+'.

The menu entry will only appear if there is an active business add-in implementation containing the corresponding enhancement.

You can only create function codes for business add-ins that can only be used once. Moreover, the business add-in cannot be filter-dependent.

These restrictions are necessary to ensure that there are no conflicts between two or more implementations.

If the user chooses the menu entry in the program to which the function code "+" is assigned, the system processes the relevant method call.

The method call and the menu enhancement belong inseparably to one another. Having the former without the latter would make no sense. For this reason, it is important that the two enhancement components are combined in a single enhancement - the business add-in.

To create a BAdI, use the BAdI Builder (Tools -> ABAP Workbench -> Utilities -> Business Add-Ins -> Definition).

Reward pts if help.