Friday, April 5, 2013

Understanding RICEFWs - Enhancements

       Enhancements are the means by which the SAP standard code can be customized as per the clients requirement. This does not require access key as code will be written in SAP provided slots for custom code.

The type of enhancements:
1. User exits
2. Customer exits
    a. Function exits
    b. Screen exits
    c. Menu exits
3. BADI
4. Enhancement frameworks
    a. Implicit enhancements
    b. Explicit enhancements

User Exits:
The naming convention for user exits is FORM USEREXIT_001 These can be found in SE80. User exits are generally includes which are collected together and added to the SAP standard program. But the disadvantage with the user exits are it needs access key to add/change any code in the exit.

How to find a user exit?
Get the package name of the transaction/program etc. Go to SMOD, press F4 in the enhancement field. Press information systems button. Give the package name in the popup and a list of user exits are displayed pertinent to the package.

Customer exits:
Customer exits are also pre existing slots provided by SAP, but the advantage with the customer exits is they do not need any access key.
A basic check to see if a particular program has any customer exits is the keyword
CALL CUSTOMER-FUNCTION 001. Digging deep into this function, we can find the customer exits available.

Screen exits:
Like the CALLL CUSTOMER FUNCTION '001' for function exits, there is CALL CUSTOMER-SUBSCREEN for the screen exits. If this particular keyword is present in the screen program of the screen to be modified it means that a screen exit is available for us to modify the screen.
Once we have the package the screen exit can be found in SE80, or in SMOD.

How to find the enhancement for a particular  exit/screen area/menu entries -
After the customer/function exit is found, go to SMOD and press f4 in the enhancements field, press the button to expand the search options in the search popup. And uncheck all the check boxes except exits function and in the name of the component-field give the exit name. Then the enhancement screen in the SMOD tcode will be populated with the enhancement of that exit. Now go to CMOD and generate the project to code the exit.
Similarly for screen uncheck exit functions and menu entries and for menu uncheck the exit functions and screen area.

Another common way to find out exits/BADIs -
Put a break point in the get_instance method of the class CL_EXITHANDLER, and run the prog/tcode etc. The execution stops at this method every time it finds a BADI or an exit. This way the list of all the exits and BADIs in the executed program can be found.

BADIs:
These are also predefined exit points available for developers where code can be written without the necessity of any access key. Unlike the exits most of the BADIs can have multiple implementations, meaning you have a particular slot which is appropriate to insert a certain piece of code but it already has an implementation which will be triggered if a particular condition is satisfied, in this case you can create another implementation to this BADI and set up your own conditions to trigger the BADI.

Setting up a condition to a BADI can be done using filters.

Filter dependent BADI:
A filter dependent BADI is very much useful if want your code in the BADI to be triggered for only certain conditions. A BADI filter is SPECIFIC to the IMPLEMENTATION, meaning filter can be set on any one field that you wish and for any number of values of that field values. 

How to set a filter?
Select the checkbox filter-depend, and in the field type choose a data element and below insert a value in the defined filters section. ( insert field appears after the filter-depend checkbox is selected and the badi is activated).
Note1 : When the filter-depend box is checked and after the badi is activated, an importing parameter fil_val is automatically added to the interface of the badi. Also this parameter is added to all the methods of that particular implementation.

So when calling this BADI, this new import parameter should also be passed -
CALL METHOD l_badi_instance ->get_cust_name
exporting
kunnr = '300014'
flt_val = 'DEFAULT_ID'
importing
name = lv_name.

IMPLICIT ENHANCEMENTS:
Are the ones that we generally use. There are pre-existing locations in an SAP program where the user is allowed to include their code piece. These are very well carried over during upgrade to higher versions.
In the program, click on the circle button and then go to Edit -> Enhancement operations -> Show implicit enhancement options.
The general locations for these options are
- At the beginning and end of a form
- At the end of the function modules etc.

EXPLICIT ENHANCEMENTS
There are 2 types of explicit enhancements
1. Enhancement point
2. Enhancement section

The main difference between both is, enhancement point can have multiple implementations and it exists along with the SAP standard code where as the enhancement section replaces the new code with the existing SAP standard code. Enhancement section can have only one active implementation, this is especially used when we have certain code in the standard SAP program which we want to avoid. And enhancement point can have multiple implementations and hence it can exist along with the standard code.

How to create an explicit enhancement?
Goto SE80 and select the desired package and right click on it to create enhancement spot. Create an implementation for this spot and save and activate.
Now go to your program, place the cursor where you want to create the enhancement spot and in the create enhancement option give your spot and package name.With this the enhancement point gets added to your program.
Click on the ENHANCE button on the top, enhancement options - > create ->give enhancement impl name -> Place the code and activate. 

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.