Abap Enhancement
Abap Enhancement
Abap Enhancement
The enhancement concept allows you to add your own functionality to SAP's standard
business applications without having to modify the original applications.
To modify the standard SAP behavior as per customer requirements, we can use
enhancement framework.
SAP does not promote modifications to their standard codes, but they provide some exits
(include files, function modules, sub-screens) for developers to include their own functionalities.
Hence through enhancement (Exits) the developers can be able to add few changes to the existing
SAP codes without affecting the standard codes.
Types of Enhancement:
User Exits
Customer Exits
Screen Exits
Menu Exits
Function Module Exits
Field Exits --> Obsolete
New Enhancement Framework
Implicit
Explicit
Enhancement Points.
Enhancement Sections.
BADI’s - For enhancing methods and object.
User Exits:
User Exits actually comes under Modification of standard SAP codes and they are available
only for SD Modules.
An ABAP developer needs an access key to modify the user exits provided by SAP.
These are implemented in the form of sub-routines and hence 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 that SAP Developers have provided for you. You can fill them with
your own source code.
All User exits start with the word USEREXIT_...
FORM USEREXIT_XXXX....
INCLUDE ZZUSEREXIT.......
ENDFORM.
How to Identify a User Exit?
User exits can be found in the following ways:
Go to Object Navigator (SE80), select Package and put VMOD (Application development R/3
SD customer modification) and press enter. You will find all the includes for user exits in SD. You will
get User exits for Sales order, Delivery, Billing, Pricing etc.
Limitations of User Exit:
User Exits Cannot be Re-usable.
Will be overwritten during Upgrade.
Read / Change almost every Data Object which is defined Globally in the Program.
Very Easy to manipulate the Data which could result in Erroneous outcome.
Customer Exits:
Unlike user exits the Customer Exits are implemented as function modules and can be
enhanced without access key.
SAP creates customer exits for specific programs, screens, and menus within standard applications.
These exits do not contain any functionality. Instead, the customer exits act as hooks. You can hang
your own add-on functionality onto these hooks.
Customer exits are nothing but a include in customer name space will be provided in the function
module which starts with CALL CUSTOMER. You can fill them with your own source code.
User exits generally refer to the SD module while customer exits refer to all modules like MM, SD,
PP, FICO etc.
Advantage:
They do not affect the standard SAP source code.
They do not affect software updates.
Disadvantage:
Customer exits are not available for all programs and screens found in the SAP System. You
can only use customer exits if they already exist in the SAP System.
Types of Customer Exits:
Function Module Exits
Screen Exits
Menu Exits
Field Exits --> Obsolete
Function Module Exits:
The exit is implemented as a call to a function module. The code for the function module is
written by the developer. You are not writing the code directly in the function module, but in the
include that is implemented in the function module.
Format: CALL CUSTOMER-FUNCTION '910'.
The naming standard of function modules for function module exits is:
EXIT_<program name>_<3-digit suffix>
Examples:
Before enhancement any country code can be used.
The enhancement can be implemented within the include file given inside the function module.
Use the E_COCI_AUFK exporting parameter to append the values to Structure CI_AUFK, which will
get saved in AUFK when the production Order gets saved.
Create the Custom field in the structure CI_AUFK.
Now when you create the production order the value entered in the custom field gets saved along
with the production order data in AUFK table.
Menu Exits:
Menu exits allow you to add your own functionality to menus. Menu exits are implemented
by SAP and are reserved menu entries in the GUI interface. The developer can add his/her own text
and logic for the menu.
Function codes for menu exits all start with "+".
Format: +CUS (additional item in GUI status)
Example:
Identify the menu exit from the standard transaction, i.e. through SMOD.
You will get the below screen. Enter the package name in Package and press enter.
(You will get the package name using attributes of the program for the transaction)
These are the list of exits available and MCP20003 is the Menu exit.
Go to the initial screen of SMOD transaction and enter the enhancement name and select the option
component and click on display to check the list of components from the enhancement.
You will get the components of the exit.
Note: since the function codes for the menu options are already available, it is enough to provide
the meaningful descriptions. But this enables the options only and the functionality can be linked in
the function code.
Execute the COMD transaction and provide the project name and click on Create button if the
project is not yet created. Else deactivate the project by clicking on and open the project in
change mode.
Now click on the enhancement assignments.
Now you will get the components of the exit. Double click on required function code i.e. +CU1.
Provide the function text, which is to be displayed as the menu option and click on Copy.
Once the test is provided, we need to link the functionalities for the already activated function codes
through the function module exits.
Now double click on include ZXSOPU03. It will ask for creation click on Yes.
Save it as a local object and write the code as shown below. And activate it.
Now back to the initial screen of COMD and activate the project
Note: Make sure that the project is always activated and so that the additional functions get
activated.
Execute the transaction MC94. Enter the planning type and press enter
Enter the Material group and Material number. Now click on Active version.
Now in Menu go to Extras -> Customer functions you can find the Menu item “Create program -
SSR3KOR” which is created now.
Click on Create program – SSR3KOR. You will get SE38 screen where you can create a program.
A field exit applies to a given data element and a given dynpro or all dynpro’s, and is active
for all clients.
It is called just after the user has pressed a key (see below how it works).
It calls a function module with a special name that needs to be registered via program RSMODPRF
(see below how to implement).
Field exit technology is deactivated by default since NetWeaver 6.10 and is obsolete since SAP Basis
4.6a.
How it works:
The field exits cannot be called in releases 6.10 (and after) if the "abap/fieldexit" profile
parameter is set to 0
Here are the moments where the field exits are called,
Restrictions:
If the PAI contains a "FIELD <field name> MODULE <module name> ON REQUEST" about an
input field which has also a field exit, and only the field exit changes the value, then the module is
not called
If the relationship between the field and the DDIC is deactivated, the field exit is not called
In releases 6.10 and after, the "abap / fieldexit" profile parameter must be changed from 0
to 1 (transaction RZ10 or RZ11), and the system must be restarted so that to take this change into
account
First, you must get some information about the field for which you want to execute a field exit
Display screen where you need to add an exit to a field, press F1 and display technical information,
write down data element name + dynpro/program name
Note: If 2 dynpro numbers are displayed, use the one at the top (for information: this happens when
the field belongs to a "sub-screen"; the top dynpro number is the sub-screen number, while the
bottom number is the main screen number, used for batch input)
Note: if you just want to display all existing field exits, leave the data element field blank.
It then displays a screen with function module FIELD_EXIT_<data_element>. Note: you may change
the name by adding a 1 character or 1-digit suffix, like this:
FIELD_EXIT_<data element> [_<one digit or one letter>]
Press Create
You must assign this function module to a function group and to a package of the customer
namespace (most common is to have Y or Z as the first character)
This function module must have "INPUT" importing parameter, and "OUTPUT" changing parameter,
both without type
You may change the OUTPUT parameter or send an error message which interrupts the dynpro logic
Go back to RSMODPRF selection screen, let the selection screen input fields blank, EXECUTE IT, then
your field exit is displayed (and all the others).
Check box of your field exit, you have the option to assign it to a particular dynpro (combination
dynpro/data element). Default screen name is "GLOBAL" (valid for all dynpros).
Check box of your field exit, and select menu Fieldexit | Activate. Note: You have to enter a
workbench transport request (object of type R3TR XDYN)
After transport of the field exit in a target system, you must call program RSMODFDG in the target
system (any client) to activate the field exit
Miscellaneous:
If several fields have the same data element in the same dynpro, the field exit will apply to
all of them.
Break-points are ignored in field exits with the classic debugger (but it works with the new
debugger).
If you execute the following ABAP statements during the field exit, the program will dump: CALL
SCREEN, CALL DIALOG, CALL TRANSACTION, SUBMIT, MESSAGE W... and MESSAGE I..., COMMIT
WORK, ROLLBACK WORK, COMMUNICATION RECEIVE, STOP, REJECT, EXIT FROM STEP-LOOP.
There are numbers of way by using we can find out Customer Exits.
Find(Cntrl + F)
Then use Call customer and select in the main program radio button tab and press Enter.
We can find out all the possible Customer exits based on this transaction.
Method 2: SMOD
We can find out all the possible Enhancement (Customer exits) based on this package.
Method 3: SE84
Go to Transaction SE84.
Give Package and Execute. We can find out all the possible Enhancement (Customer exits) based on
this Package.
Method 4: SE81
Go to Transaction SE81.
Then from the top menu select Edit -> Select sub tree +/-.
We can find out all the possible Enhancement (Customer exits) based on this Module.
Method 5: ST05
Then go to the transaction, based on which you want to see the customer exits.
This transaction is used to see the list of objects in an enhancement. It is a container which
holds many related objects within it.
If you Double click on TEST button, you will get below screen.
From the above screen shot we can say that the Function Exit is already implemented (Green light)
but in Inactive stage (Red light).
This Transaction is used to create a project. Project is also a container, which holds several
Enhancements. If we identify the User Exits and write down the code only within it, then the
functionality will not be worked. That is why we require adding the enhancement into a project &
making it active.
Select Enhancement assignments and you add your Enhancement in this project.
You can add multiple Enhancements in one project. But you can't add one enhancement in multiple
projects. Then error message will be generated.
Error message generate, because Enhancement V45A0002 is already exist in another project.
From screen short no: 2 of CMOD description, if we click on Components, we will get the list of
Customer exits belongs to these enhancements.
Both Green-light shows that the exit is already implemented & is Active stage.
You don’t need to have an explicitly defined enhancement spot in order to implement these
enhancements.
Just position the cursor on any of these implicit points and choose ‘Create Enhancement’ from the
menu to
implement it.
Example:
1. In SE37.
2. Screen will look something like this.
4. Screen will come white & fonts will come Gray, select Show Implicit Enhancement Options.
5. Yellow lines will come, place your cursor on the yellow strip & create enhancement.
6. Choose the declaration type of enhancement.
7. Now place your required code in this section.
Explicit Enhancement:
The Implicit enhancement options are provided at specific source code places explicitly by
SAP (Note that these enhancement definitions can also be created by partners and customers in
their code).
There are two types of Explicit Enhancement options available.
ENHANCEMENT-POINT
ENHANCEMENT-SECTION
Enhancement Point:
There can be multiple active implementations of an Enhancement-Point, in which case all
the implementations will be executed with no guarantee in the order of execution.
Enhancement Section:
When the Enhancement-Section is implemented, only the implementation gets executed
and the original code doesn’t get executed. This is a new technique, which didn’t exist previously in
any of the old ways of enhancing, to exclude any standard SAP code from execution. Because of this,
there can be only one active implementation of an Enhancement-Section.
Example:
Incase of explicit enhancement, we can add our enhancements at any place as per our
requirement.
Well in our case I don't have any standard program so I am using a Z program & enhancing the code.
6. Enter Enhancement implementation name in Enhancement Spot name & Package name.
7. Now enhancement-point will come in your code with Grey Fonts.
8. Select Enhance
12. Now run the program you will find the enhancement.
In contrast to the earlier enhancement techniques, BADI follows Object Oriented approach
to make them reusable. A BADI can be used any number of times where as standard enhancement
techniques can be used only once.
For example, if we assign an enhancement to one custom project, then that enhancement
cannot be assigned to any other custom projects. To overcome this drawback SAP has provided a
new enhancement technique called BADI.
BADI T-Codes:
Types of BADI's:
While creating a BADI using the T-code SE18, it provides the pop-up screen to select the type
of BADI to be used is as shown below.
With this option, any number of active implementations can be assigned to the same definition
BADI. By default, this option is checked.
If you have multiple-use BADI definitions, the sequence must not play any role.
The drawback in Multiple use BADI is, it is not possible to know which BADI is active especially in
country specific version.
Using this option, we can define the BADI's according to the filter values to control the add-in
implementation on specific criteria.
Method 1:
4. Run any transaction on which we want find the BADI's say VA01.
5. Give the transaction name VA01 and press enter.
6. It will automatically take you to the break-point which we have set the in the SE24 transaction.
Each time if you press F8 a list BADI names will be displayed.
7. You can find the BADI name in field EXIT_NAME and if you double click on it, we can get the
corresponding BADI name before hit the corresponding screen. Based on the requirement find the
BADI name and accordingly implement your functionality using the transaction se19.
Method 2:
Go to transaction SE84 and click on Enhancements. Then double click on Business Add-Ins.
For example, if you want to find the BADI's for the standard transaction ME22n, the
procedure is as follows. This example shows, finding the way of BADI names by providing the
Package of ME22n.
1. Go to transaction ME22n. Select the System option from the menu and then click on Status.
It displays the following information.
2. Double click on the program name i.e. SAPLMEGUI. It will take you into the program and
click on Go to tab from the Menu. There we can find the package name of the standard
transaction ME22n.Copy and paste it in the package filed.
3. Now Press F8, a list of BADI names will be displayed as shown below. Select the appropriate
BADI name and implement it based on the business requirement using the transaction SE19.
Method 3:
1. Go to transaction SE 18. Select F4 help for the definition name and click on Information
System button as shown below.
2. A pop-up screen will be displayed and give the package name for any standard transaction
say VA02. Finding the package is explained above. Please refer above method to find the
package name. The package name for VA02 transaction is 'VA.'
3. A list of BADI names will be displayed for the transaction VA02. Select the appropriate BADI
name and implement it using T-code SE19.
Example:
This Example explains how to implement BADI's. Here I am trying to show how to add custom
screen to the ME23N Transactions using BADI's.
- Go to T-code SE19 and create an implementation ZME_GUI_PO_CUST and then click on create
button
- Give the Definition name "ME_GUI_PO_CUST" and continue, give short text, save
- Click on Interface Tab, you can find the implementation class name as
ZCL_IM_ME_GUI_PO_CUST2.
Go to the code section of the method and add the following code there.
CLEAR re_subscribers[].
*--the name is a unique identifier for the subscreen and defined in this
*--class definition
ls_subscriber-name = subscreen1.
ls_subscriber-dynpro = '0002'.
ls_subscriber-program = 'ZME_GUI_PO_CUST_SCREEN'.
ls_subscriber-struct_name = 'ZMARA'.
*--a label can be defined
ls_subscriber-position = 7.
*--the height of the screen can be defined here. Currently we support two
*--screen sizes:
ls_subscriber-height = 7.
CASE <mapping>-fieldname.
ENDCASE.
ENDLOOP.
The metafield mapping important for field selection and error handling purpose.
Save, check and back
Activate the Implementation class.
Activate the BADI Implementation.
De comment the PBO module in screen flow logic and create the module in above program.
TABLES: ZMARA.
*---------------------------------------------------------------------*
* FORM SET_SUBSCREEN_AND_PROG *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> DYNNR *
* --> PROG *
* --> VIEW *
* --> TO *
* --> CL_SCREEN_VIEW_MM *
*---------------------------------------------------------------------*
call_subscreen = dynnr.
call_prog = prog.
call_view = view.
ENDFORM.
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*