ABAP methods overloading

Hi All,
In ABAP objects, is it possible to use same method name with different signature
in the same class. In Se24, i have build a class xyz and a method A. The method A has a string as importing parameter. I have to use the same method A with an internal table as importing parameter. Any code samples and replies would be really appreciated.
Thanks,
Ricky

In abap objects overloding(we can change the signature ) is possible only with construcor.
It is not possible with methods and the signatures can not be changed.
*& Report  ZTEST_TWO                                                   *
REPORT  ZTEST_TWO   .
class c_base definition.
  public section.
    methods: constructor importing value(p_name) type string,
             m_show1,
             m_show2.
  private section.
    data     a_name type string.
endclass.
class c_derived definition inheriting from c_base.
  public section.
    methods: constructor importing value(p_name1) type string
                                   value(p_name2) type string,
             m_show1 redefinition.
  private section.
    data     a_name type string.
endclass.
class c_base implementation.
  method constructor.
    a_name = p_name.
  endmethod.
  method m_show1.
    write: / 'Show1  :', a_name.
  endmethod.
  method m_show2.
    write: / 'Show2  :', a_name.
  endmethod.
endclass.
class c_derived implementation.
  method constructor.
    call method: super->constructor exporting p_name = p_name1.
    a_name = p_name2.
  endmethod.
  method m_show1.
    write: / 'Show1_r:', a_name.
  endmethod.
endclass.
data o type ref to c_derived.
start-of-selection.
create object o exporting p_name1 = 'Base...' p_name2 = 'Derived...'.
call method: o->m_show1,
             o->m_show2.

