Calling inteface methods - which implementation to consider??

Hi Experts
I am new to ABAP Objects, but I know Java. So I am trying to learn ABAP comparing with Java but it creating lot of confusions.
in a demo program I found the below code :
DATA tab_root TYPE REF TO cl_wd_uielement_container.
    DATA structure_root TYPE REF TO cl_wd_uielement_container.
    DATA new_tab TYPE REF TO cl_wd_table.
    IF wd_this->structure_changed = abap_true.
      structure_root ?= view->get_element( id = 'FIELD_GROUP' ).
      tab_root       ?= view->get_element( id = 'TABLE_GROUP' ).
In  the above code snippet,
structure_root ?= view->get_element( id = 'FIELD_GROUP' ).
is a downcasting and view is of type ref to IF_WD_VIEW and class cl_wd_uielement_container implements this interface.
My question is, when we do not know which is the implemenation class  for this interface, how can we call a method of this interface (because methods are not implemented in the interface itself but in the implementation class).??
In the above assignment statement, how does system finds out which implementation to point to??
Question may be very basic, but i couldnt find the answer for this.
Please help me
Thanks
Dhananjay Hegde

Hi,
First create the instance(object) of class in you were implement interface method then call the interface method using the object.
for example
Report  Zinterface,
interface IF_view.
methods: view.
endinterface.
class c1 definition.
public section.
interfaces: IF_view.
methods:m1,m2. " here some more methods.
endclass.
class c1 implementation.
method IF_view~view.
write:/ 'this is an interface method'.
endmethod.
method m1.
write:/ 'this is  M1 method'.
endmethod.
method m2.
write:/ 'this is  M2 method'.
endmethod.
endclass.
data: obj type ref to c1.
START-OF-SELECTION.
create object obj.
call method obj->IF_view~view." call the interface method using the insatance of where you were implemeted the interface
The above procedure apply for your requirement.. i hope you may get idea about interface method calling.
Best Regards
sreenivas.

