User exit is a classic concept. User exit is a blank code block in the form of subroutine which lies in a standard program (perform-endform). Now to write our own piece of code we shall need access key for the standard program. Modifying standard program will not be a good idea because SAP will not provide any support if any bugs are found.
From ECC 6 onwards SAP has implemented enhancement point, the implicit enhancement. By using implicit enhancement we can write our own code into a coding block. We can write our own code into a standard program or any function module or any include program also. The code block will be under a subroutine (perform – endform). Now our piece of code will be under Enhancement – Endenhancement block which is under that perform.
The enhancement must be created under a package & transport request. Any local object will not be accepted here because SAP system wants to take the versions of this enhancement.
With implicit enhancement we can create our custom code into a function module, include or standard program where the ENHANCE (coin) button exits. Now in the following example we have discussed a step by step approach to make an implicit enhancement. Here we have taken a standard include program of order. We have a format of standard include programs.
a. MV45* - it relates with Order
b. MV50* - it relates with Delivery
c. RV60* - it relates with Billing
1. Go to VA01 (Create Sales Order) transaction. Go to system > status.
2. Double click on the program SAPMV45A and go to include program MV45AFZZ.
3. We have a subroutine USEREXIT_SAVE_DOCUMENT_PREPARE. When we prepare a sales document and then press SAVE button, this subroutine comes into the picture (get help by searching or functional consultant). Click on the Enhancement (coin) button with keeping the cursor on the subroutine.
4. After clicking there we see the spot sign comes to every line.
5. Now keep the cursor inside the subroutine and go to Edit > Enhancement Operation > Show implicit enhancement options.
6. Now we see that a sign (””””””) comes into every subroutines’ starting and ending line. It means we are now ready to write code inside there.
7. After that put the cursor on that sign and right click > Enhancement Implementation > Create.
8. Now choose Enhancement mode -> CODE because we just want to code (we are not going to declare any data or structure here).
9. Click on the create button.
10. Give the name Enhancement Implementation (ZENHT in this case) and short text also.
11. Keep it inside a package and transport request.
12. Now we see at the last position we have our own enhancement which has been implemented.
13. Now we can write our piece of code inside Enhancement – Endenhancement. Here 315 is the implemented enhancement number and ZENHT is our given name.
14. Now we have written our custom code. If there is no material declared then an information message will be displayed. After that save > check > and activate by clicking on Enhancement button. Pretty Printer will not work here.
15. Now go to VA01 again and try to create a sales order without entering any material. Whenever we click on SAVE button, an information message will be displayed as follows.