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

Regarding the statement 'GET BADI handle'

Former Member
0 Likes
2,970

Hi guys,

As you know,the statement above is designed for new BAdI technology.After I created the enhancement spot and relevant Badi, I typed the statement in ABAP Editor as GET BADI handle.

But an error occured when compliling,with a erroe message popup as 'HANDLE' ist kein gultiges BAdI-Handle, which was shown in German. I don't know its actual meaning.

If you know the actual reason,please let me know.Thank you.

Hi guys,

As you know,the statement above is designed for new BAdI technology.After I created the enhancement spot and relevant Badi, I typed the statement in ABAP Editor as GET BADI handle.

But an error occured when compliling,with a erroe message popup as 'HANDLE' ist kein gultiges BAdI-Handle, which was shown in German. I don't know its actual meaning.

If you know the actual reason,please let me know.Thank you.

1 REPLY 1
Read only

Former Member
0 Likes
971

Let us use an example to clarify how to work with BAdIs.

You want to carry out country-specific validity checks upon completion of an order in the core. The interface of these validity tests is specified by the interface if_check_validity.

The current country is, as always, in the field sy-langu of the type lang. To be able to work with a method of a BAdI interface, you must first get an object that implements the interface if_check_validity (depending on the current country). In the second step, you can call the corresponding methods of this object (in this case, a BAdI with exactly on active implementation is semantically most useful) and the result of the validity tests is used in the core code. In this process, the core specifies the interface if_check_validity and its contract, while the subsequent systems provide the implementations.

You obtain a handle for a BAdI instance using the command GET BADI and call the interface methods using CALL BADI. If the BAdI definition created in the core is called badi_check_validity, check_validity(data) is the method that verifies the order data, and the country filter has the name language, the enhancement point is as follows:

DATA bd TYPE REF TO badi_check_validity.

GET BADI bd FILTERS language = sy-langu.

CALL BADI bd->check_validity exporting data = data.

This code fragment shows that a BAdI is represented by a variable of the type ref to badi_check_validity; BAdI names are thus in the same namespace as ABAP data types. Objects of this type are known as BAdI handles.

The GET BADI command then searches the Repository for currently active implementations and selects the one defined for the filter value sy-langu. It is instantiated and u201Cappendedu201D to the BAdI handle bd, which has also just been created. In the subsequent CALL BADI, the method call is passed on to the object instance of the BAdI implementation appended to the BAdI handle bd.