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: 

how to call a method from class interface

Former Member
0 Kudos

Hi ,

I want to call a method from a 'class interface' in a BADI .

Class Interface -- /SAPSRM/CL_PDO_DO_BASE

Method -- /SAPSRM/IF_PDO_DO_PARTNER_BASE~UPDATE_ITEM_PARTNERS

Please let me know how can I call this method in my BADI.

Thanks-

1 ACCEPTED SOLUTION

former_member230674
Contributor
0 Kudos

Hi Harmeet,

Follow these simple steps.

1. Create an instance of class interface /SAPSRM/CL_PDO_DO_BASE if method /SAPSRM/IF_PDO_DO_PARTNER_BASE~UPDATE_ITEM_PARTNERS is instance method and

call instance -> /SAPSRM/IF_PDO_DO_PARTNER_BASE~UPDATE_ITEM_PARTNERS

2.if method /SAPSRM/IF_PDO_DO_PARTNER_BASEUPDATE_ITEM_PARTNERS is static method ,call directly using class interface like /SAPSRM/CL_PDO_DO_BASE=> /SAPSRM/IF_PDO_DO_PARTNER_BASEUPDATE_ITEM_PARTNERS.

If you feel any dificulty in declaring instances and call methods,

Goto EDIT-> Pattern ->ABAP Object Patterns, Give class name , instance name and method, you got the required code.

Thanks,

Prasad.

4 REPLIES 4

alex_campbell
Contributor
0 Kudos

If you use the keyword 'CALL METHOD' the syntax is similar to the 'CALL FUNCTION' keyword.

If the method in question is a static method, it should look like this:

CALL METHOD /SAPSRM/CL_PDO_DO_BASE=>UPDATE_ITEM_PARTNERS

If the method is an instance method, it should look like this:

CALL METHOD /SAPSRM/CL_PDO_DO_BASE->UPDATE_ITEM_PARTNERS

If what you're after is more specific information about how to implement a BADI, or about the parameters required for this specific method, please provide more details and clarify.

Former Member
0 Kudos

If you're not sure how to write it, you can use the Pattern feature from the ABAP editor.

Just set the cursor in the code in place, where you want to call the method and click the Pattern button. There is an option "ABAP Objects Pattern". When you choose it, new window will appear in which you can:

- for static method - just provide class name and method name,

- for instance method - provide class name, instance name and method name,

- for creating an instance (calling constructor) - provide class name and instance name.

Then, a code which calls desired method will be inserted in your code (just like for the function module calling). You can now provide the parameters, deal with the exceptions etc.

Former Member
0 Kudos

hi harmeet,

please check that in the badi methods ur needed interface method is there. if it is there then u can call with that interface method with the interface name. if it is not there in any of the badi's then u can go for custom badi's.

former_member230674
Contributor
0 Kudos

Hi Harmeet,

Follow these simple steps.

1. Create an instance of class interface /SAPSRM/CL_PDO_DO_BASE if method /SAPSRM/IF_PDO_DO_PARTNER_BASE~UPDATE_ITEM_PARTNERS is instance method and

call instance -> /SAPSRM/IF_PDO_DO_PARTNER_BASE~UPDATE_ITEM_PARTNERS

2.if method /SAPSRM/IF_PDO_DO_PARTNER_BASEUPDATE_ITEM_PARTNERS is static method ,call directly using class interface like /SAPSRM/CL_PDO_DO_BASE=> /SAPSRM/IF_PDO_DO_PARTNER_BASEUPDATE_ITEM_PARTNERS.

If you feel any dificulty in declaring instances and call methods,

Goto EDIT-> Pattern ->ABAP Object Patterns, Give class name , instance name and method, you got the required code.

Thanks,

Prasad.