Call a static method via RFC

Hello people,
How can I call a static method via RFC?
I am in SRM and would like to call a static method defined in ECC.
What is necessary to be configured in this class/method?
Thanks!!!

You may need to write RFC in ECC and call it from SRM
and write following code in RFC for call a static method
reference_obj=>method_name
EXPORTING

Similar Messages

  • How to call a static method from an event handler

    Hi,
       I'm trying to call a static method of class I designed.  But I don't know how to do it.  This method will be called from an event handler of a web dynpro for Abap application.
    Can somebody help me?
    Thx in advance.
    Hamza.

    To clearly specify the problem.
    I have a big part code that I use many times in my applications. So I decided to put it in a static method to reuse the code.  but my method calls functions module of HR module.  but just after the declaration ( at the first line of the call function) it thows an exception.  So I can't call my method.

  • How to call a static method in a class if I have just the object?

    Hello. I have an abstract class A where I have a static method blah(). I have 2 classes that extend class A called B and C. In both classes I override method blah(). I have an array with objects of type B and C.
    For every instance object of the array, I'm trying to call the static method in the corresponding class. For objects of type B I want to call blah() method in B class and for objects of type C I want to call blah() method in C class. I know it's possible to call a static method with the name of the object, too, but for some reason (?) it calls blah() method in class A if I try this.
    So my question is: how do I code this? I guess I need to cast to the class name and then call the method with the class name, but I couldn't do it. I tried to use getClass() method to get the class name and it works, but I didn't know what to do from here...
    So any help would be appreciated. Thank you.

    As somebody already said, to get the behavior you
    want, make the methods non-static.You all asked me why I need that method to be
    static... I'm not surprised to hear this question
    because I asked all my friends before posting here,
    and all of them asked me this... It's because some
    complicated reasons, I doubt it.
    the application I'm writing is
    quite big...Irrelevant.
    Umm... So what you're saying is there is no way to do
    this with that method being static? The behavior you describe cannot be obtained with only static methods in Java. You'd have to explicitly determine the class and then explicitly call the correct class' method.

  • 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);

  • Calling a static method when starting the server???

    Hi,
    i wanted to call a static method of a java class,
    whenever i start the server.
    plz give some input on this.
    thanks and regards
    siva

    Siva -- Can you be more specific as to the problem you are trying to solve (why do you want to call this static method,.)
    The reason I ask is that there are some ways to make this happen but they may have limitations
    that won't work for you. For instance, you can create a servlet that calls your class' static method and then make the
    servlet be loaded on startup.
    Thanks -- Jeff

  • Initializer block not called when static method called

    public class Initializer {
         Initializer(){
              System.out.println("Constructor called");
                   System.out.println("CLASS INITIALIZED");
         static void method(){
              System.out.println("Static method called");
         public static void main(String[] args) {
              Initializer.method();
    From the JLS
    A class or interface type T will be initialized immediately before the first occurrence of any one of the following:
    T is a class and an instance of T is created.
    T is a class and a static method declared by T is invoked.
    [b]
    But when i call the static method , if the class is initialized shouldnt the initializer block be called, it is not called, why.

    Perhaps running something like this will add a little more colour?:
    public class Initializer {
        static {
            System.out.println("First static initializer");
            System.out.println("First instance initializer");
        Initializer() {
            System.out.println("Constructor");
        static {
            System.out.println("Second static initializer");
            System.out.println("Second instance initializer");
        static void staticMethod() {
            System.out.println("staticMethod");
        void instanceMethod() {
            System.out.println("instanceMethod");
        public static void main(String[] args) {
            System.out.println("main");
            staticMethod();
            new Initializer().instanceMethod();
    }

  • Calling a static method from another class

    public class Command
        public static void sortCommands(String command, String order, List object)
             if(command.equalsIgnoreCase("merge") && order == "a")
                  object.setAscending(true);
                  Mergesort.mergesort(object.list);                  // line 85
    }and
    public class Mergesort
         public static void mergesort (int[] a)
              mergesort(a, 0, a.length-1);
         private static void mergesort (int[] a, int l, int r)
         private static void merge (int[] a, int l, int m, int r)
    }Error:
    Command.java:85: cannot find symbol
    symbol : variable Mergesort
    location: class Command
    Mergesort.mergesort(object.list)
    What am I doing wrong here? Within the Command class I am calling mergesort(), a static method, from a static method. I use the dot operator + object so that the compiler would recognize the 'list' array. I tried using the
    Mergesort.mergesort(object.list);notation in hopes that it would work like this:
    Class.staticMethod(parameters);but either I am mistaken, misunderstood the documentation or both. Mergesort is not a variable. Any help would be appreciated, I have been hitting a brick wall for hours with Java documentation. Thanks all.

    [Javapedia: Classpath|http://wiki.java.net/bin/view/Javapedia/ClassPath]
    [How Classes are Found|http://java.sun.com/j2se/1.5.0/docs/tooldocs/findingclasses.html]
    [Setting the class path (Windows)|http://java.sun.com/j2se/1.5.0/docs/tooldocs/windows/classpath.html]
    [Setting the class path (Solaris/Linux)|http://java.sun.com/j2se/1.5.0/docs/tooldocs/solaris/classpath.html]
    [Understanding the Java ClassLoader|http://www-106.ibm.com/developerworks/edu/j-dw-javaclass-i.html]
    java -cp .;<any other directories or jars> YourClassNameYou get a NoClassDefFoundError message because the JVM (Java Virtual Machine) can't find your class. The way to remedy this is to ensure that your class is included in the classpath. The example assumes that you are in the same directory as the class you're trying to run.
    javac -classpath .;<any additional jar files or directories> YourClassName.javaYou get a "cannot resolve symbol" message because the compiler can't find your class. The way to remedy this is to ensure that your class is included in the classpath. The example assumes that you are in the same directory as the class you're trying to run.

  • JCO RFC Provider: "Bean not found" when calling EJB from ABAP via RFC

    Hello,
    I'm having trouble calling an EJB in a CE 7.1 system from ABAP via RFC. I'm trying to use the JCO RFC Provider service, which mean that I want to expose an EJB so that it can be called via Remote Function Call.
    I have documented everything, including the code and the deployment descriptors I wrote, in this thread in the CE forum: Jco RFC Provider: Bean not found
    If there's any chance you can help, please do me a favour and look into the problem.
    Thanks a lot!
    Thorsten

    Hi Vladimir,
    Thank you very much, your help was immensely valuable.
    I just had to add the function declaration to the Home Component interface, everything else was correct, and now it works.
    Cheers,
    Thorsten

  • Can TDMS Call a Custom Algorithm (via RFC) to Scramble a Value?

    Hi,
    Background: Our SAP is one of many systems in an integrated environment. We are looking at scrambling data across all systems for testing purposes. The implication is that if we scramble a field in a non-SAP system using a specific scrambling algorithm (provided by a non-SAP test data management tool) and that field also exists in the SAP system, then the same scrambling algorithm must be used in SAP as well.
    Question: Does anyone know or have tried calling a low level scrambling algorithm (via RFC call) to scramble the value of a field? This scrambling algorithm is a C library routine. The vendor said they can wrap it into an RFC call.
    Thank you in advance for any insights you can provide.
    Luke Lau
    IS Solutions Leader
    Insurance Corporation of British Columbia

    As far as I know calling an RFC from TDMS workbench is the same as calling an RFC from any abap program so as long as the destination is configured you shouldn't have any problems.
    Check here:
    http://help.sap.com/saphelp_nw04/helpdata/en/22/042537488911d189490000e829fbbd/content.htm
    Bruno

  • UnsatisifiedLinkError calling overloaded static method

    I'm sure I'm doing something dumb but I can't figure it out. I am getting an UnsatisifiedLinkError when I call one of the two following overloaded methods.
    Here's the java class:
      public native static RtaPlcAddress create(String address, int elements);
      public native static RtaPlcAddress create(String address, Type type,
                                                int elements);Here's a snipet of the c code:
    JNIEXPORT jobject JNICALL Java_Packages_RTA_RtaPlcAddress_create__Ljava_lang_String_2LPackages_RTA_RtaPlcAddress_Type_2I
      (JNIEnv *pEnv, jclass cl, jstring address, jobject type, jint elements)
      jobject
        retval = NULL;
      const char
        *pAddress;
      PLC_ADDRESS_STR
        *pPlcAddr;
      jclass
        classType = (*pEnv)->GetObjectClass(pEnv, type);
      jmethodID
        valueId,
        elementSizeId;
    JNIEXPORT jobject JNICALL Java_Packages_RTA_RtaPlcAddress_create__Ljava_lang_String_2I
      (JNIEnv *pEnv, jclass cl, jstring address, jint elements)
      jobject
        retval = NULL;
      const char
        *pAddress;
      PLC_ADDRESS_STR
        *pPlcAddr;
      PCCC_ADDRESS_STR
        addr;
    }I am getting the function declarations by running javah on the class and pulling them from the header file that was created so I'm sure I have the correct function declaration.
    Both functions show exported when I used the dumpbin program on the DLL that was created.
    Anyway, when I use the create method with 2 parameters (String, int), everything works but when I do the other, I get the error. I can't figure it out.
    This is on Windows XP SP3 with JDK 1.6.0_14.
    Thanks

    searay268 wrote:
    I just tried what you suggested by changing the name of the method that's giving the error to "bill". Obviously, the function call for the other "create" method that works changed so I handled that as well. I don't understand that statement.
    You started with "create" which is overloaded with two instances.
    You then change the name of one of them, only one, to "bill".
    See if both methods then work.
    That is what I suggested.
    Once I did that, everything worked. I then changed it back to "create" and I got the error again.If you did what I suggested above then try the following.
    1. Change one to "billxxx" - where the 'xxx' is to insure absolutely nothing else matches.
    2. Verify it works for both methods (where one is still "create").
    3. Change the second one to "billxxx".
    4. See if both methods work.
    If 4 is an error, then yes it is a bug.
    You then should create a small test case that demonstrates it. For that try primitive parameters to see if it makes a difference.

  • How to call a static method of a class from another class?

    Hello,
    I have two classes in a package. The first one
    package my package;
    public class class1
    protected static ImageIcon createIcon(String path)
    The second one
    package my package;
    public class class2
    private ImageIcon image1;
    image1 = class1.createIcon("/mypath");
    This does not work since class2 cannot load the appropriate image. Where do I have to define the ImageIcon variables in class one or two and do they have to be static variables?
    Thanks in advance
    Christos

    If the two classes are in the same package, that will work, in fact. A trivial example:
    package foo;
    public class Foo1 {
         protected static String getString() {
              return "World";
    // Note: Member of the same package
    package foo;
    public class Foo2 {
         public static void main(String[] argv) {
              System.out.println("Hello "+ foo.Foo1.getString());
    }However, if they are in different packages that won't work - the protected keyword guarantees that only classes derived from the class with the protected method can access it: Therefore this will not work:
    package foo;
    public class Foo1 {
         protected static String getString() {
              return "World";
    package foo.bar;
    public class Foo2{
         public static void main(String[] argv) {
              System.out.println("Hello "+ foo.Foo1.getString());
    }But this will:
    package foo;
    public class Foo1 {
         protected static String getString() {
              return "World";
    package foo.bar;
    public class Foo2 extends foo.Foo1 {
         public static void main(String[] argv) {
              System.out.println("Hello "+ foo.Foo1.getString());
    }I think you should read up a bit more about packages and inheritance, because you're going to have a lot of trouble without a good understanding of both. Try simple examples first, like the above, and if you hit problems try to produce a simple test case to help you understand the problem rather than trying to debug your whole application.
    Dave.

  • How to call a static method of a class (continued)

    In reference to the above topic posted one week ago I give you the relative code. The problem is resolved and it was the following one (amazing for me since I looked for any possible error in the code like the one posted in my article but I could never imagine this trivial thing.........):
    the package name which is the directory with the appropriate class files should not extend the lenght of 8 characters!!! Initially I had a package named Applications (too long for DOS...) and when I renamed it to Test everything worked. Any suggestion on how to overcome this DOS filesystem problem?
    Christos
    Here is my simplified code
         package test;
         import java.io.*;
         import java.net.URL;
         import javax.swing.*;
         import java.beans.*;
         import java.awt.*;
         import java.awt.event.*;
         public class myapplet extends JApplet
         private MyClass myframe;
         private JDesktopPane desktop;
         private Dimension d;
    public void init() {
    myframe= new MyClass();
    desktop = new JDesktopPane();
    d=desktop.getSize();
    try {
    javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
    public void run() {
    createGUI();
    } catch (Exception e) {
    System.err.println("createGUI didn't successfully complete");
         private void createGUI() {
         myframe.pack();
         myframe.setBounds(0,0,d.width,d.height);
         desktop.add(myframe);
         this.getContentPane().add(desktop);
         try {
         myframe.setMaximum(true);
         } catch (PropertyVetoException e) {
         e.printStackTrace();
         myframe.setVisible(true);
    protected static ImageIcon createAppletImageIcon(String path,
    String description)
    int MAX_IMAGE_SIZE = 75000; //Change this to the size of
    //your biggest image, in bytes.
    int count = 0;
    BufferedInputStream imgStream = new BufferedInputStream(
    myapplet.class.getResourceAsStream(path));
    if (imgStream != null)
    byte buf[] = new byte[MAX_IMAGE_SIZE];
    try {
    count = imgStream.read(buf);
    } catch (IOException ieo) {
    System.err.println("Couldn't read stream from file: " + path);
    try {
    imgStream.close();
    } catch (IOException ieo) {
    System.err.println("Can't close file " + path);
    if (count <= 0) {
    System.err.println("Empty file: " + path);
    return null;
    return new ImageIcon(Toolkit.getDefaultToolkit().createImage(buf),
    description);
    } else {
    System.err.println("Couldn't find file: " + path);
    return null;
    followed by the class MyClass
    package test;
         import javax.swing.*;
         import java.awt.*;
         import java.awt.event.*;
         public class MyClass extends JInternalFrame
         private JLabel jl;
         private String myicon1="images/myimage.gif";
         private ImageIcon image1;
         public MyClass()
         super ( "This is my application",false,true,true,false);
         setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    image1= myapplet.createAppletImageIcon(myicon1,"");
    jl = new JLabel("This is my image",
              image1,JLabel.CENTER);
    jl.setFont (new Font("Times-Roman",Font.BOLD, 17));
    getContentPane().add(jl);
    and finally the html file with the applet tag:
    <APPLET CODE = "test.myapplet" width=760 height=380>
    </APPLET>

    I have to say that everything works fine even with
    long package names besides the loading of the image in
    MyClass (in fact you see the JInternalFrame with the
    JLabel without icon!). Since I never saw an error in
    the Sun Java Console or the DOS window I tried this
    last solution, i.e. to shorten the package name. Only
    then the icon appears in the label......strange thingsThere shouldn't be a problem with long package (and hence long directory) names.
    private String myicon1="images/myimage.gif"; // which becomes the 'path' variable below
    BufferedInputStream imgStream = new BufferedInputStream(
    myapplet.class.getResourceAsStream(path));So are you sure you are always putting this images subdirectory underneath where your myapplet class lives? If myapplet.class lives in /foo/bar/mypackage, belongs to the 'mypackage' package, and your classpath includes /foo/bar, then your gif file better be at /foo/bar/mypackage/images/myimage.gif (or actually at mypackage/images/myimage.gif from any classpath root)

  • Reflection: how to call static method?

    You can call an instance method for an object via
    Method method = myClass.getDeclaredMethod(mName, mTypes);
    Object value = method.invoke(instance, mValues);But how do you call a static method (that is perhaps in an abstract class)? Is it save to have the instance variable null?

    Is it save [sic] to have the instance variablenull?Please refrain to mock at that, Peter. Even the
    English often confuse "loose" and "lose", don't be
    that critical to foreigners. :-)Is there something wrong? I just serach via google:
    "is it save to" ... results: 800 ...
    Okay, "is it safe to" : 636.000 ... :-)

  • Compilation error while calling static method from another class

    Hi,
    I am new to Java Programming. I have written two class files Dummy1 and Dummy2.java in the same package Test.
    In Dummy1.java I have declared a static final variable and a static method as you can see it below.
    package Test;
    import java.io.*;
    public class Dummy1
    public static final int var1= 10;
    public static int varDisp(int var2)
    return(var1+var2);
    This is program is compiling fine.
    I have called the static method varDisp from the class Dummy2 and it is as follows
    package Test;
    import java.io.*;
    public class Dummy2
    public int var3=15;
    public int test=0;
    test+=Dummy1.varDisp(var3);
    and when i compile Dummy2.java, there is a compilation error <identifier > expected.
    Please help me in this program.

    public class Dummy2
    public int var3=15;
    public int test=0;
    test+=Dummy1.varDisp(var3);
    }test+=Dummy1.varDisplay(var3);
    must be in a method, it cannot just be out somewhere in the class!

  • Calling a non-static method from another Class

    Hello forum experts:
    Please excuse me for my poor Java vocabulary. I am a newbie and requesting for help. So please bear with me! I am listing below the program flow to enable the experts understand the problem and guide me towards a solution.
    1. ClassA instantiates ClassB to create an object instance, say ObjB1 that
        populates a JTable.
    2. User selects a row in the table and then clicks a button on the icon toolbar
        which is part of UIMenu class.
    3. This user action is to invoke a method UpdateDatabase() of object ObjB1. Now I want to call this method from UIMenu class.
    (a). I could create a new instance ObjB2 of ClassB and call UpdateDatabase(),
                                      == OR ==
    (b). I could declare UpdateDatabase() as static and call this method without
         creating a new instance of ClassB.With option (a), I will be looking at two different object instances.The UpdateDatabase() method manipulates
    object specific data.
    With option (b), if I declare the method as static, the variables used in the method would also have to be static.
    The variables, in which case, would not be object specific.
    Is there a way or technique in Java that will allow me to reference the UpdateDatabase() method of the existing
    object ObjB1 without requiring me to use static variables? In other words, call non-static methods in a static
    way?
    Any ideas or thoughts will be of tremendous help. Thanks in advance.

    Hello Forum:
    Danny_From_Tower, Encephalatic: Thank you both for your responses.
    Here is what I have done so far. I have a button called "btnAccept" created in the class MyMenu.
    and declared as public.
    public class MyMenu {
        public JButton btnAccept;
         //Constructor
         public MyMenu()     {
              btnAccept = new JButton("Accept");
    }     I instantiate an object for MyMenu class in the main application class MyApp.
    public class MyApp {
         private     MyMenu menu;
         //Constructor     
         public MyApp(){
              menu = new MyMenu();     
         public void openOrder(){
               MyGUI MyIntFrame = new MyGUI(menu.btnAccept);          
    }I pass this button all the way down to the class detail02. Now I want to set up a listener for this
    button in the class detail02. I am not able to do this.
    public class MyGUI {
         private JButton acceptButton;
         private detail02 dtl1 = new detail02(acceptButton);
         //Constructor
         public AppGUI(JButton iButton){
         acceptButton = iButton;
    public class detail02{
        private JButton acceptButton;
        //Constructor
        public detail02(JButton iButton){
          acceptButton = iButton;
          acceptButton.addActionListener(new acceptListener());               
       //method
        private void acceptListener_actionPerformed(ActionEvent e){
           System.out.println("Menu item [" + e.getActionCommand(  ) + "] was pressed.");
        class acceptListener implements ActionListener {       
            public void actionPerformed(ActionEvent e) {
                   acceptListener_actionPerformed(e);
    }  I am not able to get the button Listener to work. I get NullPointerException at this line
              acceptButton.addActionListener(new acceptListener());in the class detail02.
    Is this the right way? Or is there a better way of accomplishing my objective?
    Please help. Your inputs are precious! Thank you very much for your time!

Maybe you are looking for

  • Windows 7 x64 - iPhone and iTouch - iTunes Sync errors on new HP Dv8

    PROBLEM DESCRIPTION: I just purchased a brand new HP dv8 laptop and cannot get my iphone or itouch synch. I get errors for both the iphone and itouch, but my Nano and shuffle are fine. HP support said that this is a known issue and that the software

  • Why i can't open my hotmail with iphone but safari and laptop can open

    Why i can't open my hotmail with iphone but safari and laptop can open why???

  • Do I have to configure realm policy in Access Manager for IDM SPML Request

    Hi all, I wanted to run a SPML request from my application to the IDM which is presently protected by an AM server. Somehow, I get the following error, while I run a search using SpmlClient: org.openspml.util.SpmlException: Unsupported response conte

  • Which Flash Player

    My company purchased a Flash-based e-learning development tool. It comes with many compiled SWF templates. There are no FLA files to work with. I'm getting inconsistent behaviors and think that the SWF may have been compiled for early, or possibly va

  • Useful function module for get month

    Dear experts, I need some FM to realise some functions : 1, get the month and year from system date 2, get the month by adding or subtracting from a given month ex: month(system date) - 11 Moderator message: date conversion questions = FAQ, please se