Skip to Content
avatar image
Former Member

how to call a method from class interface

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-

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    avatar image
    Former Member
    Apr 18, 2011 at 02: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.

    Add comment
    10|10000 characters needed characters exceeded

  • Apr 15, 2011 at 06: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.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Apr 16, 2011 at 09: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.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Apr 16, 2011 at 09: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.

    Add comment
    10|10000 characters needed characters exceeded