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 ME21N

Former Member
0 Kudos
4,028

Hello All,

I read the correspondance on BADI posted by Kripa and answers by all, I also want to learn BADI.

Kripa, can you send me the BADI code & how you write methods along with the technical specifications.

My ID : dilip.gupchup@gmail.com

Thanks & Regards,

Dilip

Regards,

Dilip

Message was edited by: Diliip Gupchup

16 REPLIES 16

Former Member
0 Kudos
3,551

Hi,

in SE18

enter the badi name

ME_PROCESS_PO_CUST - > display

then in the menu - > goto - > sample code - > display

then select method - > and code

cheers,

sasi

Former Member
0 Kudos
3,551

Hi Dilip,

BADI is - Buisness Add Ins..... say if u want to customise the standard transaction u can use the BADIs .. and they are nothing but Advanced version of user Exit ......... here the words like Object, class, methods come into picture .............

There is something called BADI definition(SE18) and BADI implementation(SE19) .....

Hey see depending upon ur requirements u can select the BADIs...... and i think it would be better for me to explain u with respect to what i did

i'll tell u all the steps u have to do ( may be most of the steps ..) for the implementation of BADI......

Not all BADIs have documentation/sample code and its my luck that i had a sample code for my BADI implementation...

Steps ( from my perspective and accordance with my requirement .... so something may be needed in extra for ur implementation or something has to be added etc.,... )

1. My requirement is to add a new subscreen/tab in the item level of ME21N - PO transaction, which could hold a user defined field say "ZZPAYMENT".

2. Go to SE80 --> Repository Information System --> Enhancements --> BADI --> Definitions. U get a Selection screen wherein u give the description as purchase and press ENTER(F8) .. u'll get the BADI's informations .. i selected two BADIs ME_GUI_PO_CUST and ME_PROCESS_PO_CUST

which are needed for my implementation/requirement.

3. U go to SE19 ( BADI implementation ) give any name to the BADI ( generally a 'Z' in front of the BADI name ZME_GUI_PO_CUST )...and press CREATE .. it will ask for which BADI definition u want to create the ZME_GUI_PO_CUST .. give the definition name ME_GUI_PO_CUST .... and say yes.....and give the Short text for ur BADI....Now u have implemented the BADI.

4. U'll get the initial page for the BADI " screen title would be - Buisness Add In Builder - Display implementation ZME_GUI_PO_CUST" .....and u'll have two tabs 'Attributes' and 'Interface' ... Click on the 'Interface' tab ... u'll get all the methods which are needed for some tasks ( depending upon the requirement )......

