cancel
Showing results for 
Search instead for 
Did you mean: 

New to BADI long question

Former Member
0 Kudos

Hi,

I am new to SAP. Learned SAP SRM. I have a basic doubts about Badi.

To Modify:

1. Check which BADI to customize from SRM Server -> BADI

Get the exact name to modify based on the description (say ABC_BADI).

2. Use SE18 to create a new BADI ZABC_BADI.

3. Save and go back to SRM Server -> BADI.

4. Select the new implementation ZABC_BADI and Save.

Please let me know if I miss any step here.

a) Difference between Claissic and New BADI.

b) Why we have two transaction SE18/SE19.

c) How do I know which one to use. Just above steps or any other way to find.

Also how to customize to show 20 or 30 records on web page (say request list, p.o list etc.,). Right now by default it is showing only 12 records when I make a search on Check Status.

Can someone send me documenation of basic steps or programming involved in BADI.

Thanks!

Sona

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

First,some general info on BADI;

BADI - Business Add Ins are enhancements to the standard version of the code of SAP. They can be inserted into the SAP system to accommodate user requirements too specific to be included in the standard delivery. Customers can find the possible enhancements (BADIs) in their SAP system in the Implementation Guide (IMG) and in the component hierarchy. BADI definitions are included in the IMG so that the customer can create suitable, company-specific implementations. SAP guarantees the upward compatibility of all Business Add-In interfaces. Release upgrades do not affect enhancement calls from within the standard software nor do they affect the validity of call interfaces.

Two different views are available:

In the definition view, an application programmer defines exit points in a source that allow specific industry sectors, partners, and customers to attach additional coding to standard SAP source code without having to modify the original object.

In the implementation view, the users of Business Add-Ins can customize the logic they need or use a standard solution if one is available.

DEFINITION OF A BADI

SAP application developer actually defines a Business Add-In available to an application program. The following are the steps in defining a BADI:

1. Using the SAP BADI builder, the SAP application developer defines an enhancement (BADI). It consists of an interface with a method.

2. The interface name is generated automatically and can be changed. The system branches to the Class Builder.

3. Using the Class Builder, the developer assigns a method to the interface.

4. For each method, he defines parameters. Parameters can either be importing or changing and these are the fields available for customer to use for enhancements. Importing parameters are the fields being passed from the calling program and changing parameters are the fields being passed back to the program.

5. The Business Add-In is then activated in the Class Builder.

Note: Documentation of the BADI usually provides the list of parameters and their definition. For example, for method DETERMINE_EXTPO, the available parameters are:

Importing

o ITEM_DATA Item data (is a structure)

Changing

o BBP_EXTPO_GL

o If the field has the value X, the request is subject to the extended classic scenario.

o If the field is empty, the request is not subject to the extended classic scenario.

IMPLEMENTATION OF A BADI

If a customer wishes to use a Business Add-In, he or she first creates an implementation. The customer must implement the methods and the enhancements. You need to program the interface method in such a way that, when the add-in is called from the application program, it will perform the specific action the customer intends. The following are the steps customer can follow in implementing a BADI:

1. In the SAP menu, choose ABAP Workbench ® Utilities ® Business Add-Ins (transaction SE19) or double-click the corresponding activity in the Implementation Guide (IMG).

2. Enter a name for the implementation and then click the Create pushbutton.

3. Enter the name of the add-in for which you want to create an implementation for in the dialog box that appears. Choose the Interface tab.

4. Choose ABAP Code as the implementation type.

5. Navigate to the Class Builder by double-clicking the method. You must first enter a

package before the Class Builder is displayed.

6. Insert the desired source code for the implementation between the method if_ex_businessaddin~method. and endmethod (statements that already exist) You need to use the parameters (importing and changing) as fields within the BADI. You can define additional fields you need in the coding as local data fields.

7. Save your entries and return to the Change Implementation screen.

8. Choose Activate. The enhancement's active components are then called at runtime.

EXAMPLE (code)

Definition name BBP_EXTLOCALPO_BADI

Implementation Name ZEXTENDEDCLASSIC

Interface name IF_EX_BBP_EXTLOCALPO_BADI

Name of implementing class: ZCL_IM_EXTENDEDCLASSIC

Method DETERMINE_EXTPO

ABAP Code Determination of Control for Extended

method IF_EX_BBP_EXTLOCALPO_BADI~DETERMINE_EXTPO.

data: zzecs type zecs. * local data field

*extended classic will be activated only for specific product categories

if item_data-category eq '420DD2C2CFDF56478E705E352FEC86CB'.

bbp_extpo_gl-bbpexpo = 'X'.

else.

select single * from zecs into zzecs where product eq item_data-product.

if sy-subrc eq 0.

bbp_extpo_gl-bbpexpo = 'X'.

endif.

endif.

endmethod.

FILTER-DEPENDENT BADI

Business Add-Ins may also be implemented on the basis of a filter value. The application program provides the filter value for the enhancement method. The filter parameter is defined within the method when creating the interface. For each method created in the interface of a filter-dependent enhancement, the filter value must be defined as the importing parameter so that the application program can provide the filter value to the enhancement method. The method then selects the active implementation for that value. The filter value is always declared using the parameter flt_val and is predefined in the list of parameters

