Reg: declaring classes, methods, objects

Hi,
Can anyone help me on how do i declare classes and methods in webdynpro. My requirement is to do some functionality in a method of a class and reuse the code wherever i require.
Can anyone help me on this?
Thanks
Regards
Naveen

Hi Naveen George ,
                       You can create methods in both component controller and on each view also.
methods dexlaring in comp controller will be common among all view
you can call comp controller method like comp_controller->method name in other view
and own methods can be called like wd_this-> method name.
you can also use wizard to call methods
for calling own methods you have to select current controller radio button and for comp_controller you hacve to use used controller.
you can create method by going to method tab both in view and component controller
Regards
Sarath

Similar Messages

  • ActiveX in BradySoft (CodeSoft) - What Class/Method/Object's would I use to send variable form data to BradySoft?

    What Class/Method/Object's would I use to send variable form data to BradySoft? I have a basic label setup in BradySoft and I want to send it variable form data (a serial number) from Labview ActiveX. I have attached Brady's ActiveX programmers guide but can't figure out what to use for this. P.S. I would call Brady or TekLynx tech support about this but they have a strict policy whereas BradySoft supports ActiveX but their tech support doesn't provide programming help with it. I figured I'd try the NI Forums.  

    Aaronb, I presume by publishing an ActiveX programmers manual the BradySoft software installs Active X objects. You may choose to interact with these objects within LabVIEW using Active X controls. The following link will provide a starting point for LabVIEW help topics on Active X communication: Select ActiveX Object Dialog Box
    http://zone.ni.com/reference/en-XX/help/371361F-01/lvdialog/insert_active_x_object/
    Building a Simple Web Browser Using ActiveX (Example of ActiveX arcitecture)
    http://zone.ni.com/devzone/cda/epd/p/id/81 Hope this helps provide a bit of guidance. Cheers!  

  • Purpose of declaring the method or class or static and as instance

    what is the purpose of declaring a method in a class or the class itself as static.
    Does it mean we cannot create a copy of that class or method if we declare it as static.
    if so then why do they dont want that class to be created as a copy ?
    Why do they want to declare a class as static
    please provide some conceptual undersatnding regarding the static and instance class with one example

    Static methods are often used for the implementation of utility methods. Please have a look at the class CL_ABAP_CHAR_UTILITIES for example.
    You use the methods of this class in the same way as you would use a function in ABAP (like
    LINES( itab )
    ). You use it in a static way because the functionality is always the same no matter in what context you are calling the function.
    The purpose of instance methods is that their logic is in some way related to an attribute of the object instance that you use to call it.
    For example, you create an instance of object PO (a purchase order) called MY_PO. Then the method
    MY_PO->ADD_POSITION
    would add a position to a concrete PO that has a unique number etc. But if the object has a static method DELETE_POSITION then it just deletes the current position of a PO, regardless on which concrete PO you are acting at the moment.
    I hope this clarifies it for you.
    Regards,
    Mark

  • Clustered timers object is not an instance of declaring class

    WLS 12.1.3 installation, one cluster of two managed servers.
    An enterprise application contains 3 EJB timers. Timers are clustered and persisted to DB (table WEBLOGIC_TIMERS).
    The application is written for JEE version 5 and timers are coded according rto EJB3.0 spec.
    Each time ejbTimeout() triggers for one of the timers, the following exception is logged
    <Error> <EJB> <SRVAW00> <clusterServer_1> <[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'> <<anonymous>> <BEA1-002F16F44C0F7F98CBA5> <> <1426609941352> <BEA-011088> <The following error occurred while invoking the ejbTimeout(javax.ejb.Timer) method of EJB MyBean(Application: MyClusteredApp, EJBComponent: LucyStarEJB.jar).
    javax.ejb.EJBTransactionRolledbackException: EJB Exception:
         at weblogic.ejb.container.internal.BaseLocalObject.handleSystemException(BaseLocalObject.java:452)
         at weblogic.ejb.container.internal.BaseLocalObject.postInvoke1(BaseLocalObject.java:251)
         at weblogic.ejb.container.internal.BaseLocalObject.postInvoke(BaseLocalObject.java:431)
         at weblogic.ejb.container.internal.TimerDrivenLocalObject.postInvoke(TimerDrivenLocalObject.java:44)
         at weblogic.ejb.container.timer.TimerHandlerImpl$TimerObject.execute(TimerHandlerImpl.java:131)
         at weblogic.ejb.container.timer.TimerHandlerImpl.executeTimer(TimerHandlerImpl.java:45)
         at weblogic.ejb.container.timer.ClusteredTimerImpl.timerExpired(ClusteredTimerImpl.java:95)
         at weblogic.scheduler.ejb.internal.EJBListenerWrapper.executeTimer(EJBListenerWrapper.java:59)
         at weblogic.scheduler.ejb.internal.EJBListenerWrapper.timerExpired(EJBListenerWrapper.java:50)
         at weblogic.scheduler.TimerState$1$2.run(TimerState.java:200)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:146)
         at weblogic.scheduler.TimerState$1.run(TimerState.java:197)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:311)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:263)
    Caused By: java.lang.IllegalArgumentException: object is not an instance of declaring class
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
         at java.lang.reflect.Method.invoke(Method.java:606)
         at weblogic.ejb.container.timer.TimerHandlerImpl$TimerObject.execute(TimerHandlerImpl.java:118)
         at weblogic.ejb.container.timer.TimerHandlerImpl.executeTimer(TimerHandlerImpl.java:45)
         at weblogic.ejb.container.timer.ClusteredTimerImpl.timerExpired(ClusteredTimerImpl.java:95)
         at weblogic.scheduler.ejb.internal.EJBListenerWrapper.executeTimer(EJBListenerWrapper.java:59)
         at weblogic.scheduler.ejb.internal.EJBListenerWrapper.timerExpired(EJBListenerWrapper.java:50)
         at weblogic.scheduler.TimerState$1$2.run(TimerState.java:200)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:146)
         at weblogic.scheduler.TimerState$1.run(TimerState.java:197)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:311)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:263)
    Alternatively, the stack trace is slightly different:
    <[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'> <<anonymous>> <BEA1-012838E30163E6919A1F> <> <1426809856301> <BEA-011088> <The following error occurred while invoking the ejbTimeout(javax.ejb.Timer) method of EJB MyServicesBean(Application: MyAppClustered, EJBComponent: MyEJB.jar).
    javax.ejb.EJBTransactionRolledbackException: EJB Exception:
        at weblogic.ejb.container.internal.BaseLocalObject.handleSystemException(BaseLocalObject.java:452)
        at weblogic.ejb.container.internal.BaseLocalObject.postInvoke1(BaseLocalObject.java:251)
        at weblogic.ejb.container.internal.BaseLocalObject.postInvoke(BaseLocalObject.java:431)
        at weblogic.ejb.container.internal.TimerDrivenLocalObject.postInvoke(TimerDrivenLocalObject.java:44)
        at weblogic.ejb.container.timer.TimerHandlerImpl$TimerObject.execute(TimerHandlerImpl.java:131)
        at weblogic.ejb.container.timer.TimerHandlerImpl.executeTimer(TimerHandlerImpl.java:45)
        at weblogic.ejb.container.timer.ClusteredTimerImpl.timerExpired(ClusteredTimerImpl.java:95)
        at weblogic.scheduler.ejb.internal.EJBListenerWrapper.executeTimer(EJBListenerWrapper.java:59)
        at weblogic.scheduler.ejb.internal.EJBListenerWrapper.timerExpired(EJBListenerWrapper.java:50)
        at weblogic.scheduler.TimerState$1$2.run(TimerState.java:200)
        at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
        at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:146)
        at weblogic.scheduler.TimerState$1.run(TimerState.java:197)
        at weblogic.work.ExecuteThread.execute(ExecuteThread.java:311)
        at weblogic.work.ExecuteThread.run(ExecuteThread.java:263)
    Caused By: java.lang.IllegalArgumentException: java.lang.ClassCastException@402f37c8
        at sun.reflect.GeneratedMethodAccessor225.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at weblogic.ejb.container.timer.TimerHandlerImpl$TimerObject.execute(TimerHandlerImpl.java:118)
        at weblogic.ejb.container.timer.TimerHandlerImpl.executeTimer(TimerHandlerImpl.java:45)
        at weblogic.ejb.container.timer.ClusteredTimerImpl.timerExpired(ClusteredTimerImpl.java:95)
        at weblogic.scheduler.ejb.internal.EJBListenerWrapper.executeTimer(EJBListenerWrapper.java:59)
        at weblogic.scheduler.ejb.internal.EJBListenerWrapper.timerExpired(EJBListenerWrapper.java:50)
        at weblogic.scheduler.TimerState$1$2.run(TimerState.java:200)
        at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
        at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:146)
        at weblogic.scheduler.TimerState$1.run(TimerState.java:197)
        at weblogic.work.ExecuteThread.execute(ExecuteThread.java:311)
        at weblogic.work.ExecuteThread.run(ExecuteThread.java:263)
    It seems that this exception is not enough to stop timer schedulation, because it goes on and on. In some way, therefore, WLS keeps track of the timer recurring expirations. On the other hand, my code in ejbTimeout() is never executed.
    What is causing these exceptions ? The stack trace is fully in WLS internal code.
    Thanks

    Indeed, the AbstractPageBean is a JSF managed bean. What does it mean to me?
    I want to add some Information:
    If I build a 'helper' class, with the following body, the same error is thrown:
    public class EJBTestHelper {
        private EJBTestRemote lookupEJBTestBean() {
                try {
                    Context c = new InitialContext();
                    return (EJBTestRemote) c.lookup("java:comp/env/ejb/EJBTestBean");
                } catch (NamingException ne) {
                    throw new RuntimeException(ne);
    }What can I do?

  • IllegalArgumentException: object is not an instance of declaring class

    Hi all,
    I know that this is the not exact forum to post this issue.
    I'm working on a clustered environment and my server details are given below
    a) jboss-4.0.2
    b) J2SDK-1.4.2_09
    In my jboss.xml file, I have defined
           <session>
                <ejb-name>ExampleSLBean</ejb-name>
                <jndi-name>ExampleSLHome</jndi-name>
                <cache-invalidation>true</cache-invalidation>
                <clustered>true</clustered>
           </session>And in my servlet i have written below code to lookup up a Stateless Session bean
    Hashtable hashtable = new Hashtable();
    hashtable.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
    hashtable.put(Context.URL_PKG_PREFIXES, "jboss.naming:org.jnp.interfaces");
    hashtable.put(Context.PROVIDER_URL, "localhost:1100");
    Context context = new InitialContext(hashtable);            
    Object objectRef = context.lookup("ExampleSLHome");
    System.out.println("objectRef ::: "+objectRef)
    ExampleSLHome home = (ExampleSLHome) PortableRemoteObject.narrow(objectRef, ExampleSLHome.class);after the context.lookup("ExampleSLHome") statement, I'm getting the error as
    java.lang.IllegalArgumentException: object is not an instance of declaring class.
    I'm not able to find the possible cause of the problem.
    Please help me
    thanks
    arvind

    Try this:
    Class objCls = Class.forName ("ClassName");
    Object obj = objCls.newInstance();
    method.invoke(objCls , null);
    This will throw an exception. However, following will work:
    method.invoke(obj , null);
    OR
    method.invoke(new ClassName(), null);
    Refer to the following thread for detailed discussion:
    http://forum.java.sun.com/thread.jspa?threadID=439811&messageID=1980996

  • A function module or class/method to look up repository objects?

    Hi,
    Does anyone know of a class/method or a function module that returns back objects of a namespace in the integration repository.
    For example, I would like to be able to retrieve all the message interfaces of a particular namespace.
    Thanks in advance,
    Duke

    Hi Duke,
    I am not sure about the function module. But you can look up all the objects with their IDs using transaction sxi_cache.
    Regards,
    Ramesh P

  • Static Classes/Methods vs Objects/Instance Classes/Methods?

    Hi,
    I am reading "Official ABAP Programming Guidelines" book. And I saw the rule:
    Rule 5.3: Do Not Use Static Classes
    Preferably use objects instead of static classes. If you don't want to have a multiple instantiation, you can use singletons.
    I needed to create a global class and some methods under that. And there is no any object-oriented design idea exists. Instead of creating a function group/modules, I have decided to create a global class (even is a abstract class) and some static methods.So I directly use these static methods by using zcl_class=>method().
    But the rule above says "Don't use static classes/methods, always use instance methods if even there is no object-oriented design".
    The book listed several reasons, one for example
    1-) Static classes are implicitly loaded first time they are used, and the corresponding static constructor -of available- is executed. They remain in the memory as long as the current internal session exists. Therefore, if you use static classes, you cannot actually control the time of initialization and have no option to release the memory.
    So if I use a static class/method in a subroutine, it will be loaded into memory and it will stay in the memory till I close the program.
    But if I use instance class/method, I can CREATE OBJECT lo_object TYPE REF TO zcl_class then use method lo_object->method(), then I can FREE  lo_object to delete from the memory. Is my understanding correct?
    Any idea? What do you prefer Static Class OR Object/Instance Class?
    Thanks in advance.
    Tuncay

    @Naimesh Patel
    So you recommend to use instance class/methods even though method logic is just self-executable. Right?
    <h3>Example:</h3>
    <h4>Instance option</h4>
    CLASS zcl_class DEFINITION.
      METHODS add_1 IMPORTING i_input type i EXPORTING e_output type i.
      METHODS subtract_1 IMPORTING i_input type i EXPORTING e_output type i.
    ENDCLASS
    CLASS zcl_class IMPLEMENTATION.
      METHOD add_1.
        e_output = i_input + 1.
      ENDMETHOD.
      METHOD subtract_1.
        e_output = i_input - 1.
      ENDMETHOD.
    ENDCLASS
    CREATE OBJECT lo_object.
    lo_object->add_1(
      exporting i_input = 1
      importing e_output = lv_output ).
    lo_object->subtract_1(
      exporting i_input = 2
      importing e_output = lv_output2 ).
    <h4>Static option</h4>
    CLASS zcl_class DEFINITION.
      CLASS-METHODS add_1 IMPORTING i_input type i EXPORTING e_output type i.
      CLASS-METHODS subtract_1 IMPORTING i_input type i EXPORTING e_output type i.
    ENDCLASS
    CLASS zcl_class IMPLEMENTATION.
      METHOD add_1.
        e_output = i_input + 1.
      ENDMETHOD.
      METHOD subtract_1.
        e_output = i_input - 1.
      ENDMETHOD.
    ENDCLASS
    CREATE OBJECT lo_object.
    lo_object->add_1(
    zcl_class=>add_1(
      exporting i_input = 1
      importing e_output = lv_output ).
    lo_object->subtract_1(
    zcl_class=>subtract_1(
      exporting i_input = 2
      importing e_output = lv_output2 ).
    So which option is best? Pros and Cons?

  • Declaration of Rabge table Paramater in Global class method

    Hi Friends,
    I have created a Global class with a method GET_DATA.
    In that method,i have written the like  :
    select * from kna1 into table it_kna1where kunnr in S_kunnr.
    But, I am getting the error with Range table S_KUNNR.
    Kindly, Let me know how I should Declare S_KUNNR in parameter list of GET_DATA,  what should be its associated data type?
    Regards,
    Xavier.p
    Edited by: Xavier on Jul 16, 2009 3:50 PM

    1) Create a Public Type for ranges. You can do it in SE11 or in SE24. I generally prefer doing it in SE24.
    Go to Types Tab
    Declare your range type
    TYPES: ty_r_kunnr type range of kna1-kunnr.
    2) Use this type to declare your method's parameters:
    IR_KUNNR TYPE TY_R_KUNNR
    3) When calling the method you can do like:
    CALL METHOD O_REF->GET_dATA
      EXPORTING
        IR_KUNNR = S_KUNNR[].
    Regards,
    Naimesh Patel

  • Object is not an instance of declaring class

    Hi All,
    I am having an issue with reflection invoking a method. I have looked up the error I am getting but cannot see why my code is throwing it. As I understand it, the error thinks I am invoking a method on the wrong instance of an expected object, but clearly my code shows I am passing the same class.
    The call to field.getName() will return capitalised variables Id and Description, so that when "get" is prepended, getId and getDescription are formed. Neither method takes arguments.
    I have placed a log statement gm= to find out whether the Method object has been captured, and it has. I get getId logged to the console. All fine so far until a call is made to invoke. Clearly my passed lineItemClass is causing a problem but I am not sure why, this class afterall does have getId. Have also tried changing the lineItemClass param to lineItem which is an actual instance found earlier in my code but this throws ClassCastException, even though that too has getId.
    Your help appreciated!
    try {
    Object[] args = {};
    Class[] paramTypes = {};
    Class lineItemClass = lineItem.getClass();
    Method getMethod = lineItemClass.
    getDeclaredMethod("get" + field.getName(), paramTypes);                    
    System.out.println("gm=" + getMethod.getName());
    Object value = getMethod.invoke(lineItemClass, args);
    } catch (Exception e) {
    System.out.println("error on getFieldValue " + field.getName() + " " + e.getMessage());
    }

    You cannot overload a method with a different return type only, in this case invoke can only return an Object.
    What reflection does for you is ensure that if the actual method invoked returns a primitive, that the equivalent Number type or Boolean is returned.
    Number is the superclass of all primitive wrappers except Boolean, which is the wrapper for the boolean primitive type.
    What reflection also does for you is ensure that although parameter values must be objects that the correct type is used in a method invocation so a method that expects an int will be invoked with a parameter of type Integer, Method.invoke ensures that the Integer value is converted to an int before the method actually is called.

  • The 'this' object in class methods

    The book I'm reading says that the 'this' object needs to be initialized in every class method. Does it have to be explicitly initialized or can it be implicit? and if it can be implicit, how would you do that?(code wise)

    Actually, I think it is correct to say that 'this' needs to be initialized. In a constructor, you cannot make a reference to the 'this' reference until the super constructor gets called. If you do not explicitly call the super constructor, then a call to the no argument super constructor gets inserted. If there isn't a no argument super constructor, then you must either make a call to one of the super constructors that is defined, or make a call to another constructor in that class. Until after that point, the 'this' reference is not valid.

  • Validating a method object whether it is a bean class method

    I have a class that is loaded dynamically using URLClassLoader. It is required to validate whether it is a valid bean class' method. i.e. if it is set method, it should start with <set>xxx and if it is get method, it should be like <get>xxx or <is>xxx. I dont want to make it with if conditions and I believe there should be a way to validate if that class satisfies java bean naming specification ( for class/method). Any help is much appreciated.

    kajbj  wrote:
    How would you be able to verify that? Beans can have other methods as well. Well.. in my case, I want to ensure that that does not contain "other methods" and only getters/setters. It should be just a bean and nothing more. There could be cases when a setter method is written like "setTablename" ( note: camel case missing).
    I prefer to use this one.
    public class Bean {
        String tableName;
        public String getTableName() {
            return tableName;
        public void setTableName(String tableName) {
            this.tableName = tableName;
    try {
         BeanInfo info = Introspector.getBeanInfo( Bean.class );
         PropertyDescriptor[] pd  = info.getPropertyDescriptors();
         for (int i=0;i<pd.length;i++) {
              System.out.println( pd.getName() +","+pd[i].getReadMethod());
    if(pd[i].getReadMethod()==null) {
    throw new Exception("Not a bean");
    } catch (Exception e) {
    e.printStackTrace();
    }This code works well, when 1. members not in camel case,
    2. methods not in camel case. But when it comes to method , it throws exception for public String getTablename() {
    return tableName;
    }But it doesnt throw exception for public String gettableName() {
    return tableName;
    } I predicted exception here. Correct me If I am wrong.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Code to call friends class method

    Hello,
    Please can someone help me with friends class method call. in global classes
    Thanks
    Megh
    Moderator message: please search for available information/documentation before asking.
    Edited by: Thomas Zloch on Nov 2, 2010 5:29 PM

    What is your exact problem?
    The class whose private and protected section you want to use, needs declaration of its friends. You do it in Friends tabstrip. All these classes are allowed then to access these "hiden" sections from outside of the class. Below example how it works with local classes. For global ones the principle stays the same
    CLASS lcl_main DEFINITION DEFERRED.
    CLASS lcl_other DEFINITION FRIENDS lcl_main. "only LCL_MAIN can use may hiden sections
      PROTECTED SECTION.
        METHODS prot_meth.
      PRIVATE SECTION.
        METHODS priv_meth.
    ENDCLASS.                  
    CLASS lcl_other IMPLEMENTATION.
      METHOD prot_meth.
        WRITE / 'This is protected method of class lcl_other'.
      ENDMETHOD.                    "prot_meth
      METHOD priv_meth.
        WRITE / 'This is private method of class lcl_other'.
      ENDMETHOD.                    "priv_meth
    ENDCLASS.                   
    CLASS lcl_main DEFINITION.
      PUBLIC SECTION.
        METHODS call_friends_methods.
      PRIVATE SECTION.
        DATA mr_my_friend TYPE REF TO lcl_other.
    ENDCLASS.                  
    CLASS lcl_main IMPLEMENTATION.
      METHOD call_friends_methods.
        CREATE OBJECT mr_my_friend.
        mr_my_friend->prot_meth( ).
        mr_my_friend->priv_meth( ).
      ENDMETHOD.                   
    ENDCLASS.           
    START-OF-SELECTION.
      DATA gr_main TYPE REF TO lcl_main.
      CREATE OBJECT gr_main.
      gr_main->call_friends_methods( ).
    Regards
    Marcin

  • Passing vector into class/methods

    I am new to Vectors check this simple code out. I am trying to pass a vector onto another class then add an integer element to it. I see that its looking for an identifier but i dont unerstand how the code is for an identifier for a vector.
    ERRORS: .\Remove.java:4: <identifier> expected
         public static void AddIntegers(varray);
    ^
    .\Remove.java:4: ')' expected
         public static void AddIntegers(varray);
    ^
    .\Remove.java:4: cannot resolve symbol
    symbol : class varray
    location: class Remove
         public static void AddIntegers(varray);
    ^
    C:\Computer Work\Lab4\RemoveTest.java:11: cannot resolve symbol
    symbol : method varray ()
    location: class RemoveTest
              rm.AddIntegers(varray());
    ^
    .\Remove.java:4: missing method body, or declare abstract
         public static void AddIntegers(varray);
    ^
    .\Remove.java:6: cannot resolve symbol
    symbol : variable varray
    location: class Remove
              varray.AddElement(new Integer(13));
    ^
    6 errors
    Tool completed with exit code 1
    import java.io.*;
    import java.util.*;
    public class RemoveTest
         public static void main(String[] args)
              Vector varray = new Vector();
              Remove rm = new Remove();
              rm.AddIntegers(varray);
              System.out.println(varray);
    public class Remove
         public static void AddIntegers(varray);
              varray.AddElement(new Integer(13));

    I think the question whether you should use Vector over arrays, but rather should you use Lists over arrays. Vectors are kind of deprecated. You should be using the Collections Framework as a whole, and that means that ordered items are in java.uti.Lists, where are a kind of java.util.Collection, and a Vector is just a particular kind of List, and not necessarily even the best kind -- an ArrayList or LinkedList is often better.
    The advantage of arrays over Lists is that they can hold primitive types trivially. You can only hold objects in Lists, so you can put primitive class wrapper objects in Lists, but that has its disadvantages. Apparently in JDK 1.5 there's some syntactic sugar to make this easier, but there are still other disadvantages.
    The advantages of Lists over arrays are like what you mentioned -- things like resizings are automatic, there are lots of convenience methods, etc. The Collections Framework provides an abstraction of, well, collections, which is a good thing over futzing with details like with arrays, frequently.

  • Type for SENDER parameter in Class Method

    Hi all,
    I have an import parameter declared in a Class method .
    in SE38 program i want to retrieve through export parameter .
    But i am not able to figure how to defind the type of SENDER parameter . Please suggest if my perception is wrong or the point that i am missing here .
    Regards,
    Ry.

    Hi Vijay,
    Thank you for your reply . the problem i am having is the functionlaity of this report is it displays three grids and when ever i double click on a grid it should identify the particluar grid . i have highlighted in bold where i am encountering the problem. i am enclosing the class details and the report source code. Please suggest after going through it . thanks in advance.
    Class details that i have created :
    the class has a method handle_double_event with event handler double_click of CL_GUI_ALV_GRID . i have defined this in the method section.
    in public section section :
    public section.
      types GO_GRID1 type ref to CL_GUI_ALV_GRID .
      class-methods HANDLE_DOUBLE_CLICK
        for event DOUBLE_CLICK of CL_GUI_ALV_GRID
        importing
          ES_ROW_NO
          E_COLUMN
          E_ROW
          SENDER .
    in handle_double_event code :
    DATA:
      go_grid1         TYPE REF TO cl_gui_alv_grid,
      go_grid2         TYPE REF TO cl_gui_alv_grid,
      go_grid3         TYPE REF TO cl_gui_alv_grid.
    DATA:
      gt_knb1          TYPE STANDARD TABLE OF knb1,
      gt_vbak          TYPE STANDARD TABLE OF vbak,
      gt_vbap          TYPE STANDARD TABLE OF vbap.
      define local data
        DATA:
          ls_knb1      TYPE knb1,
          ls_vbak      TYPE vbak,
          ls_vbap      TYPE vbap.
       DATA: es_row_no type lvc_s_roid,
             e_column  type lvc_s_col,
             e_row     type lvc_s_row.
        *CASE sender. - here when i double click on the first grid go_grid1 it should go inside the go_grid1 . but it is not entering .*
          WHEN go_grid1.
            READ TABLE gt_knb1 INTO ls_knb1 INDEX e_row-index.
            CHECK ( ls_knb1-kunnr IS NOT INITIAL ).
            CALL METHOD go_grid1->set_current_cell_via_id
              EXPORTING
                 IS_ROW_ID    =
                 IS_COLUMN_ID =
                is_row_no    = es_row_no.
            Triggers PAI of the dynpro with the specified ok-code
            CALL METHOD cl_gui_cfw=>set_new_ok_code( 'ORDERS' ).
          WHEN go_grid2.
            READ TABLE gt_vbak INTO ls_vbak INDEX e_row-index.
            CHECK ( ls_vbak-vbeln IS NOT INITIAL ).
            CALL METHOD go_grid1->set_current_cell_via_id
              EXPORTING
                 IS_ROW_ID    =
                 IS_COLUMN_ID =
                is_row_no    = es_row_no.
            Triggers PAI of the dynpro with the specified ok-code
            CALL METHOD cl_gui_cfw=>set_new_ok_code( 'ORDER_DET' ).
          WHEN go_grid3.
            READ TABLE gt_vbap INTO ls_vbap INDEX e_row-index.
            CHECK ( ls_vbap-matnr IS NOT INITIAL ).
            SET PARAMETER ID 'MAT' FIELD ls_vbap-matnr.
            CALL TRANSACTION 'MM02' AND SKIP FIRST SCREEN.
          WHEN OTHERS.
            RETURN.
        ENDCASE.
    endmethod.
    Code for the Report that is accessing the class.
    DATA:
      gd_okcode        TYPE ui_func,
      go_docking       TYPE REF TO cl_gui_docking_container,
      go_splitter      TYPE REF TO cl_gui_splitter_container,
      go_splitter_2    TYPE REF TO cl_gui_splitter_container,
      go_cell_top      TYPE REF TO cl_gui_container,
      go_cell_bottom   TYPE REF TO cl_gui_container,
      go_cell_left     TYPE REF TO cl_gui_container,
      go_cell_right    TYPE REF TO cl_gui_container,
      go_grid1         TYPE REF TO cl_gui_alv_grid,
      go_grid2         TYPE REF TO cl_gui_alv_grid,
      go_grid3         TYPE REF TO cl_gui_alv_grid,
      list             type ref to zcl_eventhandler,
      es_row_no        type lvc_s_roid,
      e_column         type lvc_s_col,
      e_row            type lvc_s_row,
      sender(8)        type c.
    DATA:
      gt_knb1          TYPE STANDARD TABLE OF knb1,
      gt_vbak          TYPE STANDARD TABLE OF vbak,
      gt_vbap          TYPE STANDARD TABLE OF vbap.
    PARAMETERS  :  p_bukrs TYPE ekko-bukrs default '1000'.
    START-OF-SELECTION.
      create object list.
      SELECT        * FROM  knb1 INTO TABLE gt_knb1
             WHERE  bukrs  = p_bukrs.
    Create docking container
      CREATE OBJECT go_docking
        EXPORTING
          parent                      = cl_gui_container=>screen0
          ratio                       = 50
        EXCEPTIONS
          OTHERS                      = 6.
      IF sy-subrc <> 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    Create splitter container
      CREATE OBJECT go_splitter
        EXPORTING
          parent            = go_docking
          rows              = 1
          columns           = 1
         NO_AUTODEF_PROGID_DYNNR =
         NAME              =
        EXCEPTIONS
          cntl_error        = 1
          cntl_system_error = 2
          OTHERS            = 3.
      IF sy-subrc <> 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    Get cell container
      CALL METHOD go_splitter->get_container
        EXPORTING
          row       = 1
          column    = 1
        RECEIVING
         container = go_cell_left.
          container = go_cell_top.
      CALL METHOD go_splitter->get_container
        EXPORTING
          row       = 1
          column    = 2
        RECEIVING
          container = go_cell_right.
    Create 2nd splitter container
      CREATE OBJECT go_splitter_2
        EXPORTING
         parent            = go_cell_left
          parent            = go_cell_top
          rows              = 2
          columns           = 1
         NO_AUTODEF_PROGID_DYNNR =
         NAME              =
        EXCEPTIONS
          cntl_error        = 1
          cntl_system_error = 2
          OTHERS            = 3.
      IF sy-subrc <> 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    Get cell container
      CALL METHOD go_splitter_2->get_container
        EXPORTING
          row       = 1
          column    = 1
        RECEIVING
          container = go_cell_top.
      CALL METHOD go_splitter_2->get_container
        EXPORTING
          row       = 2
          column    = 1
        RECEIVING
          container = go_cell_bottom.
    Create ALV grids
      CREATE OBJECT go_grid1
        EXPORTING
          i_parent          = go_cell_top
        EXCEPTIONS
          OTHERS            = 5.
      IF sy-subrc <> 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      CREATE OBJECT go_grid2
        EXPORTING
          i_parent          = go_cell_bottom
        EXCEPTIONS
          OTHERS            = 5.
      IF sy-subrc <> 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      CREATE OBJECT go_grid3
        EXPORTING
          i_parent          = go_cell_right
        EXCEPTIONS
          OTHERS            = 5.
      IF sy-subrc <> 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
          CALL METHOD ZCL_EVENTHANDLER=>HANDLE_DOUBLE_CLICK
            EXPORTING
              ES_ROW_NO = ES_ROW_NO
              E_COLUMN  = E_COLUMN
              E_ROW     = E_ROW
              SENDER.
    Set event handler
      SET HANDLER: list->handle_double_click FOR go_grid1.
      SET HANDLER: list->handle_double_click FOR go_grid2.
      SET HANDLER: list->handle_double_click FOR go_grid3.
    Display data
      CALL METHOD go_grid1->set_table_for_first_display
        EXPORTING
          i_structure_name = 'KNB1'
        CHANGING
          it_outtab        = gt_knb1
        EXCEPTIONS
          OTHERS           = 4.
      IF sy-subrc <> 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      REFRESH: gt_vbak.
      CALL METHOD go_grid2->set_table_for_first_display
        EXPORTING
          i_structure_name = 'VBAK'
        CHANGING
          it_outtab        = gt_vbak
        EXCEPTIONS
          OTHERS           = 4.
      IF sy-subrc <> 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      REFRESH: gt_vbap.
      CALL METHOD go_grid3->set_table_for_first_display
        EXPORTING
          i_structure_name = 'VBAP'
        CHANGING
          it_outtab        = gt_vbap
        EXCEPTIONS
          OTHERS           = 4.
      IF sy-subrc <> 0.
       MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                  WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    Link the docking container to the target dynpro
      CALL METHOD go_docking->link
        EXPORTING
          repid                       = syst-repid
          dynnr                       = '0100'
         CONTAINER                   =
        EXCEPTIONS
          OTHERS                      = 4.
      IF sy-subrc <> 0.
       MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                  WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    NOTE: dynpro does not contain any elements
      CALL SCREEN '0100'.
    Flow logic of dynpro:
    *PROCESS BEFORE OUTPUT.
    MODULE STATUS_0100.
    *PROCESS AFTER INPUT.
    MODULE USER_COMMAND_0100.
    END-OF-SELECTION.
    *&      Form  CUSTOMER_SHOW_ORDERS
          text
    -->  p1        text
    <--  p2        text
    FORM customer_show_orders .
    define local data
      DATA:
        ld_row      TYPE i,
        ls_knb1     TYPE knb1.
      CALL METHOD go_grid1->get_current_cell
        IMPORTING
          e_row = ld_row.
      READ TABLE gt_knb1 INTO ls_knb1 INDEX ld_row.
      CHECK ( syst-subrc = 0 ).
      SELECT        * FROM  vbak INTO TABLE gt_vbak
             WHERE  kunnr  = ls_knb1-kunnr.
      REFRESH: gt_vbap.
    ENDFORM.                    " CUSTOMER_SHOW_ORDERS
    *&      Form  ORDER_SHOW_DETAILS
          text
    -->  p1        text
    <--  p2        text
    FORM order_show_details .
    define local data
      DATA:
        ld_row      TYPE i,
        ls_vbak     TYPE vbak.
      CALL METHOD go_grid1->get_current_cell
        IMPORTING
          e_row = ld_row.
      READ TABLE gt_vbak INTO ls_vbak INDEX ld_row.
      CHECK ( syst-subrc = 0 ).
      SELECT        * FROM  vbap INTO TABLE gt_vbap
             WHERE  vbeln  = ls_vbak-vbeln.
    ENDFORM.                    " ORDER_SHOW_DETAILS
    *&      Module  STATUS_0100  OUTPUT
          text
    MODULE STATUS_0100 OUTPUT.
    SET PF-STATUS 'STATUS_0100'.  " contains push button "ORDERS"
    SET TITLEBAR 'xxx'.
    Refresh display of detail ALV list
      CALL METHOD go_grid2->refresh_table_display
       EXPORTING
         IS_STABLE      =
         I_SOFT_REFRESH =
        EXCEPTIONS
          OTHERS         = 2.
      IF sy-subrc <> 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    Refresh display of detail ALV list
      CALL METHOD go_grid3->refresh_table_display
       EXPORTING
         IS_STABLE      =
         I_SOFT_REFRESH =
        EXCEPTIONS
          OTHERS         = 2.
      IF sy-subrc <> 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
          text
    MODULE USER_COMMAND_0100 INPUT.
    move sy-ucomm to gd_okcode.
    CASE gd_okcode.
        WHEN 'BACK' OR
             'END'  OR
             'CANC'.
          SET SCREEN 0. LEAVE SCREEN.
      User has pushed button "Display Orders"
        WHEN 'ORDERS'.
          PERFORM customer_show_orders.
        WHEN 'ORDERS_DET'.
          PERFORM order_show_details.
        WHEN OTHERS.
      ENDCASE.
      CLEAR: gd_okcode.
    endmodule.
    Regards,
    Ry

  • How to declare class for library like function

    Hey guys I want to declare class Math and define method subtrction so that i can use it in other class like
    package p1
    public class Math
    Math( ){}
    int Subtration ( int a, int b)
    return (a-b)
    package p2
    import p1.*;
    Public Class Test
    Test()
    int somenumber=Math.Subtration(3,4);
    For some reason I cannot see any methods inside Math class. when i type
    somenumber = Math. it show me only one option and that is 'class' instead of mathods inside Math. any thoughts?
    thx

    Yes I am aware of Math class in java. The question is
    how do i declare a class and call it's method in some
    other class with out declaring an object of that
    class.
    Like I can just call Math.sqrt(4) with out
    specifically declaring Math as an object. I want to
    declare my own class which has some methods I wish to
    call in some other class.MyClass.someMethod(). Just make sure that the methos is actually declared static. I suggest looking up the static keyword to find out what it means.

Maybe you are looking for