How to call a instance method without creating the instance of a class

class ...EXCH_PRD_VERT_NN_MODEL definition
public section.
  methods CONSTRUCTOR
    importing
      value(I_ALV_RECORDS) type ..../EXCH_VBEL_TT_ALV
      value(I_HEADER) type EDIDC .
  methods QUERY
    importing
      I_IDEX type FLAG
      i_..........
    returning
      value(R_RESULTS) type .../EXCH_VBEL_TT_ALV .
Both methods are instance methods.
But in my program i cannot created instance of the class unless i get the results from Query.
I proposed that Query must be static, and once we get results we can create object of the class by pasing the result table which we get from method query.
But i must not change the method Query to a static method.
Is there any way out other than making method Query as static ?
Regards.

You can't execute any instance method without creating instance of the class.
In your scenario, if you don't want to process your method of your class, you can check the instance has been created or not.
Like:
IF IT_QUERY IS NOT INITIAL.
  CRATE OBJECT O_QUERY EXPORTING......
ENDIF.
IF O_QUERY IS NOT INITIAL.
CALL METHOD O_QUERY->QUERY EXPORTING....
ENDIF.
Regards,
Naimesh Patel

Similar Messages

  • Can we call a static method without mentioning the class name

    public class Stuff {
         public static final int MY_CONSTANT = 5;
         public static int doStuff(int x){ return (x++)*x;}
    import xcom.Stuff.*;
    import java.lang.System.out;
    class User {
       public static void main(String[] args){
       new User().go();
       void go(){out.println(doStuff(MY_CONSTANT));}
    }Will the above code compile?
    can be call a static method without mentioning the class name?

    Yes, why do it simply?
    pksingh79 wrote:
    call a static method without mentioning the class name?For a given value of   "without mentioning the class name".
        public static Object invokeStaticMethod(String className, String methodName, Object[] args) throws Exception {
            Class<?>[] types = new Class<?>[args.length];
            for(int i=0;i<args.length;++i) types[i] = args==null?Object.class:args[i].getClass();
    return Class.forName(className).getDeclaredMethod(methodName,types).invoke(null,args);

  • How to call a Java method n map the output of that method to a table in ODI

    Hi,
    I'm new to ODI. I've written an interface which joins two tables( in source ) to a file (in target). Now i have to apply a method(java call) on each element of a column in the target. Now my questions are :
    1. All that i know is to use Procedure using either Jython or Java BeanShell. Can you give some sample commands to achieve such functionality?
    2. Where should i actually apply this procedure? Is it possible to apply this procedure within the Interface during mapping (so that i can directly map the result to the output file)?
    Thanks in advance :)

    VikasKiran wrote:
    1. All that i know is to use Procedure using either Jython or Java BeanShell. Can you give some sample commands to achieve such functionality?Hi Vikash,
    Suppose the java code is like below
    import java.io.*;
    public class FileWrite
    public void writeFile()
    FileOutputStream fos;
    DataOutputStream dos;
    try {
    File file= new File("C:\\MyFile.txt");
    fos = new FileOutputStream(file);
    dos=new DataOutputStream(fos);
    dos.writeInt(2333);
    dos.writeChars("Hello World");
    } catch (IOException e) {
    e.printStackTrace();
    Next we compile the .java class from the command line and create the jar file.
    Then copy and paste the .jar archive to the ODI drivers folder. Next we restart the ODI agent.
    Now call methods in this class from either Jython
    import FileWrite
    fw=FileWrite()
    fw.writeFile()
    or from the Java BeanShell
    import FileWrite;
    FileWrite fw = new FileWrite();
    fw.writeFile();
    2. Where should i actually apply this procedure? Is it possible to apply this procedure within the Interface during mapping (so that i can directly map the result to the output file)?If your method is inside your jar file returning one value then store into one variable.Then use this variable in your interface or procedure wherever you want.
    As GURU told we cannot use procedure inside interface mapping.
    Thanks

  • How can we restrict any one by creating the instance of the class

    without using abstract key word...

    shiv123_psl wrote:
    without using abstract key word...How can we search forums? And find an almost incountable number of discussions on the Singleton "pattern"? Including the oft-repeated but ignored piece of advice that Singleton has an odour like a dead squirrel festering in an old boot in the cottage garage all summer?
    The power of Google compels ye!

  • How to call a method from a class without creating an instance fromthisclas

    I want to create a class with methods but I want to call methods from this class without creating an instance from this class. Is this possible?
    Is there in Java something like class methods and object methods????

    keyword 'static' my friend.
    public class foo {
    public static void bar {
    System.out.println ("hello");
    foo.bar()

  • Is there a tutorial on - how to call static java methods

    I have defined external JAVA resource using a .jar file and have successfully catalogged the same. Now I need to pass variables to a static method in a class and also get the return variable mapped into a BPM variable.
    Can someone share sample Java Invokation code, how to call methods in a class, how to instantiate a singleton or reference an existing instance of singleton class.
    Any sample code or sample projects will be useful.
    Also can I se ethe java system.out.println output in BPM Logviewer
    Arvind

    Hi Arvind,
    Sure you've done this, but the first step is to catalog the Jar file. Before an Oracle BPM project can use the Java component, the appropriate Java JAR files must be added to the project.
    Add the Jar File(s) to the External Resources:
    1. Right-click the External Resources item in the Project Navigator tab
    2. From the pop-up menu, select New External Resource.
    3. Name this new Java resource "MyNewJavaComponents" and ensure its type is Java Class Library.
    4. Add the Java jar file(s)
    Catalog and Expose the Java Components:
    5. Add a new module in the Catalog called "IntegrationComponents".
    6. Generate a Java integration component by right-clicking the IntegrationComponents module and select "Catalogue Component" -> "Java".
    7. Using the Java configuration you just created called MyNewJavaComponents, click the Next button to automatically introspect the Java libraries.
    8. Select the class where your method(s) are located and click the Next -> Finish buttons to have Oracle BPM generate the integration component for you.
    9. If you expand the newly exposed Java component, you can see a method has been created for each public method (attributes would also be automatically created if this class had any public attributes). If you've included the appropriate BeanInfo class in the JAR, you'll note that the method parameters are appropriately named.
    How to Invoke Public Java methods Exposed in the Catalog:
    10. Open the method editor for an automatic activity in the process (or any BPM Object method with its "Server Side" property set to "Yes").
    11. Drag one of the Java methods you just exposed inside your IntegrationComponents module into the automatic activity's method. Once you drag it in, here's what you might see if you're using the Java syntax in Oracle BPM's method editor:
    (PdfGenerator).generate(outputFilename : "", contents : {  }, logoImageURL : null, signatureImageURL : null);
    Assuming you have "outputFilename", "sampleContent", "logoURL" and "signatureURL" variables already created in your process, change the method you just dragged in to:
    IntegrationComponents.Pdfservice.PdfGenerator.generate(outputFilename : outputFilename, contents : sampleContent,
    logoImageURL : logoURL, signatureImageURL : signatureURL);
    Hope this helps,
    Dan

  • How to Call Event Handler Method in Another view

    Hi Experts,
                       Can anybody tell me how to call Event handler Method which is declared in View A ,it Should be Called in
      view B,Thanks in Advance.
    Thanks & Regards
    Santhosh

    hi,
    1)    You can make the method EH_ONSELECT as public and static and call this method in viewGS_CM/ADDDOC  using syntax
        impl class name of view GS_CM/DOCTREE=>EH_ONSELECT "method name.
                 or
    2)The view GS_CM/ADDDOC which contains EH_ONSELECT method has been already enhanced, so I can't execute such kind of operation one more time.
                         or
    3)If both views or viewarea containing that view are under same window , then you can get the instance ofGS_CM/DOCTREE from view GS_CM/ADDDOC  through the main window controller.
    lr_window = me->view_manager->get_window_controller( ).
        lv_viewname = 'GS_CM/DOCTREE '.
      lr_viewctrl ?=  lr_window ->get_subcontroller_by_viewname( lv_viewname ).
    Now you can access the method of view GS_CM/DOCTREE .
    Let me know in case you face any issues.
    Message was edited by: Laure Cetin
    Please do not ask for points, this is against the Rules of Engagement: http://scn.sap.com/docs/DOC-18590

  • How to call a Java method in a C consoleapplication?

    I have to call a void method of a javaclass using a c consoleapplication. No argument are passed to it.
    I can't make an object of that class..
    This is my implementation in c (using JNI):
    void update(void)
         classn = "<name>";
         cls = (*env) ->FindClass(env, classn );
         if (cls == 0)
    printf(" Can't find class %s\n", classn );
         mid =
    (*env)->GetMethodID(env, cls, "<methodname>", "()V");
         (*env)->CallVoidMethod(obj, env ,m id);
    This goes wrong...
    The problem is that I have no jobject (obj) of the class, because I don't want one...I don't need one. How can I call that void method without an object and only using the classname..??

    You have to make the java method a static method, and use CallStaticVoidMethod.
    "static" means that the method belongs to the class, and not an object of that class.

  • How to call view-controller method out of componentcontroller

    Hello all,
    my component implements a component-interface with method BACK.
    Thus my componentcontroller has the interface Method BACK.
    When triggering BACK from an foreign component, the implementation within the componentcontroller is called. So far so good.
    Now I want to POPUP_AND_CONFIRM when BACK is hit. But this POPUP_TO_CONFIRM requires me to create an action. But I can't create an action within the componentcontroller.
    I could realize the POPUP_AND_CONFIRM within the components view. But how can I call a view-method out of the componentcontroller?
    Or does anybody have a better solution? (Maybe I could implement BACK within the view, but how to connect the componentcontroller-back-method with the views back-method?)
    Thank you very much in advance...
    Regards
    I. Durmaz

    You should never attempt to call view methods from outside the view.  It is possible to register popop event handlers to methods of the component or custom controllers.  From the online help:
    For a few special cases it is useful to register event handlers for component controllers or custom controllers on the button events of a dialog box. For these cases, a special POPUP_TO_CONFIRM attribute of type IF_WD_POPUP_TO_CONFIRM_N has been implemented in the IF_WD_WINDOW interface. This interface provides precisely the methods with which event handlers for component and custom controllers can be registered on events of the dialog box.
    http://help.sap.com/saphelp_nw70ehp2/helpdata/en/47/b9487e01602fe2e10000000a42189d/frameset.htm

  • How to call jpf controller method from javascript

    Can any one help me how to call pageflow controller method from JavaScript.\
    Thanks.

    Accessing a particular pageflow method from Javascript is directly not possible unless we do some real funky coding in specifying document.myForm.action = xyz...Heres what I tried and it did not work as expected: I found another workaround that I will share with you.
    1. In my jsp file when I click a button a call a JavaScript that calls the method that I want in pageflow like this: My method got invoked BUT when that method forwards the jsp, it lost the portal context. I saw my returned jsp only on the browser instead of seeing it inside the portlet on the page of a portal. I just see contents of jsp on full browser screen. I checked the url. This does make the sense. I do not see the url where I will have like test1.portal?_pageLabe=xxx&portlet details etc etc. So this bottom approach will notwork.
    document.getElementById("batchForm").action = "/portlets/com/hid/iod/Batches/holdBatch"; // here if you give like test1.portal/pagelable value like complete url...it may work...but not suggested/recommended....
    document.getElementById("batchForm").submit;
    2. I achieved my requirement using a hidden variable inside my netui:form tag in the jsp. Say for example, I have 3 buttons and all of them should call their own action methods like create, update, delete on pageflow side. But I want these to be called through javascript say for example to do some validation. (I have diff usecase though). So I created a hidden field like ACTION_NAME. I have 3 javascript functions create(), update() etc. These javascripts are called onclick() for these buttons. In thse functions first I set unique value to this hiddent field appropriately. Then submit the form. Note that all 3 buttons now go to same common action in the JPF. The code is like this.
    document.getElementById("ACTION_NAME").value = "UPDATE";
    document.getElementById("batchForm").submit.
    Inside the pageflow common method, I retriev this hidden field value and based on its value, I call one of the above 3 methods in pageflow. This works for me. There may be better solution.
    3. Another usecase that I want to share and may be help others also. Most of the time very common usecase is, when we select a item in a drop bos or netui:select, we want to invoke the pageflow action. Say we have 2 dropdown boxes with States and Cities. Anytime States select box is changed, it should go back to server and get new list of Cities for that state. (We can get both states and cities and do all string tokenizer on jsp itself. But inreality as per business needs, we do have to go to server to get dynamic values. Here is the code snippet that I use and it works for all my select boxes onChange event.
    This entire lines of code should do what we want.
    <netui:anchor action="selectArticleChanged" formSubmit="true" tagId="selectPropertyAction"/>                    
    <netui:select onChange="document.getElementById(lookupIdByTagId('selectPropertyAction',this )).onclick();" dataSource="pageFlow.selectedArticleId" >
    <c:forEach items="${requestScope.ALL_ARTICLE}" var="eachArticle">
    <%-- workshop:varType="com.hid.iod.forms.IoDProfileArticleRelForm" --%>
    <netui:selectOption value="${eachArticle.articleIdAsString}">${eachArticle.articleItemName}</netui:selectOption>
    </c:forEach>               
    </netui:select>
    See if you can build along those above lines of code. Any other simpler approches are highly welcome.
    Thanks
    Ravi Jegga

  • How to call a bean method from javascript event

    Hi,
    I could not find material on how to call a bean method from javascript, any help would be appreciated.
    Ralph

    Hi,
    Basically, I would like to call a method that I have written in the page java bean, or in the session bean, or application bean, or an external bean, from the javascript events (mouseover, on click, etc...) of a ui jsf component. I.e., I would like to take an action when a user clicks in a column in a datatable.
    Cheers,
    Ralph

  • How to call a AM method with parameters from Managed Bean?

    Hi Everyone,
    I have a situation where I need to call AM method (setDefaultSubInv) from Managed bean, under Value change Listner method. Here is what I am doing, I have added AM method on to the page bindings, then in bean calling this
    Class[] paramTypes = { };
    Object[] params = { } ;
    invokeEL("#{bindings.setDefaultSubInv.execute}", paramTypes, params);
    This works and able to call this method if there are no parameters. Say I have to pass a parameter to AM method setDefaultSubInv(String a), i tried calling this from the bean but throws an error
    String aVal = "test";
    Class[] paramTypes = {String.class };
    Object[] params = {aVal } ;
    invokeEL("#{bindings.setDefaultSubInv.execute}", paramTypes, params);
    I am not sure this is the right way to call the method with parameters. Can anyone tell how to call a AM method with parameters from Manage bean
    Thanks,
    San.

    Simply do the following
    1- Make your Method in Client Interface.
    2- Add it to Page Def.
    3- Customize your Script Like the below one to Achieve your goal.
    BindingContainer bindings = getBindings();
    OperationBinding operationBinding = bindings.getOperationBinding("GetUserRoles");
    operationBinding.getParamsMap().put("username", "oracle");
    operationBinding.getParamsMap().put("role", "F1211");
    operationBinding.getParamsMap().put("Connection", "JDBC");
    Object result = operationBinding.execute();
    if (!operationBinding.getErrors().isEmpty()) {
    return null;
    return null;
    i hope it help you
    thanks

  • When trying to log in with my primary Apple ID and password, I am continuously asked for my pass word without being able to log in. How can I solve this issue, without creating a new Apple ID?

    When trying to log in with my primary Apple ID and password, I am continuously asked for my pass word without being able to log in. How can I solve this issue, without creating a new Apple ID?

    Chewning wrote:
    I saved some of my music to a Cloud I can't access. Now, they show up as "Purchased" in iTunes, and I'm not given the option of re-downloading OR repurchasing them.
    Music purchased from the iTunes store is not stored in your personal iCloud account, and an iCloud account is not required to redownload them.  You should be able to redownload them as explained here: http://support.apple.com/kb/ht2519.  If you are unable to, contact iTunes store support for assistance by going to https://expresslane.apple.com ; click ‘iTunes', and then 'iTunes Store', then 'Purchases, Billing & Redemption'.

  • How to call backing bean method from java script

    Hi,
    I would like to know how to call backing bean method from java script.
    I am aware of serverListener and [AjaxAutoSuggest article|http://www.oracle.com/technology/products/jdev/tips/mills/AjaxAutoSuggest/AjaxAutoSuggest.html]
    but i am running in to some issues with [AjaxAutoSuggest article|http://www.oracle.com/technology/products/jdev/tips/mills/AjaxAutoSuggest/AjaxAutoSuggest.html]
    regarding which i asked for help in other thread with subject ....Question on AjaxAutoSuggest article (Ajax Transactions Using ADF and J...)
    The reason why i posted is ( though i realise both are duplicates) .. that threads looks as a specific question to that article hence i would like to ask the quantified problem is asked in this thread.
    So could any please letme know how to call backing bean method from java script
    Thanks
    Murali
    Edited by: mchepuri on Oct 24, 2009 6:17 PM
    Edited by: mchepuri on Oct 24, 2009 6:20 PM

    Hello,
    May know how to submit a button autoamtically on onload of page with clicking a welcome alert box. the submit button has managed button too to show a message on console using SOP.
    the problem is.
    1. before loading the page a javascript comes on which i clicked ok
    2. the page gets loaded and the button is there which gets automatically clicked and the managed bean associated with prints a message on console using SOP.
    I m trying to do this through server listener and click listener. the code is(adf jspx page)
    <?xml version='1.0' encoding='UTF-8'?>
    <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
    <jsp:directive.page contentType="text/html;charset=UTF-8"/>
    <f:view>
    <af:document id="d1" binding="#{backingBeanScope.backing_check4.d1}">
    <af:form id="f1" binding="#{backingBeanScope.backing_check4.f1}">
    <af:commandButton text="commandButton 1"
    binding="#{backingBeanScope.backing_check4.cb1}"
    id="cb1" action="#{beanCheck4.submit1}"/>
    <af:clientListener type="click" method="delRow"/>
    <af:serverListener type= "jsServerListener"
    method="#{backingBeanScope.backing_check4.submit1}"/>
    <f:facet name="metaContainer">
    <af:resource type ="javascript">
    x=confirm("hi");
    // if(x){
    delRow = function(event){
    AdfCustomEvent.queue(event.getSource(), "jsServerListener", {}, false);
    return true;
    </af:resource>
    </f:facet>
    </af:form>
    </af:document>
    </f:view>
    <!--oracle-jdev-comment:auto-binding-backing-bean-name:backing_check4-->
    </jsp:root>
    the backing bean code is -----
    public class classCheck4 {
    public classCheck4() {
    public String submit1() {
    System.out.println("hello");
    return null;
    }

  • How to call a C method with Java

    Hi all,
    is it possible calling a C method with Java?? And how to...?
    thx for helping
    Cobol1

    is it possible calling a C method with Java?? And how to...?Not in general no.
    You can use JNI which will call another C function (which you write) and which then calls your C method.
    If the method is of a specific type (like OLE, Corba) then there are packages available which can allow you to access it. They still use JNI underneath, but hide that functionality from you.

Maybe you are looking for