For example:

You can use the Business Add-Ins BBP_DOC_CHANGE_BADI to make changes to the document, after user entry and before saving the document to the database. These changes are subject to the document-specific checks. The parameter FLT_VAL acts as a filter value that assigns the BAdI implementation to a particular document type. You can use the BAdI to change some of these documents:

o Shopping cart (filter value BUS2121 - shopping cart EC)

o Purchase order (filter value BUS2201 - purchase order EC)

o Confirmation (filter value BUS2203 - confirmation of goods/services EC)

o Invoice (filter value BUS2205 - incoming invoice EC)

o Bid invitation (filter value BUS2200 - bid invitation EC)

CALLING A BADI IN THE APPLICATION PROGRAM

When a Business Add-In is created, enhancement management generates a class that implements the interface. The application developer uses a factory method to create an instance of this adapter class in the application program and calls the corresponding method, if necessary.

The adapter class method generated by add-in management decides whether one or several active implementations should be called. If necessary, these implementations are subsequently executed. The application program ensures only that the adapter class method is called. The application program does not know which implementations are called.

Answers to your queries:

b) Why we have two transaction SE18/SE19.

SE18 - This trascn is used to display/view all the BADI's available in the SRM system

SE19 - This trascn is used to create a custom implementation for a BADI .In the BADI implementation,you will have different methods.In one of the methods(as per the reqt),you will write your piece of code as shown in the above example.

c) How do I know which one to use. Just above steps or any other way to find.

Again,

SE18 - BADI Defination

SE19 - BADI Implementation

SE18 we have list of all BADI's BBP* and also few BADI s are having examples say BBP_WFL_APPRV_BADI is having a good example. We can check such examples at SE18 Implementation -- Display

In SE19 you can create a ZBADI where you can write your own code.

Regarding the number of records /entries shown in a list,you can implement the BADI "BBP_WF_LIST" to modify the number of records shown.

Sample Code for the BADI BBP_WF_LIST Implementation...

codeMETHOD if_ex_bbp_wf_list~bbp_wf_list.

DATA: t_header_guids TYPE TABLE OF bbp_guid_tab,

t_pdlist TYPE TABLE OF bbp_pds_pdlist,

t_messages TYPE TABLE OF bbp_pds_messages,

t_sc_guids TYPE TABLE OF bbp_guid_tab,

t_ref_doc TYPE TABLE OF bbps_sc_refdata,

t_itemlist TYPE TABLE OF bbp_pds_sc_itemlist,

t_conf_pdlist TYPE TABLE OF bbp_pds_pdlist.

DATA: wa_sc_guids TYPE bbp_guid_tab,

wa_pdlist TYPE bbp_pds_pdlist,

wa_ref_doc TYPE bbps_sc_refdata,

wa_itemlist TYPE bbp_pds_sc_itemlist,

wa_conf_pdlist TYPE bbp_pds_pdlist.

IF sy-tcode EQ 'BBPCF02'.

First Get all the Reference documents

Get all the Shopping Carts

CALL FUNCTION 'BBP_PD_SC_GETLIST'

TABLES

i_header_guids = t_header_guids

e_pdlist = t_pdlist

e_messages = t_messages.

Sort the SC based on SC number

SORT t_pdlist BY object_id.

Get all the Header Guids

LOOP AT t_pdlist INTO wa_pdlist.

wa_sc_guids-guid = wa_pdlist-guid.

APPEND wa_sc_guids TO t_sc_guids.

ENDLOOP.

Get all the Reference Document for the Header Guids

CALL FUNCTION 'BBP_PD_SC_REF_GETLIST'

EXPORTING

i_item_not_deleted = 'X'

TABLES

it_header_guids = t_sc_guids

et_refdata = t_ref_doc

it_logical_systems = 'R3BACKENDSYSTEM' -> Give he R/3 backend system RFC Destination name here

EXCEPTIONS

nothing_found = 1

OTHERS = 2.

Retain only the PO (Business Object 2012)

DELETE t_ref_doc WHERE ( be_object_type NE 'BUS2012' AND

be_object_type NE 'BUS2012001' ).

Sort all reference documents based on be_object_id - Purchase Order numbers.

SORT t_ref_doc BY be_object_id.

Loop on all remaianing POs

Use SC Guid (Header)

LOOP AT t_ref_doc INTO wa_ref_doc.

DELETE e_pdlist WHERE object_id = wa_ref_doc-be_object_id.

ENDLOOP.

Here make a call to the R/3 system by using your RFC Function module

and update e_pdlist [] table which finally will contain all the

detialed confirmations starting with Document type - "EB"

based on the document type "ECDP" and "ECPO" - Add one more document type "EB" ..

so when ever BBPCF02 is called in ITS it should disply the POs

which are based on document types as "ECDP" "ECPO" and "EB".

ELSEIF sy-tcode EQ 'BBPCF03'. " Display All PO/Confirmations

Similar code as above

ENDIF. "if sy-tcode eq 'BBPCF02'.

ENDMETHOD.[/code]

BR,

Disha.

Pls reward points for useful answers.