Sunday, April 28, 2013

ABAP Enhancement Technologies


Enhancing Standard SAP ABAP code

SAP has already provided certain solutions for the standard SAP processes. But sometimes there is a need of adding some additional logic to change the business logic according to user needs or change the look and feel of some standard screens. When we try to change certain standard code the system asks us to provide access key for which one has to register him. Actually there is no need of doing so as SAP provides source code plugins where one can add his/her own logic.
SAP provides many ways to achieve it.
1.       User Exit ( Generally only for SD module)
2.       Customer Exit (For MM, SD, PP, FICO modules)
3.       Enhancement framework
4.       BAdI (OOPs concept)



1.       USER EXIT
User Exit is implemented in the form of subroutine also known as FORM EXITs. The user exits are generally collected in includes and attached to the standard program by the SAP. User-exits are empty subroutines and one can fill them with your own source code. Technically this is a modification.
E.g.
FORM USEREXIT_XXXX....
 INCLUDE ZZUSEREXIT.......
  ENDFORM.   
 All of the user exits in SD are contained in the development class VMOD.
How to find these:
SE80- Give package name as VMOD.

These are the includes for user exits for sales order, delivery, billing, pricing etc. One can write his own logic inside a include program and put that include inside the subroutine meant for the exit of the include for user exit.

2.       Customer Exit
These are mainly of three types:
a.       Field Exit
b.      Function Module Exit
c.       Screen Exit
d.      Menu Exit

There are two important TCodes namely SMOD (To find available Exits) and CMOD (To implement the Exit).

a.       Field Exit
These can be created in two ways
i.                     Go to transaction CMOD and there execute transaction PRFB in command line.
ii.                   Use program RSMODPRF to create it.
By both the ways one has to provide the Field Element and Screen number and a Function module named as FIELD_EXIT_ is generated with data element as import parameter. The validation logic is written inside the function module.

b.      Function Module Exit
One can find the available function module exit from SMOD and use it in his own code. Actually the Function Module exit is a function module with a Z include. One can write his own logic inside this. This is called using CALL CUSTOMER-FUNCTION ‘<3 digit="" number="">’. But the actual Function module name is EXIT_SAPLSUSF_<3 digit="" number="">.

c.       Screen Exit
Standard screen modifications are achieved through this exit. Standard screen are modified by placing special sub screen areas on standard screen and calling the sub screen from standard screen flow logic.
CALL CUSTOMER_SUBSCREEN INCLUDING
In PAI of main screen the PAI of sub screen is called using
CALL CUSTOMER_SUBSCREEN .

To transfer data from screen to sub screen or vice versa two function module exits are used.
d.      Menu Exit
Using this any user specific menu item can be added to the standard menu options. To use this first one has to find the package in which the menu program is written and then from there one has to find the available exits using package name in SMOD. Then using CMOD one can achieve his desired results.

3.       Enhancement Framework
Enhancement can be of two types.
a.       Implicit Enhancement
b.      Explicit Enhancement

a.       Implicit Enhancement:
In an ABAP report/Function Module SAP provided implicit enhancement points i.e. at the beginning and end of the codes. So customer can do customer implementations at these places.
Implicit enhancements are possible at-
                                         I.            Beginning/End of Include/Function Module/Routine
                                       II.            End of structure
                                     III.            End of private/public/protected section of a local class.
b.       Explicit Enhancement:
These are explicitly declared. These can be of two types:
                                      I.            Enhancement Point
                                    II.            Enhancement Section
Enhancement Point: These are created in the report where exactly customer can enhance in future to get some of the additional checks/logics to get desired results. Customer adds logic at the point using enhancement implementation.
After a standard code is generated for functionality the cursor is kept at a point where enhancement logic can be written in future to enhance the logic further. Then from the Edit option – Enhancement Operations, enhancement option can be created. That time enhancement point name and enhancement spot name are given.
Then when the customer wants to add his own logic ,he goes for enhancement implementation by choosing edit option after choosing enhance option from program option.
Enhancement Section:  Enhancement section is created around a section of code which can be enhanced later by customer/partner. Enhancement section creation and implementation is same as enhancement point creation and implementation. After implementation the new set of code replaces the old code in the logical flow sequence.
               
4.               BADI
BADI is the object oriented enhancement technique in SAP ABAP. BADI definition created with an interface with fixed signature that can be implemented by the customer. During development phase an enhancement spot is created from SE18 and BADI definition is created inside it. An interface separately created added to it. BADI is called from the program using GET BADI and CALL BADI method. Customer creates BADI implementation from SE19 using BADI interface.

A program can have multiple BADIs inside it. To find the required BADI, put a breakpoint in GET_INSTANCE method class CL_EXIT_HANDLER and execute the transaction.

After application developer creates an interface for the business add in, enhancement management takes this interface and generates an adapter class for implementing it. So developer has to create an instance of adapter class in the application program while implementing the BADI.

No comments:

Post a Comment