BADI's
Badi's are the new way of implementing the enhancement to the standard programs without changing the original code.
These are implemented through OO PROGRAMMING TECHNIQUE.
BADI'S are aslo called as INTERFACE.
BADI DEFINITION
BADI consists of method without any implementation is called BADI DEFINITION
TCODE is SE18.
BADI IMPLEMENTATION
Badi implementation means creating a oops-class internally and adding the logic.
TCODE is SE19
BADI TYPES:
1. Multiple Implementation.
2. Setting Filters In Implementation
3. BADI's are Implemented through OO Technology.
By these the performance will be better .
MULTIPLE IMPLEMENTATION
Disadvantage of Customer exit is " single Implementation' , that means
A Single Person can write the logic in ZINCLUDE and save changes under the TRANSPORT REQUEST.
So that the another person can't able to write the logic in same place unless until the first person releases his TR .
To overcome this SAP released BADI's.
So here we can create multiple implementation and write their own logic and save under his own TR without disturbing the another person.
A BADI which has multiple implementation is called MULTIPLE IMPLEMENTATION BADI.
By default all implementation will be executed.
We can't able to control the order / sequence of execution of multiple badi.
CHECKING THE BADI EITHER IT IS MULTIPLE OR SINGLE IMPLEMENTATION BY USING SE18 TCODE as below
Go to Tcode se18.
Give the Badi name as VENDOR_ADD_DATA and click on display
Now select the PROPERTIES TAB here we can see the badi either it is mutiple or not.
IF MULTIPLE USE check box is SELECT then it is MULTIPLE IMPLEMENTATION BADI
FILTER BADI
Filter Badi is type of Badi which as filter values so that only those implementation which satisfy the filter value will be executed.
Remaining implementations won't be executed .
CHECKING THE BADI EITHER IT IS FILTER BADI OR NOT USING SE18 TCODE.
Go to Tcode SE18 and give Badi name as address_check and click on display
select the properties tab here we can see whether it is filter Badi or not .
Properties of BADI:
UNDER PROPERTIES TAB WE HAVE AT THE BOTTOM
TYPES options
1. If the check box is selected as multiple use then it is used for multiple implementation if not it is for single implementation.
2. If the check box is selected as WITHIN SAP then it is used only by SAP not by us.
3. If the check box is selected as FILTER-DEPEND then it is used for setting Filter values.
HOW TO FIND BADI'S FOR A PARTICULAR TCODE
There are 2 ways we cab find BADI's
1. Using SE24 Tcode, using class as CL_EXITHANDLER.
2. Using SE84 Tcode
USING CLASS CL_EXITHANDLER AND THE METHOD IS GET_INSTANCE BY THESE WE CAN FIND LIST OF BADI FOR A TCODE
1. Go to Tcode SE24.
2. Give class name as CL_EXITHANDLER.
3. Click on display
We will get list of methods just dobule on GET_INSTANCE method
After doubling clicking on GET_INSTANCE method the following screen will appear.
Now place a break point as shown below
Now go to particular TCode as per our requirement i.e xd01 and our Break Point will trigger
and double click on EXIT_NAME we will get BADI NAME.
Again press F6 and F8 we will get another BADI NAME just down all those by repeating above step Preesing F6 and F8 untill XD01 screens ends.
USING SE84 METHOD FOR FINDING BADI'S
1. We need to find the package name for a particular transaction code .. i.e xd01.
2. Go to SE93 tcode and give our transaction code and click on display and note down the package name . example vs for xd01 tcode.
now move to TCODE SE84
1. EXPAND ENHANCEMENT FOLDER
2. EXPAND BUSINESS ADD FOLDER
3. FINALLY DOUBLE CLICK ON DEFINITION
EXAMPLE ON BADI
NEED A RAISE AN ERROR MESSAGE WHEN EVER A VENDOR IS CREATED FOR FRANCE COUNTRY WITHOUT SPECIFYING INDUSTRY KEY
STEP 1
Go to Tcode SE24 and give name as CL_EXITHANDLER and click on DISPLAY.
And Double Click on GET_INSTANCE Method.
Place a Break Point Over There as Below
STEP 2:
Go To Tcode XK01 , Now our Break Point will Trigger as below
Double click on EXIT_NAME , We will get a BADI .Just note down it.
Now click on F6 and F8 we will get Some other Badi's note down them.
Repeat the above steps we will get some more Badi's hust note them all.
Then we will move CREATE VENDOR SCREEN
Give some vendor number
Account Group as below.
We will get second screen
Here provide the mandatory fields
And press enter again we will move to our break point location as below.
Repeat the above steps we will get some other Badi's note them.
Again next Screen will appear.
Provide the industry field with some thing and click on save.
When we click on SAVE we will move to our break point location.
Repeat the above steps F6 F8 for more BADI's
Until we get the initial stage as shown below.
Now Remove The BREAK POINT.
List of Badi's we got in XK01 transaction are.
1. VENDOR_ADD_DATA
2. VENDOR_ADDRSCR_CHG.
3. BADI_LAYER
4. ADDRESS_SUBSCREEN
5. ADDRESS_CHAR.
6. ADDR_TXJCD_CHECK
7. ADDRESS_UPDATE
8. ADDRESS_CHECK
STEP 3
We need to check DEFINITION of each BADI in SE18
As per our requirement VENDOR_ADD_DATA Badi works because this BADI FINAL CHECKS BEFORE SAVING.
Go to Tcode SE18 and Provide the Badi Name VENDOR_ADD_DATA and click on DISPLAY
And check the ATTRIBUTES of this BADI Whether it is Used in WITHIN SAP or not.
If the check box is ticked as within sap we should not use this if not we can use it .
Then go to INTERFACE Tab and check all the methods that suits for our Requirement.
Here the METHOD CHECK_ALL_DATA works for us
Double Click on CHECK_ALL_DATA to view the parameters as below
finally this badi is used to do final checks and mostly it has LFA1 as importing parameter so it works.
STEP 4:
Create a Implementation For BADI.
Go to SE19 Tcode
Pick the 2nd Screen CREATE IMPLEMENTATION block
Select CLASS BADI - Provide the BADI name as VENDOR_ADD_DATA and click on Create as shown below
Provide a name for it and click on continue.
Give some short description and Click on interface tab.
Double on our method CHECK_ALL_DATA.
We will get a message as Implementation ZFINAL_CHECK_LFA1 Migrated , Means BADI's are Migrated to enhancement .
Press ENTER
So we have to Create another Implementation Called ENHANCEMENT IMPLEMENTATION
Create Implementation by clicking on CREATE ICON.
Press Enter
Then select our enhancement name what we created just now click on enter.
Now our method CHECK_ALL_DATA will be DISPLAYED AS BELOW
TESTING
Put a BREAK POINT in that check_all_data method.
Save and activate it
Go Back
Save and Activate it.
Go to Tcode XK01 and create a vendor
Press Enter provide the Mandatory Fields
Press Enter provide the Next Screen Details
Click on save
Our Break Point should Trigger
If it Triggers our Badi is suits for Implementation.
Here our Break Point is Triggered.
Now go to our Method remove the BREAK POINT and write the logic as per requirement
Now go to XK01 tcode create a vendor without specifying the INDUSTRY
And we will get an error message at the bottom of the screen on left side as below as per our logic written in CHECK_ALL_DATA method in VENDOR_ADD_DATA Badi.
EXAMPLE ON FILTER BADI
WHILE CREATING A VENDOR WE NEED TO PERFORM SOME VALIDATIONS
1. IF COUNTRY = AUSTRALIA ,VALIDATE REGION.
2. IF COUNTRY = SPAIN , VALIDATE PO BOX
3. IF COUNTRY = NEW ZEALAND , VALIDATE POSTAL CODE
STEP 1:
Go to SE24 Tcode and give name as CL_EXITHANDLER and click on DISPLAY
Double click on GET_INSTANCE method
And place a break point over there
STEP 2
Go to Tcode XK01
Our break point will trigger
Double click on EXIT_NAME
We will get some BADI note down them
Repeat the above steps we will get some more BADI's
Repeat the steps as above
We will get XK01 Screen at last , provide some vendor name
click on enter , we will move to next screen ,here provide some data
click on SAVE
Our break point will trigger
use F6 F8 we will get some BADI names not
Repeat the above steps until we get initial screen as below
List of BADI'S we got for XK01 Tcode is
1. VENDOR_ADD_DATA
2. VENDOR_ADDRSCR_CHG.
3. BADI_LAYER
4. ADDRESS_SUBSCREEN
5. ADDRESS_CHAR.
6. ADDR_TXJCD_CHECK
7. ADDRESS_UPDATE
8. ADDRESS_CHECK
STEP 4
Go to Tcode SE18 and check the DEFINITION of Each BADI which suits our requirement
As per our requirement we use ADDRESS_CHECK because it is used to perform ADDRESS CHECK and it is a FILTER DEPENDENT BADI.
Go to SE18 and give BADI name as ADDRESS_CHECK .
Click on DISPLAY.
Go to ATTRIBUTES Tab and check whether it is FILTER BADI or NOT as below
Now go to interface tab and check the method.
Double click on method ADDRESS_POSTAL_CHECK to view the parameters
Double click on CH_ADRC_STRUC to view the fields that are needed for our requirement.
THIS ADDRESS_CHECK Badi is a FILTER DEPENDENT BADI we can create FILTERS as per our requirement and this Badi Perform CHECKS while saving .
STEP 5:
Go to SE19 Tcode for implementation.
Select second screen CREATE IMPLEMENTATION BLOCK
Select Radio Button CLASSIC BADI and provide our BADI NAME
Click on create implementation and provide a name for it as shown below.
Provide some description and click on the INSERT ROW BUTTON as below to add FILTERS.
Click on that icon and add AU (Australia) country as below.
Click on INTERFACE Tab to view the method.
And double click on our method
And place a BREAK POINT to test as below
Now go to Tcode XK01 and Create a vendor with AU as country and enter some data in region field
Press ENTER and provide data on next screen and click on save.
click on save our break point should trigger.
So it is the right place to add our logic So go back to our Method In SE19 Tcode and write the code
Save and Activate it.
Go Back
Save and activate it.
Go to Tcode XK02 (changing) and Provide a created vendor number as below.
Press ENTER
Now remove the region field data and save it
when we click on save an ERROR MESSAGE Will appear at the bottom of the screen.
Similarly Create another implementation with filter value as country = spain.
And we need to validate the field PO BOX.
So go to SE19 select 2nd screen create implementation block
give CLASSIC BADI NAME as ADDRESS_CHECK
Click on create implementation
Give a valid name
Go to ATTRIBUTES TAB and set a FILTER value as below
Click on INTERFACE Tab and click on our METHOD and write the logic
Save and Activate it.
Go Back.
Save and Activate.
Test it by going to Tcode Xk01 give country as "ES" spain and PO BOX as Empty and click on SAVE Button
We will get an ERROR MESSAGE .
Similarly Create another Implementation with FILTER value as country = 'NZ' New Zealand
And we need to validate the field POSTAL CODE
Go to Tcode SE19
Select 2nd selection screen Block CREATE IMPLEMENTATION
Select CLASSIC BADI - ADDRESS_CHECK
Click on Create.
Provide some description to it.
Go to Attributes tab set FILTER value as below
Go to INTERFACE Tab and Double Click on our method and write the logic.
Save and Activate it.
Go Back.
Save and Activate.
Test it by by going to tcode XK01 create a vendor with country as NZ and postal code as EMPTY.
We will get an ERROR MESSAGE.
Here we created 3 Implementations with different filter values.
So if the End User enter some value so that only those implementation which satisfy the filter value will be executed.
Remaining implementations won't execute.
Main purpose of FILTER'S is to increase the performance of the system.
Badi's are the new way of implementing the enhancement to the standard programs without changing the original code.
These are implemented through OO PROGRAMMING TECHNIQUE.
BADI'S are aslo called as INTERFACE.
BADI DEFINITION
BADI consists of method without any implementation is called BADI DEFINITION
TCODE is SE18.
BADI IMPLEMENTATION
Badi implementation means creating a oops-class internally and adding the logic.
TCODE is SE19
BADI TYPES:
1. Multiple Implementation.
2. Setting Filters In Implementation
3. BADI's are Implemented through OO Technology.
By these the performance will be better .
MULTIPLE IMPLEMENTATION
Disadvantage of Customer exit is " single Implementation' , that means
A Single Person can write the logic in ZINCLUDE and save changes under the TRANSPORT REQUEST.
So that the another person can't able to write the logic in same place unless until the first person releases his TR .
To overcome this SAP released BADI's.
So here we can create multiple implementation and write their own logic and save under his own TR without disturbing the another person.
A BADI which has multiple implementation is called MULTIPLE IMPLEMENTATION BADI.
By default all implementation will be executed.
We can't able to control the order / sequence of execution of multiple badi.
CHECKING THE BADI EITHER IT IS MULTIPLE OR SINGLE IMPLEMENTATION BY USING SE18 TCODE as below
Go to Tcode se18.
Give the Badi name as VENDOR_ADD_DATA and click on display
Now select the PROPERTIES TAB here we can see the badi either it is mutiple or not.
IF MULTIPLE USE check box is SELECT then it is MULTIPLE IMPLEMENTATION BADI
FILTER BADI
Filter Badi is type of Badi which as filter values so that only those implementation which satisfy the filter value will be executed.
Remaining implementations won't be executed .
CHECKING THE BADI EITHER IT IS FILTER BADI OR NOT USING SE18 TCODE.
Go to Tcode SE18 and give Badi name as address_check and click on display
select the properties tab here we can see whether it is filter Badi or not .
Properties of BADI:
UNDER PROPERTIES TAB WE HAVE AT THE BOTTOM
TYPES options
1. If the check box is selected as multiple use then it is used for multiple implementation if not it is for single implementation.
2. If the check box is selected as WITHIN SAP then it is used only by SAP not by us.
3. If the check box is selected as FILTER-DEPEND then it is used for setting Filter values.
HOW TO FIND BADI'S FOR A PARTICULAR TCODE
There are 2 ways we cab find BADI's
1. Using SE24 Tcode, using class as CL_EXITHANDLER.
2. Using SE84 Tcode
USING CLASS CL_EXITHANDLER AND THE METHOD IS GET_INSTANCE BY THESE WE CAN FIND LIST OF BADI FOR A TCODE
1. Go to Tcode SE24.
2. Give class name as CL_EXITHANDLER.
We will get list of methods just dobule on GET_INSTANCE method
After doubling clicking on GET_INSTANCE method the following screen will appear.
Now place a break point as shown below
Now go to particular TCode as per our requirement i.e xd01 and our Break Point will trigger
and double click on EXIT_NAME we will get BADI NAME.
Again press F6 and F8 we will get another BADI NAME just down all those by repeating above step Preesing F6 and F8 untill XD01 screens ends.
USING SE84 METHOD FOR FINDING BADI'S
1. We need to find the package name for a particular transaction code .. i.e xd01.
2. Go to SE93 tcode and give our transaction code and click on display and note down the package name . example vs for xd01 tcode.
1. EXPAND ENHANCEMENT FOLDER
2. EXPAND BUSINESS ADD FOLDER
3. FINALLY DOUBLE CLICK ON DEFINITION
AFTER DOUBLE CLICKING JUST GIVE THE PACKAGE NAME AND EXECUTE IT
WE WILL GET LIST OF BADI'S
EXAMPLE ON BADI
NEED A RAISE AN ERROR MESSAGE WHEN EVER A VENDOR IS CREATED FOR FRANCE COUNTRY WITHOUT SPECIFYING INDUSTRY KEY
STEP 1
Go to Tcode SE24 and give name as CL_EXITHANDLER and click on DISPLAY.
Place a Break Point Over There as Below
STEP 2:
Go To Tcode XK01 , Now our Break Point will Trigger as below
Double click on EXIT_NAME , We will get a BADI .Just note down it.
Now click on F6 and F8 we will get Some other Badi's note down them.
Repeat the above steps we will get some more Badi's hust note them all.
Then we will move CREATE VENDOR SCREEN
Give some vendor number
Account Group as below.
We will get second screen
Here provide the mandatory fields
And press enter again we will move to our break point location as below.
Repeat the above steps we will get some other Badi's note them.
Again next Screen will appear.
Provide the industry field with some thing and click on save.
When we click on SAVE we will move to our break point location.
Repeat the above steps F6 F8 for more BADI's
Until we get the initial stage as shown below.
Now Remove The BREAK POINT.
List of Badi's we got in XK01 transaction are.
1. VENDOR_ADD_DATA
2. VENDOR_ADDRSCR_CHG.
3. BADI_LAYER
4. ADDRESS_SUBSCREEN
5. ADDRESS_CHAR.
6. ADDR_TXJCD_CHECK
7. ADDRESS_UPDATE
8. ADDRESS_CHECK
STEP 3
We need to check DEFINITION of each BADI in SE18
As per our requirement VENDOR_ADD_DATA Badi works because this BADI FINAL CHECKS BEFORE SAVING.
Go to Tcode SE18 and Provide the Badi Name VENDOR_ADD_DATA and click on DISPLAY
If the check box is ticked as within sap we should not use this if not we can use it .
Then go to INTERFACE Tab and check all the methods that suits for our Requirement.
Here the METHOD CHECK_ALL_DATA works for us
Double Click on CHECK_ALL_DATA to view the parameters as below
finally this badi is used to do final checks and mostly it has LFA1 as importing parameter so it works.
STEP 4:
Create a Implementation For BADI.
Go to SE19 Tcode
Pick the 2nd Screen CREATE IMPLEMENTATION block
Select CLASS BADI - Provide the BADI name as VENDOR_ADD_DATA and click on Create as shown below
Provide a name for it and click on continue.
Give some short description and Click on interface tab.
Double on our method CHECK_ALL_DATA.
We will get a message as Implementation ZFINAL_CHECK_LFA1 Migrated , Means BADI's are Migrated to enhancement .
Press ENTER
So we have to Create another Implementation Called ENHANCEMENT IMPLEMENTATION
Create Implementation by clicking on CREATE ICON.
Press Enter
Then select our enhancement name what we created just now click on enter.
Now our method CHECK_ALL_DATA will be DISPLAYED AS BELOW
TESTING
Put a BREAK POINT in that check_all_data method.
Save and activate it
Go Back
Save and Activate it.
Go to Tcode XK01 and create a vendor
Press Enter provide the Mandatory Fields
Press Enter provide the Next Screen Details
Click on save
Our Break Point should Trigger
If it Triggers our Badi is suits for Implementation.
Here our Break Point is Triggered.
Now go to our Method remove the BREAK POINT and write the logic as per requirement
Now go to XK01 tcode create a vendor without specifying the INDUSTRY
Povide data on 1st Screen give country as FR
Press enter and in next screen Dont give Industry key
Click on SAVE
EXAMPLE ON FILTER BADI
WHILE CREATING A VENDOR WE NEED TO PERFORM SOME VALIDATIONS
1. IF COUNTRY = AUSTRALIA ,VALIDATE REGION.
2. IF COUNTRY = SPAIN , VALIDATE PO BOX
3. IF COUNTRY = NEW ZEALAND , VALIDATE POSTAL CODE
STEP 1:
Go to SE24 Tcode and give name as CL_EXITHANDLER and click on DISPLAY
Double click on GET_INSTANCE method
And place a break point over there
STEP 2
Go to Tcode XK01
Our break point will trigger
Double click on EXIT_NAME
We will get some BADI note down them
Repeat the above steps we will get some more BADI's
Repeat the steps as above
We will get XK01 Screen at last , provide some vendor name
click on enter , we will move to next screen ,here provide some data
click on SAVE
Our break point will trigger
use F6 F8 we will get some BADI names not
Repeat the above steps until we get initial screen as below
List of BADI'S we got for XK01 Tcode is
1. VENDOR_ADD_DATA
2. VENDOR_ADDRSCR_CHG.
3. BADI_LAYER
4. ADDRESS_SUBSCREEN
5. ADDRESS_CHAR.
6. ADDR_TXJCD_CHECK
7. ADDRESS_UPDATE
8. ADDRESS_CHECK
STEP 4
Go to Tcode SE18 and check the DEFINITION of Each BADI which suits our requirement
As per our requirement we use ADDRESS_CHECK because it is used to perform ADDRESS CHECK and it is a FILTER DEPENDENT BADI.
Go to SE18 and give BADI name as ADDRESS_CHECK .
Click on DISPLAY.
Go to ATTRIBUTES Tab and check whether it is FILTER BADI or NOT as below
Now go to interface tab and check the method.
Double click on method ADDRESS_POSTAL_CHECK to view the parameters
Double click on CH_ADRC_STRUC to view the fields that are needed for our requirement.
THIS ADDRESS_CHECK Badi is a FILTER DEPENDENT BADI we can create FILTERS as per our requirement and this Badi Perform CHECKS while saving .
STEP 5:
Go to SE19 Tcode for implementation.
Select second screen CREATE IMPLEMENTATION BLOCK
Select Radio Button CLASSIC BADI and provide our BADI NAME
Click on create implementation and provide a name for it as shown below.
Provide some description and click on the INSERT ROW BUTTON as below to add FILTERS.
Click on that icon and add AU (Australia) country as below.
Click on INTERFACE Tab to view the method.
And double click on our method
And place a BREAK POINT to test as below
Now go to Tcode XK01 and Create a vendor with AU as country and enter some data in region field
click on save our break point should trigger.
So it is the right place to add our logic So go back to our Method In SE19 Tcode and write the code
Save and Activate it.
Go Back
Save and activate it.
Go to Tcode XK02 (changing) and Provide a created vendor number as below.
Press ENTER
Now remove the region field data and save it
when we click on save an ERROR MESSAGE Will appear at the bottom of the screen.
Similarly Create another implementation with filter value as country = spain.
And we need to validate the field PO BOX.
So go to SE19 select 2nd screen create implementation block
give CLASSIC BADI NAME as ADDRESS_CHECK
Click on create implementation
Give a valid name
Go to ATTRIBUTES TAB and set a FILTER value as below
Click on INTERFACE Tab and click on our METHOD and write the logic
Save and Activate it.
Go Back.
Save and Activate.
Test it by going to Tcode Xk01 give country as "ES" spain and PO BOX as Empty and click on SAVE Button
We will get an ERROR MESSAGE .
Similarly Create another Implementation with FILTER value as country = 'NZ' New Zealand
And we need to validate the field POSTAL CODE
Go to Tcode SE19
Select 2nd selection screen Block CREATE IMPLEMENTATION
Select CLASSIC BADI - ADDRESS_CHECK
Click on Create.
Provide some description to it.
Go to Attributes tab set FILTER value as below
Go to INTERFACE Tab and Double Click on our method and write the logic.
Save and Activate it.
Go Back.
Save and Activate.
Test it by by going to tcode XK01 create a vendor with country as NZ and postal code as EMPTY.
We will get an ERROR MESSAGE.
Here we created 3 Implementations with different filter values.
So if the End User enter some value so that only those implementation which satisfy the filter value will be executed.
Remaining implementations won't execute.
Main purpose of FILTER'S is to increase the performance of the system.