Application Development and Automation 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: 
Read only

Need oops sample code for Using BADI

Former Member
0 Likes
1,110

Dear all,

Initially my requirement is to Validate the Document Type of Purchase Request ion as per material.

I have created a implementation for BADI : ME_PROCESS_REQ_CUST .

im new to OOPS-ABAP, so pls send *sample code for how to use these methods PROCESS_ITEM,

like declarations, assignment of data into internal table for further validation*.

Regards,

NIranjan.G

4 REPLIES 4
Read only

Former Member
0 Likes
809

Hi,

The assignment of data into the internal table as same as in Function modules. And the declartion part if you refer any of the class or interface then use TYPE REF TO statement.

In badi implemetion you just do your validation as useful by your abap code and move these values to the corresponding

parameters in the method after that the BADI will take care .

Data; OREF type ref to C1,

CREATE OBJECT OREF

CALL METHOD ORFF ->GET_DATA(IMPORTING IT_DATA = ITAB

EXPORTING ET_DATA = ITAB1)

Read only

Former Member
0 Likes
809

Hi Niranjan,

Once you have implement the BADI, you simply have to work in OOP's ABAP. You have to work with classes, interfaces and normal classic ABAP.

Have a look at the following demo codes:

Program : DEMO_CLASS_COUNTER

Package : SABAPDEMOS.

This package contains all the demo ABAP Codes. Have a look at it. You will have an wide array of example programs.

Hope this helps.

Thanks,

Samantak.

Read only

sudarmanikandan
Explorer
0 Likes
809

Hi Niranjan,

let's assume, you have developed a BADI under the enhancement spot.

First you have to create a reference variable to get the BADi.

data: lcl_badi_handle type ref to badi_name (your_badi_name).

then, you have to generate badi object using the following statement.

GET BADI lcl_badi_hanlde.

This statement generates a BADI Objects and sets the BAdi reference to the object.

You can also use the addition FILTERS fil1 fil2 to get the BAdi under some conditions.

for example, if you want to call the BAdi when the matnr = 1000.

GET BADI lcl_badi_handle FILTERS matnr = 1000.

To Call the methods which is implemented in BADI (SE19).

CALL BADI lcl_badi_handle->method_name

(EXPORTING

your exporting parameters

IMPORTING

your importing parameters).

Hope this hepls you.

Regards,

Sudar

Read only

Sm1tje
Active Contributor
0 Likes
809

Suggestion: Go through the following links, especially the ones from Uwe Schieferstein.

http://wiki.sdn.sap.com/wiki/display/ABAP/BAdIInterfaceIF_EX_ME_PROCESS_PO_CUST

http://wiki.sdn.sap.com/wiki/display/ABAP/AccessingtheInacessible-LocalClasseswithinGlobalClasses

Hope this is what you are looking for, otherwise you might want to consider getting up to date with ABAP OO in general.