ENHANCEMENT - FUNCTION MODULE EXIT

ENHANCEMENT
1.      Enhancement is a concept by which we can add our custom code to standard SAP software without modifying it .
2.      Each enhancement point = Exit point.

CUSTOMER EXIT
Customer Exit are  ZINCLUDE Programs which are available inside a Function Module.
 Function Module  = Customer Exit
So We Can Call Customer Exits as Enhancements ,why because it does not require any access key.
We can get Customer Exit in all Modules,where User Exits are available in SD module only.

FUNCTION MODULE EXIT
Function Module Exit Is used to write the Piece of Code to Enhance The Standard SAP Software.
These exits will have IMPORTING and EXPORTING Parameters.
Based on these we need to built our code.
Function Module Exit will have ZINCLUDES
Double On ZINCLUDE and write the LOGIC..

For Implementing These Exits wEe Need to Create a Project.
PROJECT:
Project is a group of Enhancements.
i.e like Screen and Menu exit....
We can activate and deactivate the project.
If we activate the project ,the enhancements under our project goes to active state and our     custom code will be executed.
Project is used as like SWITCH , to execute/ not to execute the enhancements.
TCODE is CMOD for project Creation.

MODSAP AND MODACT ARE THE TABLES FOR ENHANCEMENT NAMES.

EXAMPLE PROGRAM 

      We need to raise an error when ever tax jurisdiction is not entered by user only for Italy  Country customers

STEP 1 :
Need To Find Customer Exit.

Either by using SE93 or SMOD or SE84.

GO to Transcaation Code SE93.

Provide XD01 tcode and click on DISPLAY Button.





STEP 2:

Note Down the Program Name and Double Click on it.

and provide the below details






and press Enter, repeat the process until u get the list of customer exit as below.



Just double on that Call Customer Function we will get Function Exit ,

Based on the IMPORT and EXPORT Parameters Choose the Exact Function module  exit as per requirement .

As per requirement i used below function Exit , just double click on INCLUDE to write our business logic.



Before writing the Logic we need to create a project.

STEP 3:

Go to Tcode CMOD and Create a project as Zexit_pr.



Click on create and provide some description , then click on enhancement assignments 







here we need to provide enhancement name, to get enhancement we need to go to Tcode SE11 
in that give Table name as MODSAP click on DISPLAY..."modsap contains list of enhancement names.


Click on DISPLAY button.


Click on utilities - > table contents -> Display 

At the output we need to provide the our  EXIT NAME under MEMBER option .





CLick on execute 

Enhancement name will be displayed. 



STEP 4:

Now Go To Tcode CMOD and Give this Enhancement Name under Enhancement assignments.



Click on Components Tab to activate our enhancement ..




Green Colour indicates that  our enhancement in active state and activate our project too.

STEP 5:

Now go tour function module exit and double click on INCLUDE to write the code
 based on import and export parameters.


Here our requirement needs KNA1 table.

Double click on include and write the logic as below





TEST:


Go to Tcode XD01 and give account group as 004 Bill to party

Give customer number as 46

press enter

provide all mandatory fields data

enter country as it (italy)

Leave Tax Jurisdiction as Blank

Click on save.






click on save an error message will appear at the bottom of the screen.