Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

BAdI Implementation, Actions questions

Former Member
0 Kudos

Hi there,

I'm currently new to New Enhancement Framework and looking at how BADI fits into this picture. I have understood of the following when we need to enhance standard SAP using BAdI:-

1) SE18, create Enhancement Spots

2) Assign BAdI definition to Enhancement Spots

3) Create Interface, Filter, etc

4) SE19, create BAdI implementations

5) Create implementing class, add methods (here is where the customised logic goes).

I have understood until there, however I have a few questions: -

1) Where do we insert the codes to "call" these BAdIs? Is there specific places in the source code that we need to modify, just like user exits?

2) What are Actions in the enhancement context?

3) "BAdIs called via an Action", what does this mean?

4) Implementations of BAdI EXEC_METHODCALL_PFF. What does this mean?

Thanks in advance for this.

Will reward points for anything helpful!

Regards,

Jared

1 ACCEPTED SOLUTION

uwe_schieferstein
Active Contributor
0 Kudos

Hello Jared

BAdIs are pre-defined (by SAP) customer-exits in the standard coding. So you cannot decide where the BAdI is called.

At these pre-defined sites the SAP coding checks if there is an <b>active</b> implementation of the BAdI available. Implementation means there is an ABAP class that implements the interface. The coding is in the class methods and not in the interface because we cannot put coding into interfaces.

Active means you have implemented the class and activated the BAdI implemenation in transaction SE19 (you see the status of the implementation next to the implementation name).

If a BAdI is defined as "multiple" this means we can have multiple active implementations. If they exist then all implementations will be called (in a random order).

Regards

Uwe

10 REPLIES 10

uwe_schieferstein
Active Contributor
0 Kudos

Hello Jared

BAdIs are pre-defined (by SAP) customer-exits in the standard coding. So you cannot decide where the BAdI is called.

At these pre-defined sites the SAP coding checks if there is an <b>active</b> implementation of the BAdI available. Implementation means there is an ABAP class that implements the interface. The coding is in the class methods and not in the interface because we cannot put coding into interfaces.

Active means you have implemented the class and activated the BAdI implemenation in transaction SE19 (you see the status of the implementation next to the implementation name).

If a BAdI is defined as "multiple" this means we can have multiple active implementations. If they exist then all implementations will be called (in a random order).

Regards

Uwe

0 Kudos

Thanks Uwe,

I don't see the logic of it though, as to how SAP will know which BAdI implementation to call? Let's say I am told that I can use a BAdI to enhance a few functionality (5 new enhancement), say a CRM Service Order using BAdI CRM_ORDERADM_H_BADI. Do I create 5 BAdI implementations and SAP will magically know which one to select at run time?

Please advise...

Many thanks!

Jared.

0 Kudos

First the SE18 part you need not worry about, as that is for creating new BADI's or if you want to see the definition of the BADI. Since your purpose is to implement BADIs you will be mostly working with SE19. BADIs are like user-exits (only they are OO) and you dont have the control of calling them through your programs, you can implement them. So lets say you have a BADI for sales order, there are methods which if implemented will get triggered during certain points (Insert/Change/Delete of sales order). To see which method is triggered check the documentation or most of the time the method name are self-documentary in their naming conventions.

Coming to when the SAP will know, if you activate your implementation, SAP flags (somewhere dont know which table) that the BADI is active and during the business process it will call the method and execute your code.

The best start point for implementing a BADI is through SPRO TCode as SAP creates all the relevant classes and you just need to implement the relevant methods.

hith

Sunil Achyut

0 Kudos

Many thanks Sunil.

I sorta get what you mean, and I went to SPRO to check out the BADIs and found few implementations. My question is, how would SAP know which BADI implementation to run during the transaction? We create BADI implementations, but I don't remember if specify which transaction will run this implementation?

Hope you get what I mean, and would appreciate any insights. Also what are Actions? I assume these are workflow related.

Thanks!

0 Kudos

Hello Jared

