04-15-2011 4:09 PM
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-
04-18-2011 3:12 PM
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.
04-15-2011 7:38 PM
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.
04-16-2011 10:46 AM
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.
04-16-2011 10:52 AM
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.
04-18-2011 3:12 PM
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.