Similar Messages

  • Calling abap method in xslt mapping?

    Hi
    I need to call abap method in my xslt mapping , i tried with
    <sap:external-call >and <sap:external-function> .
    But it is giving short dump error.
    Can anybody give me proper syntax..
    thanks
    Prasad

    Hello,
    Please see the code below.
    This is how u call
      <sap:external-function class="ZTEST_CLASS" kind="class" method="GETRECORDCOUNT" name="ns0:GetRecordCount">
        <sap:argument param="XXXX" type="string"/>
        <sap:argument param="YYYY" type="string"/>
        <sap:result param="ZZZZ" type="string"/>
      </sap:external-function>
      <xsl:template match="/">
        <xsl:param name="Counter">
    *And this is how u call below...
    <xsl:value-of select="ns0:GetRecordCount(A,B)"/>
    </xsl:template>
    </xsl:transform>
    Regards,

  • Calling a abap method in a javascript

    Hi all,
    I've been browsing a bit through this forum, but there has no answer been completely covering my problem...
    I would like to call an abap method in the javascript in order to check some values...
    This is what I have done:
    <script language="JavaScript" defer="defer">
        function do_checks(htmlbevent)
            try
                  var doubles = "<%= controller->check_doubles( )%>";
                  if(doubles == true){
                      var Check = confirm("Test??");
                      if(Check == false){
                        htmlbevent.cancelSubmit = true;
            catch(e)
      </script>
    The method has the following code:
    mehod check_doubles. " returning parameter = rv_double of type flag
      rv_double = abap_true.
    endmethod.
    the button is defined like this...
    <htmlb:button
                              id      = "Save"
                              onClick = "save"
                              onClientClick = "do_checks(htmlbevent);"
                              text    = "<%= otr(crm_ic_appl/Save) %>"
                              />
    The funny thing is, that the controller->check_doubles( ). is already processed at load of the page (although there is no on_load used somewhere...
    If I leave out the " if(doubles == true){ } ", the javascript reacts as foreseen..., but when I keep the " if(doubles == true){ } ", the javascript doesn't go through the method anymore...
    Can anybody help me out here???
    Thanks!!
    Micha

    Hi,
    You can call them FM inside the javascript something like below...
    <script language="JavaScript">
    function yourFM()
    <%
       DATA: guid TYPE GUID_32.
       CALL FUNCTION 'GUID_CREATE' IMPORTING ev_guid_32 = guid.
    %>
    </script>
    <b>To call the class & method:</b>
    <script language="JavaScript">
        function yourFM()
          <% CLASS cl_bsp_login_application DEFINITION LOAD. %>
          var EXIT_URL  = "<%= CL_BSP_LOGIN_APPLICATION=>GET_SESSIONEXIT_URL( page = page ) %>";
      </script>
    But i am not clear what do you want to achieve. I didnt understand what you are trying to do with you code. Could you give more detail?
    <i>* Reward each useful answer</i>
    Raja T
    Message was edited by:
            Raja Thangamani

  • Starting new SAP LUW inside ABAP method

    I am calling a ABAP method and in that I want to start a new SAP LUW and do commit when leaving the method.
    The requirement is that all update function modules called inside the method should only be committed and no other prior update FMu2019s(before calling the method) should not be committed.
    Any idea if itu2019s possible to do that in ABAP OO and how do we do it.
    Thanks & Regards,
    Anand.

    HI ,
    Thanks for the quick replies. I tried using SET UPDATE TASK LOCAL but it was also committing all the prior update FM's before calling this method.
    I also tried using the RFM -    CALL FUNCTION 'ABC' IN BACKGROUND TASK   DESTINATION 'NONE' . and then
    COMMIT WORK AND WAIT.
    Now when i do commit work it commits all the previous update tasks also.
    And if i do not call COMMIT WORK right after the call to RFM, then the object that i am trying to create inside the RFM will not be committed.And then if i proceede some validations will fail as the objects were not created.
    Is there a way to commit immediately when the RFM is called without commiting the calling transaction from where this RFM is called.
    Any examples would be highly appreciated ..
    Regards,
    Anand.
    Edited by: Anand Ajitsaria on Feb 4, 2011 9:54 AM

  • Method overloading in an interface

    Hi ,
    I Have an Interface that contains overloaded methods
    Interface Interface1
    void method1();
    String method1(int i);
    }I implement this Interface in a class ExampleClass
    public class ExampleClass implements Interface1
    void method1()
    String method1(int i)
    return 'str';
    }Whenever i call the method method1(int) on ExampleClass, it throws the error java.lang.AbstractMethodError .
    Please suggest me how to handle this .
    Will Interface suypports method OverLoading .

    Hi,
    Whenever you are trying to implement a method from interface or class, the implemented method should have a access modifier greater than or equal to the original method.
    In this case, both the methods in interface are public (by default).
    So, your methods in your class should be public.
    Regards,
    Prad.

  • Combine standard task (ABAP method call) and additional UWL Action Handlers

    Hi, i have defined a task with an asynchronous ABAP method call and a terminating event which i want to use "as is" in the universal worklist, that means that the standard action has to be the ABAP method call defined for the task.
    In addition to that i want to add an extra button to the workitem view in the worklist which opens a web dynpro application. The web dynpro needs a parameter from the workitem container. Opening the web dynpro is not required for completing the task, so i do not consider using secondary methods.
    I created an UWLConfiguration for the task type without defining the defaultAction attribute, since defaultAction should not be overwritten. I wanted to use SAPWebDynproABAPLauncher to generate the button since i can easily include values from the workitem container in the call.
    When executing a workitem from the worklist the ABAP method call is not performed, instead a window opens which just displays the workitem. The button to web dynpro is generated and works fine.
    Does anyone have a clue how i can use UWL to define an additional button with SAPWebDynproABAPLauncher without overwriting the standard task definition?
    My definition:
    <ItemTypes>
        <ItemType
    name="uwl.task.webflow.TS95100103"
    connector="WebFlowConnector"
    defaultView="DefaultView">
          <ItemTypeCriteria
    systemId="ED1CLNT100"
    externalType="TS95100103"
    connector="WebFlowConnector"/>
          <CustomAttributes>
            <CustomAttributeSource
    id="WEBFLOW_CONTAINER"
    objectIdHolder="externalObjectId"
    objectType="WebFlowContainer"
    cacheValidity="final">
              <Attribute
    name="HROBJECT_OBJEKTID"
    type="string"
    displayName="HROBJECT_OBJEKTID"/>
            </CustomAttributeSource>
          </CustomAttributes>
          <Actions>
            <Action
    name="launchWebDynPro"
    groupAction=""
    handler="SAPWebDynproABAPLauncher"
    returnToDetailViewAllowed="yes"
    launchInNewWindow="yes"
    launchNewWindowFeatures="resizable=yes,scrollbars=yes,
    status=yes,toolbar=no,menubar=no,
    location=no,directories=no">
              <Properties>
                <Property
    name="WebDynproApplication" value="hr01_app"/>
                <Property
    name="newWindowFeatures"
    value="resizable=yes,scrollbars=yes,status=yes,
    toolbar=no,menubar=no,location=no,directories=no"/>
                <Property
    name="DynamicParameter"
    value="candidacy_id=${item.HROBJECT_OBJEKTID}
    &amp;from_workflow=X"/>
                <Property
    name="openInNewWindow" value="yes"/>
                <Property
    name="System" value="SYSTEM_ALIAS_ERP"/>
                <Property
    name="WebDynproNamespace" value="hr01"/>
              </Properties>
              <Descriptions default="Show"/>
            </Action>
          </Actions>
        </ItemType>
      </ItemTypes>
    Thank you very much, best regards, Martin
    Edited by: Martin Sommer on Dec 1, 2008 5:51 PM

    found a solution with transaction launcher and custom transaction

  • ABAP Methods _ 50 lines of code or less recommendation

    Hi,
    I'm looking for a document that I recall seeing that recommends that an ABAP method should have only around 50 lines of code. Can anyone recall this document and where to get it? Not sure if it was a blog or pdf paper by someone.
    Thanks,
    Ken Murray

    Hi,
    Please refer link and page number 8.
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/4fbafc9e-0e01-0010-dea9-9d23d1b269fb
    Generally, limited lines are useful for effective modularisation and easier maintanance.
    Thanks,
    Chetan Shah

  • Web Services and method overloading

    I have a number of web services which was implemented with AXIS. These services uses method overloading which
    seems to be a problem in JDeveloper (9 as well as 10 preview) JDeveloper simply won't accept the wsdl, and wont
    regenerate the web service because it doesn't support method overloading. Does anyone have a solution to this
    problem or know if it is planned to be fix'ed in the future?
    thanks
    Claus

    JAXRPC spec does not require webservice runtime to handle method overloading.
    What about creating a wrapper for the SEI to make each method name unique?

  • Call abap method in a javaScript Function

    Hi all,
    I want call a abap method via a javaScript function in a view of a bsp application.
    Does someone know how it works?
    regards Alex

    Hi,
    You can either change the location of the page to a target URL usinng "document.location.href = 'targeturl'. So targeturl is the fully qualified url necessary to call the method.
    Or you can take a look at XMLHttpRequest object (http://www.w3.org/TR/XMLHttpRequest/) which can create requests to a given URL. You can parse and use the data returned by the target url.
    Hope it helps,
    Regards.
    Ozcan.

  • ABAP OO & Overloading

    Hi,
    I am trying to write a class in ABAP. And I need to overload my constructor. I have tried this overloading operation by SE80 transaction. But ABAP says "There is already a constructor". Is it not possible to overload a method/constructor in ABAP?
    Thanks.

    Hi,
    ABAP does not provide overloading of methods/constructors in a way we know from other OO languages (eg. Java). You cannot write a method with the same name but different signature. You can only override methods  in subclass using REDEFIITION key word but signature must stay the same.
    You can also provide a different constructor in sub class but the first statement in this constructor must be a call to constructor of super-class. But only one constructor can exist.
    Here is an example:
    *& Report  ZCL_OVR                                                     *
    REPORT  zcl_ovr                                                     .
    *       CLASS lcl_a DEFINITION
    CLASS lcl_a DEFINITION.
      PUBLIC SECTION.
        METHODS:
          constructor,
          do_sth IMPORTING iv_a TYPE i
                 RETURNING value(ov_b) TYPE i.
    ENDCLASS.                    "lcl_a DEFINITION
    *       CLASS lcl_a IMPLEMENTATION
    CLASS lcl_a IMPLEMENTATION.
      METHOD constructor.
      ENDMETHOD.                    "constructor
      METHOD do_sth.
        ov_b = 2 * iv_a.
      ENDMETHOD.                    "do_sth
    ENDCLASS.                    "lcl_a IMPLEMENTATION
    *       CLASS lcl_b DEFINITION
    CLASS lcl_b  DEFINITION INHERITING FROM lcl_a.
      PUBLIC SECTION.
        METHODS:
          constructor IMPORTING iv_a TYPE i,
          do_sth REDEFINITION.
      PRIVATE SECTION.
        DATA lv_c TYPE i.
    ENDCLASS.                    "lcl_b DEFINITION
    *       CLASS lcl_b IMPLEMENTATION
    CLASS lcl_b IMPLEMENTATION.
      METHOD constructor.
        CALL METHOD super->constructor.
        me->lv_c = iv_a.
      ENDMETHOD.                    "constructor
      METHOD do_sth.
        ov_b = 2 * iv_a + lv_c.
      ENDMETHOD.                    "do_sth
    ENDCLASS.                    "lcl_b IMPLEMENTATION

  • Calling ABAP methods in Web-dynpro for ABAP

    Hi
    Can any one tell me how we can call any method which is defined in ABAP.
    eg.
    CALL METHOD ref_edit_chg->get_text_as_stream.
    This is the method i want to call in the first view.
    on the button action Process.
    Please reply at the earliest.
    Ragards,
    Rahul

    Hi Rahul,
    You can use WebServices, please have a look at below links,
    Re: The webdynpro/ABAP (WDA) calling RFC enabled FM of other ECC systems
    /people/thomas.jung3/blog/2004/11/15/bsp-150-a-developer146s-journal-part-xiii-developing-abap-webservices
    BSP a Developer's Journal Part XIV - Consuming WebServices with ABAP
    Regards,
    Nitin

  • Calling ABAP method from JCo

    Hi All,
    I need to invoke a static method of an ABAP class from JCo. Is this possible? I am new to JCo. Any help in this regard is highly appreciated.
    Thanks,
    Praneeth

    Hello Praneeth,
    i'm not sure about calling ABAP class method from JCo directly, but there is a possibility to call function module from SAP R3. And the shortest way to do so is described in Re: Accessing SAP backend from j2ee without entrprise portal thread, answered by me.
    I guess there is no problem to call an class method from an function module.
    Please consider rewording points if helpfull.
    regards,
    mz

  • Webdynpro abap-method for saving updated values in new database table

    Hi Experts,
    I am creating an ALV  application in weddynpro abap where i have given update button to update fields & save button to save values in mastertable,but whenever i am updating & saving ,it will overwrit previous values. For this,I need  to create a separate method to save the updated values of the fields in a new database table.
    Looking forward for solutions.
    Thank You!

    becuase of the below statement u r getting the error
    insert into ZTAB_CS_ISSSAL values Item_Dates.
    u declared the field Item_Dates as Stru_Issuesal-DATES
    and u were trying to inesrting the record in the table ZTAB_CS_ISSSAL with the field Item_Dates
    the error is related to the compatible.
    so declare work area for updating the table should be of type ZTAB_CS_ISSSAL.

  • Strange compiler bug in method overloading mechanism

    Hi,
    current javac compiler in version 1.4.2_10 and probably earlier versions seem to have a bug in the overloading mechanism of static methods in a certain case.
    I consider reporting this as a compiler bug but would like to have some feedback before.
    Would you consider this class correct? With 5+ years of java experience I'd consider it being correct:
    package test;
    public abstract class AbstractClass {
       public class RealizationClass extends AbstractClass {
          public void someMethod() {
             m(1); //Error: m(int,int) in test.AbstractClass cannot be applied to (int)
             m(1, 2);
       private static int m(int i) {
          return i+1;
       private static int m(int i, int j) {
          return i+j;
    }Interestingly the order of those two static method and their visibility affects the error (changing visibilty to public/protected makes javac accept the code).
    Eclipses compiler does not have this problem, it happily accepts the code above.
    What do you think?
    -Sebastian

    JLS 2.0 says on page 147: "The scope of a declaration of a member m declared in or inherited by a class type C is the entire body of C, including any nested type declarations."
    I read somewhere that in the case a nested or inner class accesses private fields of its enclosing type, the compiler generates "sythetic accessor methods" to allow access. Maybe there's something wrong with the generation of these generated methods...

  • ABAP METHODS : HELP

    hello friends,
                        I need some basic stuff on Method like what actually there role is in ABAP as i am shifting to OOPS . I have read some document but all are explaning methods with classes , kindly reply with some stuff which should be conceptually good.
    regards
    joshi

    Hi,
    We can create class by using these simple steps.
    class has declaration step, in this we can define call componets like
    methods, attributes,evnts..
    *local class creation
    CLASS <class> DEFINITION.
    METHOD <meth>. "for defining methods.
    ENDMETHOD.
    ENDCLASS.
    class has implementation section, in this section we can provide implementations to all the definitions which are declared in class declaration section.
    CLASS <class> IMPLEMENTATION.
    ENDCLASS.
    simple example;
    CLASS C_COUNTER DEFINITION.
      PUBLIC SECTION.  " here declare public components
        METHODS: SET_COUNTER IMPORTING VALUE(SET_VALUE) TYPE I,
                 INCREMENT_COUNTER,
                 GET_COUNTER EXPORTING VALUE(GET_VALUE) TYPE I.
      PRIVATE SECTION.         "here declare local components
        DATA COUNT TYPE I.
    ENDCLASS.
    CLASS C_COUNTER IMPLEMENTATION.
      METHOD SET_COUNTER.                " method implemetation
        COUNT = SET_VALUE.
      ENDMETHOD.
      METHOD INCREMENT_COUNTER.
        ADD 1 TO COUNT.
      ENDMETHOD.
      METHOD GET_COUNTER.
        GET_VALUE = COUNT.
      ENDMETHOD.
    ENDCLASS.
    Follow these steps to declare object to class.
    data: obj type ref to <name of the class>. "here refarence variable is created
    CREATE OBJECT obj. "here object is created
    *global class creation
    we can create global class in CLASS BUILDER, for that one we work with SE24.
    check the below links lot of info and examples r there
    http://www.sapgenie.com/abap/OO/index.htm
    http://www.geocities.com/victorav15/sapr3/abap_ood.html
    http://www.brabandt.de/html/abap_oo.html
    Check this cool weblog:
    /people/thomas.jung3/blog/2004/12/08/abap-persistent-classes-coding-without-sql
    /people/thomas.jung3/blog/2004/12/08/abap-persistent-classes-coding-without-sql
    http://help.sap.com/saphelp_nw04/helpdata/en/c3/225b6254f411d194a60000e8353423/frameset.htm
    http://www.sapgenie.com/abap/OO/
    http://www.sapgenie.com/abap/OO/index.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/c3/225b5654f411d194a60000e8353423/content.htm
    http://www.esnips.com/doc/375fff1b-5a62-444d-8ec1-55508c308b17/prefinalppt.ppt
    http://www.esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
    http://www.esnips.com/doc/5c65b0dd-eddf-4512-8e32-ecd26735f0f2/prefinalppt.ppt
    http://www.allsaplinks.com/
    http://www.sap-img.com/
    http://www.sapgenie.com/
    http://help.sap.com
    http://www.sapgenie.com/abap/OO/
    http://www.sapgenie.com/abap/OO/index.htm
    http://www.sapgenie.com/abap/controls/index.htm
    http://www.esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
    http://www.esnips.com/doc/0ef39d4b-586a-4637-abbb-e4f69d2d9307/SAP-CONTROLS-WORKSHOP.pdf
    http://www.sapgenie.com/abap/OO/index.htm
    http://help.sap.com/saphelp_erp2005/helpdata/en/ce/b518b6513611d194a50000e8353423/frameset.htm
    http://www.sapgenie.com/abap/OO/
    these links
    http://help.sap.com/saphelp_47x200/helpdata/en/ce/b518b6513611d194a50000e8353423/content.htm
    For funtion module to class
    http://help.sap.com/saphelp_47x200/helpdata/en/c3/225b5954f411d194a60000e8353423/content.htm
    for classes
    http://help.sap.com/saphelp_47x200/helpdata/en/c3/225b5c54f411d194a60000e8353423/content.htm
    for methods
    http://help.sap.com/saphelp_47x200/helpdata/en/08/d27c03b81011d194f60000e8353423/content.htm
    for inheritance
    http://help.sap.com/saphelp_47x200/helpdata/en/dd/4049c40f4611d3b9380000e8353423/content.htm
    for interfaces
    http://help.sap.com/saphelp_47x200/helpdata/en/c3/225b6254f411d194a60000e8353423/content.htm
    For Materials:
    1) http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCABA/BCABA.pdf -- Page no: 1291
    2) http://esnips.com/doc/5c65b0dd-eddf-4512-8e32-ecd26735f0f2/prefinalppt.ppt
    3) http://esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
    4) http://esnips.com/doc/0ef39d4b-586a-4637-abbb-e4f69d2d9307/SAP-CONTROLS-WORKSHOP.pdf
    5) http://esnips.com/doc/92be4457-1b6e-4061-92e5-8e4b3a6e3239/Object-Oriented-ABAP.ppt
    6) http://esnips.com/doc/448e8302-68b1-4046-9fef-8fa8808caee0/abap-objects-by-helen.pdf
    7) http://esnips.com/doc/39fdc647-1aed-4b40-a476-4d3042b6ec28/class_builder.ppt
    8) http://www.amazon.com/gp/explorer/0201750805/2/ref=pd_lpo_ase/102-9378020-8749710?ie=UTF8
    1) http://www.erpgenie.com/sap/abap/OO/index.htm
    2) http://help.sap.com/saphelp_nw04/helpdata/en/ce/b518b6513611d194a50000e8353423/frameset.htm
    Regards,
    Padmam.

Maybe you are looking for

  • How can I manage a button in a SWF?

    Hi, I have a SWF in a Flash container, in that SWF I have several buttons and I want to control them so when you click one it pushes a view in my mobile App. How do I do this? From FB or from Flash? Thanks, my code is this (only view till now): <?xml

  • Default topic for unmapped IDs

    I have been going through my client's application, with BugHunter enabled, and when I find a dialog box that has not yet been mapped in the Map ID file, I add the map ID and the associated topic. But - what if I miss a "buried" dialog box? Currently,

  • Incoming connections now at start-up

    I am now all of a sudden (after a couple of years of never seeing it) being asked to allow/deny Incoming connections for several items: -krb5kdc -qmasterd -qmasterqd -compressord and a few others. Why all of a sudden?

  • HT1491 Im not getting an option to download in the App store.... any ideas?

    I do not get the option to download in the app marketplace ... any ideas?

  • Why does the code look fine in Explorer and Chrome, and WAY off in Firefox?

    Here is the example link, but there are a lot of pages that turn out like this. Help? http://www.rv-wireless-internet.com/RV_Wireless1.html As you can see, looks ok in chrome and IE, terrible in Firefox. ANyone have the tip? I am boggled. J