5. Now go to SE18 and type in ur BADI definition ME_GUI_PO_CUST and press display .. u'll be navigated to the initial screen.... from there ..in the MENU goto GOTO--> Sample code --> display ... here u'll get the Sample Methods being implemented ...(when u double click on each and every method u'll go into the code written for the method)

6. Copy what is there in the SE18 sample code (for each and every method) and paste in the methods of SE19(by double-clicking on the mehtod u 'll be navigated to paste the code) ....save and activate ..........

Now u have implemented BADI ................

'ZME_GUI_PO_CUST'

Hope this Helps u ............. atleast for a start .

Enjoy BADI...........

All the very best .................................

Cheers,

Kripa

0 Kudos
3,551

Thanks Kripa,

Kindly put focus on how I have to add fields in standard table (EKPO). Also let me know how to call the defined screen in SE51 in the BADI method.

Regards,

Dilip

Former Member
0 Kudos
3,551

Hi Dilip,

hmm ..... See U can add a customer field in a standard table only for those standard table which has given the provision for adding fields .......

In my case ... the table EKPO is a standard table there is a provision for me to add my customer field in "CI_EKPODB" data element ...

To add the customer field :

Go to SE11 --> EKPO -->Display --> then doube click the data element "CI_EKPODB"... it will ask whether u want to create a field ...press YES and then continue with adding the field.. "ZZPAYMENT" in that ...

Creating the field in the table:

Give the name of the componenet "ZZPAYMENT" and the related data element (if the field "ZZPAYMENT" is of type CHAR give the data element as "CHAR" and give the needed length of the field say (15)...... then save and activate ur table........ it will show some warnings .... (ignore that) now ur table with the customer field will be ready

Calling Screen in the BADI:-

Hey in the ME_GUI_PO_CUST(SE18-sample code) u must have seen a method "SUBSCRIBE" there u can see a program name = "SAPLMEPOBADIEX" and screen number to be "001" .. thats how u call that screen painter in ur program

Hope these points help u more !!

All the very best again !

Cheers,

R.Kripa.

0 Kudos
3,551

Hello Kripa,

As my previous mail I am following just your BADI to add a tabstrip in <b> ME21N </b> display a field from a ztable on that tabstrip. Now I have followed the steps you mentioned in your previous mail. Also declared the tab strip in the method. But I am getting error message 'Cointrols can only defined Globally'. So in which program I should declare the tabstrip?

Do I have to modify the standard program & the screen?

I have found the Top Include <b>LMEGUITOP</b> should I declare the tabstrip there? This include file is in FunctionPool <b>SAPLMEGUI</b>.

As mentioned in my previous mail I am learning BADI & this is my first BADI implememtation.

Regards,

Dilip

Message was edited by: Diliip Gupchup

Former Member
0 Kudos
3,551

Business Add-Ins

Overview

BAdi Definition

BAdi Implementation

Calling BAdi

Filter Dependent Badi

New SAP enhancement technique

To accommodate user requirements not available / too specific to be included in the SAP standard Program

Based on ABAP Objects – It has Interfaces & Methods

Guaranteed 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

Though different enhancement technique, BAdi has following distinct features

-Uses Object oriented approach

-Two parts - Definition and its Implementation - definition can either be SAP provided or user may also create it

-no longer assumes a two-system infrastructure (SAP and customers)

-allows multiple levels of software development (by SAP, partners, and customers, and as country versions, industry solutions, and the like)

-Can have multiple representations – specific one will be executed based on some criteria (filter)

-No SSCR registration

Application Programmer defines an interface for the Business Add-Ins

Enhancement management takes this interface & generates an adapter class for implementing it, thus opening path for implementation

As per need, BAdi is suitably implemented

Developer then creates an instance of the adapter class in the application program and calls the corresponding method at the appropriate time

Application program simply calls the adapter class methods; it does not know which implementations are actually being called

Adapter class methods generated by add-in management decide which implementation is to be called

Look for BAdi in IMG and in component hierarchy

Create own implementation of the add-in (complete coding for Methods) and activate

Enhancement's active components are called at runtime.

BAdi Definition

To include Business Add-Ins in the program

- Define an interface for the enhancement in the SAP menu under Tools-> ABAP Workbench -> Utilities -> Business Add-Ins (transaction SE18)

-Call the interface at the appropriate point in application program

-Customers can then select the add-in and implement it according to their needs

Let’s plan a simple task:

We want to convert strings in your application program is a specific way through Business Add-Ins technique

As the application developer, first task is to define an enhancement consisting of an interface & a method with a changing parameter to transfer value

Choose Tools ->ABAP Workbench -> Utilities -> Business Add-Ins (transaction SE18) from the SAP menu

Create a new Business Add-In containing a maximum of 20 characters and move to Interface Tab

Name of the interface is proposed by the system but may be changed

Save and double-click on the interface name to add a method

System branches to the Class Builder

Assign a method to the interface (default is Instance Method)

Add a parameter

Save and Activate

Definition screen(SE18) will now contain the method assigned to the interface

Documentation may be created to describe the intended functionality of this Add-Ins

BAdi Implementation

ABAP Workbench ->Utilities -> Business Add-Ins (transaction SE19)

Find the suitable Business Add-Ins present in system (Use IMG or Component hierarchy)

Use Add-Ins Documentation to understand functionality & to decide

Implement the Add-Ins

-a class is created with the same interface

-Finalize coding for the method

Implementations are discrete transport objects and lie within the namespace of the person or organization implementing them

Work on Simple Badi project – Continued…

Already structure of the interface defined

In order to create an implementation for the text conversion example, the add-in (in this case, the interface's method) needs to be filled with logic that converts the string. This logic will be run through every time the add-in is called from the application program

Choose ABAP Workbench ->Utilities -> Business Add-Ins (transaction SE19)

Create a new implementation and select the appropriate definition in the dialog box

Add a short text and move to Interface tab

Save

Double-click the method name when the system will take you to the code window for the method

Insert the desired source code for the implementation between the method if_ex_businessaddin~method. and endmethod. statements automatically provided to you by the system.

Save and return to the Change Implementation screen

On Activation, this implementation may be executed from the application program

Sample code to call Add-In from ABAP Program

To call static method of a global class directly, class … definition load statement is needed

Instance of the Adapter class is created and its method is executed

If enhancement needs to be different based on some parameter (e.g. country-specific or company-code specific), separate implementation of the same Add-In can be created and activated

At run time, the specific implementation will be execute

Possible through Filter-Dependent Badi

How it works

-Switch on Filter-dependency while defining the interface

-Select a suitable filter element

-All methods created in the interface will have filter 'FLT_VAL' as one import parameter

-Application program provides the filter value to the enhancement method

-The method then selects the active implementation for that value

What qualifies as a Filter

A Data element

Underlying domain may contain a maximum of 30 characters and must be of Character type

The data element must

-Either have a search help with a search help parameter of the same type as the data element and this parameter must serve as both the import and export parameter or

-the element's domain must have fixed domain values or a value table containing a column with the same type as the data element

Custom data element with the criteria may also be used

Implementing a Filter-Dependent Business Add-In

Implement the Add-In for each relevant filter value

However, multiple filter values may use the same implementation

Enter a characteristic filter value for the implementation

Calling a Filter-Dependent Business Add-In

Same as before

Pass the filter value as export parameter to the method

BAdi – some useful information

There can be more than one implementations of the same BADI definition, and in that case only the active implementations will be executed

You can activate or de-activate any of the implementations after creation

Enhancement, interface, and associated classes generated all lie in the appropriate application development namespace

Business Add-In implementations lie in the respective namespaces of the people who created them

Changes made to the interface and changes made to the Business-Add-In definition are always incompatible

-If implementations already exist for a Business-Add-In definition, they are invalidated if you make changes to the interface. This means that their syntax is no longer correct. No statements can be given on the runtime behavior. Avoid making changes to the interface or the Business-Add-In definition after the transport has taken place.

-If changes to the interface are inevitable, navigate to the Class Builder for all implementing classes and clean up the method includes of these classes (Utilities > Clean up > Method includes)

Thanks,

Former Member
0 Kudos
3,551

Hey Dilip .....

I dint know that u have the similar requirement .... i was just telling u the implementation in general

hey see there is no need to define tabstrips and all ... when u implement the BADI it automatically takes care of all the tabstrips

Ill tell u the steps to check ur implementation now!

1. Implement 2 BADIs "ME_PROCESS_PO_CUST" and "ME_GUI_PO_CUST" as "ZME_PROCESS_PO_CUST" and "ZME_GUI_PO_CUST"(SE19)

2. Copy the code in the sample code ( as how i ve told u in U previous posts ) ....

3. In the ZME_GUI_PO_CUST(SE19)~SUBSCRIBE method there will be something like "text-001" .. double click on that and give some name like "Customer Subscreen"

4.In the "SUBSCRIBE" method again u'll see a code similar to this "ls_subscriber-name = subscreen1." right?? now double click on the subscreen1 (or) go to atributes of the class "ZCL_IM_ME_GUI_PO_CUST" (which will be automaticaly generated when u implement the BADI) --> attributes tab and give the parameters as follows ...

Attribute name : SUBSCREEN1

Level : Constant

Visibility : Public

Associated type : MEPO_NAME

Description : anything u like

Initial value : 'Customer_Screen'

5.Now save and activate both the BADIs......

6. Go to ME23N .... there u'll see a new tab with name "Customer Screen" in the Items level !! ....

Note :

1.U ll not see new tab in ME21N

2.Dont do anything in the database level now ... i mean in the table level now !!

Do till this and let me know what u ve done !! and whether u r getting the new tab in ME23N

All the very best !!

Hope these also helps u

Cheers,

R.Kripa.

0 Kudos
3,551

Hi Kripa,

Thanks for your informative reply. I followed as you have told. But having some probloem with my system so unable to transport the changes. I have saved the changes as local object & unable to see the changes in

<b> ME23N </b>.

As soon as my system is UP I will make the object transportable.

Kindly put a bit focus on next step where I have to add the fields in the DB table.

Regards,

Dilip

Message was edited by: Diliip Gupchup

0 Kudos
3,551

Hi Kripa

I am very new to ABAP and i had a scenario where i had to add a custom tab in the header level in PO in the TCODE ME21n.

I followed the below steps that you mentioned in the above thread.

1. I went to SE19 and implemented ME_GUI_PO_CUST  and ME_PROCESS_PO_CUST as ZME_GUI_PO_CUST and ZME_PROCESS_PO_CUST.


2. For the methods present in the interface, i copy pasted the sample from the corresponding methods from SE18 for both the BADI implementations.


3. In the ZME_GUI_PO_CUST(SE19)~SUBSCRIBE method,I double clicked on "text-001" and gave name as "Customer Subscreen".

4.I added SUBSCREEN1 parameters to the class attributes "ZCL_IM_ME_GUI_PO_CUST" and gave

Initial value : 'Customer_Screen'

5.I saved and activated both the BADIs.

6. Executed ME21n and ME23N and i am not able to see any custom tab at the item level.

Please do let me know the steps which you think i have missed out.

Let me know how to go further.

Regards

Manasa



Former Member
0 Kudos
3,551

Hey Dilip ...

Just let me know till what u ve done and what u ve observed in detail ....... do u struck up inbetween?? or able to proceed smoothly ....

Do till this under the transportable request / local object and let me know what is coming in the ME23N ..

All the best !!!!

Note: tell me the exact requirement!

Cheers,

R.Kripa.

0 Kudos
3,551

Hi Kripa,

I have followed the steps told by you in last post.

I have stored the changes as local object. In <b> ME23N</b> I am not able to see the tabstrip.

My requirement I want to show a zfield in the newly added tabstrip.

Regards,

Dilip

0 Kudos
3,551

Hello Kripa,

I am waiting for your answer.

Kindly tell me your email id so that I can contact you.

My ID is dilip.gupchup@gmail.com

Regards,

Dilip

Former Member
0 Kudos
3,551

hey dilip ...(i was a bit busy these days so couldnt reply u

If u ve followed the stpes u must have got an extra tab in the items level for sure (ME23N) ... ofcourse u ll not get ur user field ... but the fields as per the sample code ....

hey the tab name will be the name given in the text-001 ( as i ve told u before)

if u still not got anything just tell me in detail what u ve done .............

all the best !!

cheers,

r.kripa.

Former Member
0 Kudos
3,551

Hey Dilip,

What happened????

Is ur issue got solved ????

Cheers,

R.Kripa.

0 Kudos
3,551

Thanks Krpia,

I am on another project but still I am not got the desired output. As I have mentioned before I am still eager to learn/implement BADI. Can you give your ID so that I can mail you regarding that.

Thanks & Regards,

Dilip

Former Member
0 Kudos
3,551

Hi my mail ID is onlyforstudy2005@yahoo.co.in

But i suggest u to post ur questions and answers in this forum so that even others could be benefited

Cheers,

R.Kripa.