If the BAdI allow multiple concurrent implementations (flag "multiple" set) then all 5 implementing classes will be called. What is the consequence for us developers? <b><i>We must not rely on any specific order of the called BAdI implementations.</i></b> Furthermore, the functional enhancements in the different BAdI implementation should be completely independent of each others.

SAP does not care about which implementation to call. It calls simply all that are activated when the user-exit is passed.

Regards

Uwe

0 Kudos

>>>) Where do we insert the codes to "call" these BAdIs? Is there specific places in the source code that we need to modify, just like user exits?

There is no need to insert any code.. once you create & activate your BAdI implementation in SE19.. you are all set..the std code looks for any available active implementations & runs through that code.. for example it would look as follows:

*
  call function 'HR_GET_BUSINESS_ADD_IN'
    exporting
      exit_name      = exit_name_activation
    importing
      is_implemented = is_implemented
    changing
      instance       = exit_instance_activation.
*
  if is_implemented = true.
    call method exit_instance_activation->activate_process
      exporting
        p0759            = p0759
        message_handler  = message_handler
      importing
        is_ok            = is_ok
        process_standard = process_standard.
    check process_standard = true.
  endif.

~Suresh

0 Kudos

If I understood you right, there are 2 questions that you have.

1) How does the SAP know which BADI to exeucte for a particular transaction.

Think it this way, for exeucting a transaction there is ton of code that gets executed and in this SAP provides certain exit points where the customer can place his own values. So for example, in a delivery creation if the requirement is that for VendorA the delivery should be expedited by 3 days, you use the exit points to influence this. This exit can be a user-exit or a BADI and when you implement this it is tied to the transaction, SAP executes the specified enhancement. In other words, you dont specify the transaction in the implementation, but the transaction drives the implementation.

2) In what order does SAP execute multiple implementations of a BADI?

The answer is even SAP doesnt guarantee the order in which these get executed, the only certain thing being they will get executed. So you got to be very careful when multiple implementations have been implemented.

hith

Sunil Achyut

0 Kudos

Hi All,

I created a Global and local implementation for a custom enhancement spot. Currently the sequence is based on the Alphabetical order on Enhancement spot implementation name. I created one more implementation name in the middle of these two implementations using the implementation name sequence. It is always getting called based on this alphabetical order on enhancement implementation names. I read the documentation and User forums on the BADIs saying there no gurantee on the sequence. SAP is also giving one more BADI called BADI_SORTER to sort the implementations. I tried using that but no luck on implementing that badi successfully. Is anybody used this BADI_SORTER to sort the implementations?.Plese let me know...

0 Kudos

Hi Soma,

When creating a new implementation for the BADI sorter, one has to verify that the next steps have been taken care off:

1. The implementation has the to-be-sorted badi name set as a filter value

2. Create a new function group and create a subscreen in this function group

3. On this subscreen create a field (and text) which will hold the value you'd like to sort on and put this field in the top include of the function group.

4. For each method (except the sort) of the BAdI create a function in your new function group. One to pass the data from the BAdI to the screen and one for the way back (screen to BAdI), also one to set display/change status of the screen and one to query this status.

5. The sort method (sort_impls) must sort the table on the sorter_data field.

6. Fill in the fullname of the functiongroup and the subscreen number in the screen enhancement of your BAdI sorter implementation.

7. When implementing the to-be-sorted BADI the new field will appear in the screen of SE18 for the implementation. Filling the sort criteria and activating your implementation will now affect the order of execution. (Once you've given all implementations a sort value that is).

This did the trick for me in an ECC6.0

Regards,

Frans van Gelderen.

0 Kudos

Hello Uwe ,

I am new for the enhancement , i want to give an error massage .

We are working on QM implementation , we was implemented QM in purchase ,

i want to print error massage in MIRO transaction when the stock is in QM restriction , means he/she cant pass that stock to production . And also want some introductory nots on BAdi .

Thanks And Regards .

Shrikant Ambulkar