Similar Messages

  • In session and call tansaction methods, which is better . why?

    hi
    in session and call tansaction methods, which is better . why?

    see the link:
    <a href="http://www.itcserver.com/blog/2006/06/30/batch-input-vs-call-transaction/">batch inpunt VS call transaction</a>
    "The most important aspects of the session interface are:
    <b>Asynchronous processing</b>
    Transfer data for multiple transactions
    Synchronous database update. During processing, no transaction is started until the previous transaction has been written to the database.
    A batch input processing log is generated for each session
    Sessions cannot be generated in parallel. The batch input program must not open a session until it has closed the preceding session.
    The most important features of CALL TRANSACTION USING are:
    <b>Synchronous processing</b>
    Transfer of data from an individual transaction each time the statement CALL TRANSACTION USING is called
    You can update the database both synchronously and asynchronously. The program specifies the update type.
    Separate LUW (Logical Units of Work) for the transaction. The system executes a database commit immediately before and after the CALL TRANSACTION USING statement.
    No batch input processing log"
    I hope I have been able to help you.
    cordial greetings.

  • In bdc call transaction method which one ll prefer synchronous or asynchron

    hi could anybody tel me
    call transaction method which one is preferred synchronous or asynchronous..?
    what ll happen if we do other method..?
    foreground or background which one ll prefer..?
    what ll happen if we do otehr method..?
    on which condition we have to use synchronous and asynchronous
    on which condition we have to use foreground and background
    thanx
    kals.

    Hi,
    if you haven't done yet please visit for general information:
    http://help.sap.com/saphelp_nw70/helpdata/en/d2/f8f3393bef4604e10000000a11402f/frameset.htm
    for further information:
    http://help.sap.com/saphelp_nw70/helpdata/en/69/c2501a4ba111d189750000e8322d00/frameset.htm
    This will hopefully answer your question.
    Regards
    Bernd

  • Problem calling a method which takes a parameter from a table

    Hi guys,
    I'm very new to jsf and hope you can help me out.
    On my page i'm generating a list, which is working fine. now i want to add some commandLinks to the list entries. on click, i want to execute a bean method, which takes a parameter from the list, generates a picture and displays it on my page.
    here's a piece of code thats already working:
    <rich:dataTable var="data" value="#{pathwayBean.orgList}">
    <rich:columnGroup>     
            <rich:column>     
               <h:outputText value="#{data.name}" />
         </rich:column>
    </rich:columnGroup>
    </rich:dataTable>now, i want to replace the outputText with a commandLink, and execute a method with {data.id} as parameter. Unfortunately, the commandLink property "action" can only call bean methods with no parameter, or is that wrong?
    Thanks in advance,
    Alex

    use actionlistener.
    here a typical code that works fine for me:
    (JSF 1.2)
    //Java
    private Integer selectedItemId=null;
         public void selectItem(ActionEvent event) {
              // Find the UIParameter component by expression
              UIParameter component = (UIParameter) event.getComponent().findComponent("itemId");
              // parse the value of the UIParameter component
              try {
                   selectedItemId = Integer.parseInt(component.getValue().toString());
                   // find itemBean here using selectedItemId
              } catch (Exception e) {
                   logger.error(e, e);
              logger.info(" +++ selectedItemId =" + selectedItemId);
         public String viewItem() {
                 //create view beans here
                 return "itemView";//return appropriate view.
    //JSF
    <h:column>
                             <h:commandLink     id="View"
                                                 action="#{itemListBean.viewItem}"
                                                       actionListener="#{itemListBean.selectItem}">
                                  <h:outputText value="select"/>
                                  <f:param id="itemId" name="itemId" value="#{itemBean.id}"/>
                             </h:commandLink>
                     </h:column>

  • Calling A.method() which instanced B from Instance A, B is of another class

    I have a class that creates a window. In the process of adding a mouse listener to a pane of labels in that object I am not able to create and action on left click of the label due to not being able to access the method of the Calling class
    public class A
         A(){
         JPanel MainBar = new JPanel();
          B b = new B( this );
             b.setB(x, y, anArray );
    public void changeIcon( int xL, int yL, int ind )
                switch ( ind )
                    case 0:
                        if ( jlblButtons[xL][yL].getIcon() == icon[0] )
                            jlblButtons[xL][yL].setIcon( icon[1] );
                            ButtonPanel.repaint();
                           GroupClear instance_of_clear = new GroupClear();
                            instance_of_clear.groupClear( xL, yL, x, y );
    public class B
           public int[][] anArray;
           public int x;
           public int y;
              A e;
           B(A e){
                 this.e = e;
           public void setB(int x, int y, int[][] anArray )
               this.anArray = new int[x][y];
               this.anArray = anArray;
           public void mousePressed(MouseEvent e) {}
           public void mouseReleased(MouseEvent e) {}
           public void mouseClicked(MouseEvent e)
               String location = e.getComponent().getName();
               x = Trim.trim( Trim.Left( location, 2 ));
               y = Trim.trim( Trim.Right( location, 2 ));
               if ( e.getButton() == MouseEvent.BUTTON1 )
                   switch ( this.gameArray[x][y] )
                       case 0:
                          e.changeIcon( x, y, 0 );
                          return;
    }It calls the get Icon, but the compiler cannot find e.changeIcon
    I have also tried to send the calling class like this
    b.setB(x, y, anArray );
           public void setB(int x, int y, int[][] anArray, B e)
               this.anArray = new int[x][y];
               this.anArray = anArray;
                  this.e = e;
           }But to no avail. What will I need to do in order to properly call the function of the class that called B?
    Edited by: Stancoffyn on Nov 16, 2007 3:22 PM

    What exactly do you want to call and where?
    You can't call e.changeIcon() from mouseClicked because e is MouseEvent, and (in the second piece of code) you can't assign an instance of type B to a field of type A.

  • Applet fails to call Javascript methods

    I'm trying to implement round-trip javascript to Java to Javascript using LiveConnect, and having a lot of trouble in Firefox. It works perfectly in IE 6. In Firefox, I can successfully call a method of an applet, and get a return value. I have not been able to get the applet to call a Javascript method. I have tried using both the call and eval methods of the JSObject with no luck. Below is my code. Any suggestions would be appreciated.
    Thanks.
    import java.applet.Applet;
    import java.awt.*;
    import netscape.javascript.*;
    public class test extends Applet {
         String message="Hello Universe!";
         JSObject proxy;
         public void paint(Graphics g) {
              g.drawString(message, 20, 20);
         // pass in ref to JS object on which to call method
         public Boolean handshake(JSObject jso) {
              proxy = jso;
              // try just calling straight eval
              proxy.eval("alert('eval')");
              // set up args object to pass to js method
              Object[] args = new Object[1];
              args[0] = "handshake";
              // call method of js object 2 different ways
              proxy.call("callback", args);
              proxy.eval("o.callback('eval')");
              return true;
         // update java display to show JS to J communication
         public void setMessage(String message) {
              this.message = message;
              repaint();
    <html>
    <head>
         <script>
              // js object to receive calls from applet
              function obj() {};
              obj.prototype = new Object();
              obj.prototype.callback = function(arg) {
                   alert("callback: " + arg);
              function doit() {
                   var a = gebi("myApplet");
                   a.setMessage("Goodbye World!");
                   o = new obj();
                   // test that js method works (it does)
                   o.callback("local");
                   // call applet method which should call back to js method
                   var there = a.handshake(o);
                   // show return value from applet method call
                   alert("there: " + there);
              window.onload = doit;
         </script>
    </head>
    <body>
         <applet
              id="myApplet"
              code="test"
              width="400"
              height="50"
              mayscript="mayscript">
         </applet>
    </body>
    </html>Results:
    In both IE and Firefox, the string shown by the applet switches to "goodbye world", the local call to the callback function works, and the call to handshake returns true.
    That's all that works in Firefox.
    In IE, the various calls to the callback method, and to the alert method of the Javascript all work.
    The results are the same whether I run the HTML page as a local file, or through IIS.
    I have also noticed that Firefox seems to hang up, crash, and just have a lot of problems dealing with this code.
    Finally, I am running all of this on XP professional SP1 with J2SE 1.5.0_04-b05 and Firefox 1.07

    Hi,
    Thanks for all your replies. Does this work on Java 5 too? Could you please share the complete code snippet which makes it work? I tried working on yours but no success.
    Regards,
    Alok

  • Calling a method, some help please

    Hi, I'm trying to run or call a method in my main Class which has received a StringBuffer value from another method in a separate class. I'm unsure about how to call this particular method. The way the method works is receiving some XML packets from a ConnectionBean. I'm just testing it so far to output the stuff in my Terminal window.
    //Method to call in <body> of XML contained in a StringBuffer
    public StringBuffer updateEditor( StringBuffer body ) {
    StringBuffer sbuff;
    sbuff = communicate.incomingBody( body );
    System.out.println( "main received" + sbuff );
    return sbuff;
    How would I call this method which is already in my main Class (that has all the GUI elements). I just want this method to run when a value is received/passed into it. So really it needs to be running all the time - in effect listening to received StringBuffers.
    Thanks :)

    I wasn't clear, sorry I'll show you what I have:
    A Class named Comms that has two methods sorting out the XML stuff:
    Class Comms {
    //Handles history of incoming <body> XML from receievedPacket
    protected void addToHistory( Message msg ) {
    //Build String to append
    StringBuffer sb = new StringBuffer();
    sb.append( msg.getBody() );
    incomingBody( sb );
    System.out.println( sb );
    //Stores the StringBuffer value from addToHistory
    public StringBuffer incomingBody( StringBuffer sb ) {
    StringBuffer body;
    body = sb;
    if( body != null ) {
    System.out.println( body );
    return body;
    ....//End Class
    And the main Class ( Exchange) that does the GUI stuff and I've a method that calls in the incomingBody(); method. I've already created a new instance of that class:
    Class Exchange {
    Comms communicate = new Comms();
    //And then the method that I want to be called
    //Method to call in <body> of XML contained in a StringBuffer
    public StringBuffer updateEditor( StringBuffer body ) {
    StringBuffer sbuff;
    sbuff = communicate.incomingBody( body );
    System.out.println( "main received" + sbuff );
    return sbuff;
    I'm not sure how to call/run this method in the main Class (Exchange) all the time so that it checks the other Class' method incomingBody?
    Thanks

  • Calling a Method of Interface by using Object

    Hi All,
    I want to use a method of a class which will be IF_ABC_XYZ~ <amethod> ( ). how can i use this method in my program , I have the instance of the class which have the above mentioned method?
    Thanks & Regards
    Pavan

    thanks
    here the case is like this
    data :
           lv_type  TYPE REF TO  IF_some xyz.
    now by using a static class method i am able to get the return type equal to lv_type i.e
    CALL METHOD cl_someclassname=> amethod ( )
       IMPORTING
           type      =  lv_type.
    now when i debug and see lv_type is having a class name inside it. I want to use a method of this class.
    How can I call the method which Iam able to see in the lv_type when i debug.

  • Calling a method after 10 seconds

    Hello,
    I need to call a method after 10 seconds. That is to make sure that if one particular field is updated, say 3 times in a window of 10 seconds, I should just be able to take the last value and process it, in my ajax app. I am so far using the Timer class, but the problem is, it ticks off a thread for every single request to be processed after 10 seconds and processes all the 3 requests, where as I should just be running that method once for the last request. Could you please help me with this ?
    Cant do this at the client level, for the page may be closed within those 10 seconds of the event and the setTimeout wont work then.
    This is what I made so far.:
    final Map<String, Object> mp = new HashMap<String, Object>();
    if(form.getEmpId() != null )
                mp.put(form.getEmpId().toString(), form);
                new java.util.Timer().schedule(new java.util.TimerTask()
                   public void run()
                      EmpForm form1 = (EmpForm)mp.get(empId.toString());
                      String empId = form1.getempId().toString();
                      String value1Changed = form1.getValue1Changed().toString();
                      String value2Changed = form1.getValue2Changed().toString();
                      myService.changeData(empId, value1Changed, value2Changed),
                }, 10000);
             }

    Thanks for replying
    tjacobs01 wrote:
    My recommendation is that you share an AtomicReference between your timer and the listener that is receiving the updates. This way, the listener can just update the value, and the timer uses the latest one when it wakes upOk, out of my limited understanding, I looked up AtmoicReference and found it a class. I think I cant use that since I am maintaining a list of empIds against the object that holds their data in a hashmap, expecting the map to override the empId on the second request. So, I made a final map and thought Id just push the timer scheduler method in another method, but the problem is, for me to ask that thread (which I expect to run after 10 seconds of my calling) to run, I need to call it somewhere, and as soon as I get a request I am calling the method which runs/ticks off the thread.
    I was thinking that since I am passing and using a final map (that I declared as a class level variable), I will be able to put update the map object and whenever the thread runs, will fetch the latest value (of the empId) in the map. But I guess I am doing it wrong. :(

  • Calling a method that returns an object Array

    Hello.
    During a JNICALL , I wish to call a method which returns an object array.
    ie my java class has a method of the form
    public MyObject[] getSomeObjects(String aString){
    MyObject[] theObjects=new MyObject[10];
    return theObjects
    Is there an equivalent to (env)->CallObjectMethod(...
    which returns a jobjectArray instead of a jobject, and if not could somebody suggest a way around this.
    Thanks,
    Neil

    I believe an array oj jobjects is also a jobject. You can then cast it to another class.

  • 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

  • I cann't call a method if it use HttpServletRequest as a parameter

              I use WebLogic5.1 as a WebServer.
              When I use javabean in a jsp file, everything is ok if call a method which don't
              use HttpServletRequest as parameter.But this method use HttpServletRequest as
              parameter, It cann't work.show this error:
              Error 500--Internal Server Error
              From RFC 2068 Hypertext Transfer Protocol -- HTTP/1.1:
              10.5.1 500 Internal Server Error
              The server encountered an unexpected condition which prevented it from fulfilling
              the request.
              what is this error mean?what can I do for it?
              

              I use WebLogic5.1 as a WebServer.
              When I use javabean in a jsp file, everything is ok if call a method which don't
              use HttpServletRequest as parameter.But this method use HttpServletRequest as
              parameter, It cann't work.show this error:
              Error 500--Internal Server Error
              From RFC 2068 Hypertext Transfer Protocol -- HTTP/1.1:
              10.5.1 500 Internal Server Error
              The server encountered an unexpected condition which prevented it from fulfilling
              the request.
              what is this error mean?what can I do for it?
              

  • How can we call the method of used controller?

    Hi All,
       i created two WDA Applications.( like YWDA1,YWDA2 ) . i am using the component WDA2 in WDA 1.and displaying the one view of WDA2 as popup window in WDA1 on action of one of the input element in the view of WDA1 by using the method l_window_manager->create_window_for_cmp_usage
    I have a button on the view of WDA2 which has appear in the popup window...how can i call the method which has binded to that button....and where should i code that...and i need to assign selected value in the popup window to input elemetn of view  WDA1
    Please help me to resolve this....
    Regards,
    Ravi

    You can not directly call view's event handler from other component.
    create a method in component controller of the second component and in the button click call the component controller method. ( also make the method as interface so that you can call it from other components )
    Now, you can call the interfacecontroller's method
    DATA: l_ref_INTERFACECONTROLLER TYPE REF TO ZIWCI__VSTX_REBATE_REQ_WD .
      l_ref_INTERFACECONTROLLER =   wd_This->wd_CpIfc_<comp usage name>( ).
      l_ref_INTERFACECONTROLLER->Save_Rr(
        STATUS = '01'                       " Zvstxrrstatus
    save_rr is the method of second component controller

  • How to call a method in bean from application module Impl?

    i have to call a method which is in a bean from AppmoduleImpl class. Is it possible ?

    The model layer should never depend on a specific view layer - this breaks reusability.
    What you need to do is expose a service method on your AM. Then your view can call this method and pass a parameter into the model layer.

  • Proces chain decision with formula method: which proces chain is performing

    I want to know which chain is processing while i am in a decision. I made a decision in a proces chain. From that decision i call a formula. In that formula i call a method which i defined myself (client specific fomula/method). Now i want to know from which proces chain this method has been called. I tried the following ABAP statements in this method:
    IMPORT instance TO l_instance
    log_id TO l_logid
    chain_id TO l_chainid
    FROM DATABASE rspc_buffer(ab)
    ID i_chain.
    I found this statements in another SDN thread and from experience i know it works fine when you process normal ABAP in your proces chain.
    Unfortunately this does not work in a method from a decision. Maybe i need to access another table?
    Any suggestions?

    Ok, if you worry about that, let's do it in series...
    you create a local chain per IP/DTP (with link "if succesfull")...so you will have 10 local chains
    then create a big chain with these 10 local chain (with link "always")
    so, if a IP (eg of loacl chain 1) fails the DTP will not be triggered, the local chain 1 will go to status red, but as you put between the local chain option "always", the local chain 2 will start...and so on
    For inforamtion, I would put the attribute change run for the specific attribute in the local chain...this way you will only activate data of succesfull IP/DTP's...
    this way you should achieve what you aim for...
    M.

Maybe you are looking for

  • Can a excise invoice be created for a proforma invoice

    Hi frenz, For Intracompany stock transfer order a excise invoice has to be created.Here they raise a proforma invoice for a PO. Now they want to raise a Excise invoice(tcode: j1ib) for that Proforma invoice. So is it possible to raise a Excise invoic

  • ODS and Infocube showing different results

    Hi, I loaded same data to Infocube and ODS but they are both showing different result in BEX. ODS ODS report is showing summarised values e.g vendor               order value                   invoice value        date 00001                    20    

  • Long time for generating spool request for smartforms

    Hi, I'm have designed a  smartforms for printing a Receipt form. It takes about 1 minute for generating spool request after pressing the PRINT button in PRODUCTION Server only. The Code i used is below CALL FUNCTION lv_fname   EXPORTING       p_belnr

  • How can I use a class like this?

    public class Test<N, T extends Test<N, T>> { public static void main(String[] args) { Test<String, Test<String, Test>> test = null; //compile failed... }

  • Openbox: keycodes and keybindings

    I've got a six year old very basic Logitech wireless keyboard with 8 hotkeys (inc volume). I've found the keycodes using showkey, but I can't get them to do anything. I'm trying to get keycode 172 (hexadecimal AC) to start Firefox, and keycode 156 (h