Reference Objects and Pooling

I am trying to create a Pool class that does not require the caller to explictly return the objects. I thought I might be able to use Phantomreference or WeakReference to detect when the user no longer had reference to the object and thus reclaim it and put it back in the pool. The issues with these are this:
1) WeakReference is cleared (clear()) before it is added to the ReferenceQueue not to mention the object is finalised before as well.
2) PhantomReference is not cleared but it is finalized. Not that it matters because you can never access the referant.
So what I did is subclass PhantomReference and created an Interface called Proxy. The subclass would take a proxy referant containing the actual reclaimable object and it would store the relaimable object as a hard referant and the proxy to that as the Phantom referant. Thus when the client was no longer using the proxy the erference would be added to the reference queue and I could get the actual reclaimable object as opposed to the proxy via a call to get().
The problem with this approach has been that not all classes lend well to being proxied. The idea situation would be that the Proxy would extend the actual class thus CASTING would work as normal.
public StringBufferProxy extends StringBuffer implements Proxy {
private StringBuffer proxy;
public StringBufferProxy(StringBuffer proxy)
this.proxy = proxy;
public Object getProxied()
return proxy;
public void anyMethod()
proxy.anyMethod();
The obvious problem with the above is that StringBuffer is final and thus can't be extended. Similar problems with Thread as it relates to its final methods. So in the end after going around in circles for awhile I realized this concept would only really be practicle for Interface based classes.
Has anyone else worked this problem and solved it?
}

all cases the referant has allready been finalized. In...
So what I tried to do was create a proxy class that
wraps the actual pooled item....
This has numerous problems.You may like my method. Someone needs to tell me if this is a ``bad thing'' but I've used it quite successfully. I wrote a cache class a little while ago (very similar to your Pool needs). It's a cloning cache. Let me simplify a VERY complex cache:
class Clone implements Cloneable {
    private Object o;
    Clone(Object o) {
        super();
        this.o = o;
    public Object getObject() { return o; }
    public Clone getClone() throws ... {
        return (Clone)super.clone();
} // CloneThis sets up the clone, now:
class CloneReference extends WeakReference implements Comparable { // or extend any Reference that makes sense to you
    private Clone clone = null;
    CloneReference(Clone referent, ReferenceQueue q) throws ... {
        super(referent,q);
        try {  // don't really have to try, but...
            clone = (Clone)referent.getClone();
        } catch(Exception dowhatever) { ... }
    public Object getObject() {
        Object ret = null;
        if(clone!=null) ret = clone.getObject();
        return ret;
    // now implement Comparable
} // CloneReferenceNow in your Pool maintain your ReferenceQueue, when you add a new Object into it, purgue this queue. In my cache I have a CacheEvent/CacheListener that is event fired during the purging of this queue. More later. When adding a new object into your Pool, add a reference to a new CloneReference object:
private ReferenceQueue q;  // init elsewhere
public void add(Object o) throws ... {
    CloneReference cr = new CloneReference(
          new Clone(obj)
        , q
    // now add this cr, not the o
}When purging the queue, poll() your ReferenceQueue and then obtain the CloneReference. Get your object back out (this will not be null or yet finalized) using CloneReference.getObject(), then fire off your interpretation of my CacheEvent to your version of my CacheListener.
Note that the ReferenceQueue maintains a reference to the original Clone, but the Reference itself has a clone of that Clone which we will NOT be GCd or nullified still maintaining a reference to the original object.
If you need further help I can probably provide a truncated source of a simple Cache.

Similar Messages

  • Reference Object and New Key Word

    Hi,
    I am having a Class call ThreadHandler which implements Runnable()
    I loop through 10 times like below
    for (int i = 0; i < 10; i++) {
    ThreadHandler oTHandler = new ThreadHandler();
    Thread oTh = new Thread(oTHandler);
    oTh.start();
    Question:
    1. Will this create unnecessary referencing to ThreadHandler?
    2. Can I just instantiate ThreadHandler at the attribute declaration and just use new key word every time in the loop
    E.g :
    ThreadHandler oTHandler
    Thread oTh
    for (int i = 0; i < 10; i++) {
    oTHandler = new ThreadHandler();
    oTh = new Thread(oTHandler);
    oTh.start();
    }

    Suppose we say:
    for(ndx = 0; ndx < 1000; ndx++) {
        Type foo = new Type("etc");
    // <-- foo is no longer in scopeI'm not 100% sure what you mean "unnecessary referencing of..." but if you declare inside the for loop then there will be nothing referenced by foo after the loop. So, if anything there is less referencing going on.
    It is considered good practice to declare things close to where you use them. Because your intent is clearer that way.

  • The truth about objects, references, instances and cloning (Trees and Lists

    Hello
    As a few of you may have know from my postings over the past few weeks, ive been building my first real java ap and trying to learn along the way, hitting a few snags here and there.
    One main snag i seem to have been hitting a fair bit is objects and instances, im kinda learning on how they work and what they mean but as a php programmer it seems to be very different.
    as pointed out to me if you have objectA=objectB then in php you have two objects that share the same value but in java you have still one object value and one object pointing to the value.
    sooo my first question is
    if i have this
    Object objA=new Object()
    Object objB=objA()then object A creates a new memory allocation for the object data right? and object B is simply a reference to the object A memory allocation right?
    so therefore there is no instance of objectB? or is there an instance of object B but it just takes up the same memory allocation as object A?
    anyway, what is the point of being able to say objB=objA what can that be used for if not for making a copy of an object (i understand now that it doesnt copy an object)
    My second question (which i think i actually understand now, but im posting it to see if the answers may help others)
    If i have a List structure (e.g. arraylist) then when i add a datatype such as a treemap does it not add the changed treemap, ill try and explain with code
    ArrayList mylist=new ArrayList()
    Treemap myTree=new Treemap()
    myTree.put("hello","howdy");
    myTree.put("bye","cya");
    mylist.put(myTree);
    System.out.println(mylist.toString());
    myTree.put("another","one");
    mylist.put(myTree);
    System.out.println(mylist.toString());now to be honest ive not actually tried that code and it may actually procude the right results, but from my experience so far that similar sort of thing hasnt been working (by the way i know the above code wont compile as is :p)
    anyway what i assume is that will output this
    [Hello,howdy,bye,cya] <<this is the first system out
    [Hello,howdy,bye,cya,another,one  <<this is the second system out
    Hello,howdy,bye,cya,another,one] <<this is the second system out
    where it should produce this
    [Hello,howdy,bye,cya,
    Hello,howdy,bye,cya,another,one]
    Why when I update the treemap does the arraylist change, is this because the thing that is being put in the array list is infact not an object but simply a reference to an object?
    thanks for everyones help so far :)

    as pointed out to me if you have objectA=objectB then
    in php you have two objects that share the same value
    but in java you have still one object value and one
    object pointing to the value.Some years ago, I built a small website managing data saved in an XML file using PHP. Being used to Java, I used an OO approach and created classes managing data structures and having setter/getter methods. The fact that PHP did actually create a copy of any object being passed as and argument made me crazy. This way, I wasn't able to reach the same instances from several different places in my code. Instead, I had to put a certain operator ("&" I think) before any reference to force PHP not to make a copy but pass the reference. I also found a note on the PHP site saying that copying was faster than passing the reference, which I actually couldn't believe. If I'm not wrong, they changed the default behaviour in PHP5.
    if i have this
    Object objA=new Object()
    Object objB=objA()then object A creates a new memory allocation for the
    object data right? and object B is simply a reference
    to the object A memory allocation right?The statement "new <Class>" allocates memory. The reference itself just takes up a few bytes in order to maintain some administrative data (such as the memory address). References are basically like pointers in C, though there's no pointer arithmetics and they can't point to any arbitrary place in memory (only a legal instance or null).
    so therefore there is no instance of objectB? or is
    there an instance of object B but it just takes up
    the same memory allocation as object A?There is an instance of objectB, but it's just the same instance that objectA is pointing at. Both references objectA and objectB contain the same memory address. That's why they'd produce a result of "true" if compared using the "==" operator.
    anyway, what is the point of being able to say
    objB=objA what can that be used for if not for making
    a copy of an object (i understand now that it doesnt
    copy an object)Sometimes you don't want to make a copy, as 1) it consumes more memory and 2) you'd lose the reference to it (making it more difficult to tell what instance is actually accessed). If there was no way to pass a reference to an object into a method, methods wouldn't be able to affect the original instance.
    Why when I update the treemap does the arraylist
    change, is this because the thing that is being put
    in the array list is infact not an object but simply
    a reference to an object?The ArrayList doesn't change at all. It's the instance that's being changed, and the ArrayList has a reference to it.

  • Quality notification - more reference objects

    Hello,
    business need is to have quality notification with possibility to refer either production order or purchase order under one notification type.
    By standard this seems not possible as:
    Complaint Against Vendor references to Purchase order
    Internal Problem Report references to Production order.
    But in section "User-specific notification" is mentioned
    A user-specific notification type has the same basic structure as the standard, predefined notification types. The screen layouts, reference objects, and tab indexes, however, may differ from those in the predefined notification types, depending on how you customize the user-specific notification type.
    But I have not found a way in customizing to enable this.
    Advice appreciated.
    Br, Jan

    Thanks for the asnwer, but I think this does not solve my problem.
    In the configuaration for "Notification Header and Screen Areas" I do have
    - notification header screen H500
    - customized screen O550 (BADI)
    and both are needed.
    The BADI is used to customize refernce object screen, not reference documents screen. But my idea was to change reference document screen area in a way, that both purhcasing and production reference documents are visible in there.
    I only managed to get the vendor screen by adding screen area 037 to "Extended View: Tabstrips and Screen Areas" But adding purhcase document as reference to Reference documents remains my problem.
    I am kind of able to make the vendor screen visible by e.g. adding screen area 037 Partner overview screen (table control).But creating a new pop-up window for notification reference, where both options (pur ord, prod ord) would be available with copying functionality - in my opinion this requiers completely custom coding.

  • Alignment tool - how to set reference object?

    I am new to Flash but have used Illustrator and InDesign for years. I am wondering if someone can explain how to set the reference object by which all other objects are aligned; e.g. Illustrator ->select all objects then a second click on the reference object and all other objects take their cue.
    InDesign you lock the reference object and that determines the rest.
    In Flash it seems that either both objects move or the one that I wish to remain in position jumps rather than the other way around.
    Thanks

    I don't know if you can set a reference object in Flash.  I have always just followed the general rule of aligning into the direction where the alignment basis would not move... meaning if I am aligning to the left, then the leftmost item I would select would be the reference, and if need be I would move other objects to the right of it first.

  • Reference object in Notification

    Dear All,
    I am new person in  the SAP-PM module but I need to work on it. I have a quarry, what is reference object and reference object key in notification creation, in which table I need to see the values of the same.
    Thanks and regards,
    Krish....

    Hi
       Notification we create with reference to some object.
    whch means it is refering some functional location , equipment etc.
    So it is address some object against wihc notification is creating.
    check  table QMFE
    regards
    Krishna

  • Difference between reference variable and object ?

    I am getting confused with reference variable and object ?
    1. int a; // is a variable
    2. Car c = new Car(); // is a object of car type
    Suggest me what are the difference between the two.....

    jverd wrote:
    Shelby wrote:
    Something about an interned string literal?_
    I remember something from class about the way Java treats strings that contain the same data. yawmark
    posted a link for me that cleared up my confusion. thanks yawmark.
    >>
    Can you actually point back to the original reference?Not clear what you're asking here. Nothing points to references. References point to objects.
    Goodness, correct wording is as important as getting the syntax right, isn't it? ;-} What I was trying to ask is if it is possible to point back to the same String once you change the pointer on the variable?
    And you answered my question succintly with the rest of your post. thanks jverd
    >
    String str = "abc";
    str = null;'At this point, we've lost the reference to the original String object. However, at runtime, the VM will still be maintaining it in the constant pool. For any non-constant-pooled object, as we're writing our code, we'd have no way to refer to that object again. In this case, we are able to refer to the same object later in our code by simply using the same string literal. "abc" elsewhere in our code will cause the VM to give us a reference to that same pooled String. Same goes for Integer, etc. in the range -128..127.
    However, it's not good design to rely on this. If your design requires you to later point to "the same object" (as opposed to any object of a compatible type and holding the same contents), then you should explicitly maintain a reference to it. In the case of Strings, you really shouldn't care whether it's the same object or not. All you care about is the character sequence that defines the String's state.

  • Notification: Set priority and dates, based on the reference object

    Hello,
    I'm searching for an idea/solution, to set the priority of a notification automatically, depending on the entered reference object (F/L or equi).
    I.e. I want to classify the F/Ls and equis with a priority (e.g. via the classification, or F/L / equi master data). When the user creates a notification, and enters a F/L or equi, the priority should be selected from the object and set automatically.
    Thanks for your answers!
    Best regards
    Stephan

    Hello Pete,
    thank you for your answer. Unfortunatelly both user-exits seem not to work for my problem.
    QQMA0025: Default values when adding a notification
    Priority and dates can be modified, but in this step you don't have the functional location. I thought, I can send a popup in this user-exit, to ask for the functional location, but the functional location is deleted in a later step (before the 1st display of the notification header), i.e. the user has to enter it again.
    QQMA0018: Deadline setting based on entered priority
    Here you can only modify the dates / times, but not the priority.
    Another show stopper is, that the exits will only be processed once, i.e. in both cases, a change of the functional location doesn't adjust the dates/times.
    It seems, that exit "Before saving the notification" (as far as I remember QQMA0014) could be a solution.
    I see 2 problems ->
    1. the user enters the F/L or equi and nothing happens to the priority / dates -> sending a popup in the saving process to inform the user about the changes, could be a solution.
    2. What to do, when the user has already maintained priority and/or dates/times?
    I will have a look, if there are enhancement spots in the notification program. Perhaps this can help me (or better - my boss ).
    Best regards
    Stephan

  • How to get subject text and Reference Object both Screens at the Header lev

    Dear Experts ,
                    I am getting only Notification Header Screen ( Subject Text, Notification system and User Status) at the Header of Notification and different Tabs under that screen.
                    I want Subject Text and Reference Object screens at header Level so that any screen Tab selected at a time I can see the Subject and Reference Object of the Notification.
                    Pls tell me is there any way so I can Include 2 screens( Subject and Reference Object at the Header Level.)
    With best regards,
    Narendra

    Narendra,
    You can't in the standard system.
    Only the tabs are configurable.
    PeteA

  • Differences between object and object references

    What's the differences between object and object references? To me, it seems the same, but I am sure there are differences.
    Student s = new Student("Joe",20);
    s is an object of class Student. Can we say s is an object reference of class Student?
    Please clarify. thanks!!

    Student s = new Student("Joe",20);
    s is an object of class Student. Can we say s is an
    object reference of class Student?The thing you created via "new Student()" is an object. The variable you declared via "Student s" contains a reference to that object. People say all kinds of things but I find it clearer to differentiate between variables and the objects they refer to.

  • Object and reference accessing for primitives, objects and collections

    Hi,
    I have questions re objects, primitives and collection accessing and references
    I made a simple class
    public class SampleClass {
         private String attribute = "default";
         public SampleClass()
         public SampleClass(SampleClass psampleClass)
              this.setAttribute(psampleClass.getAttribute());
              if (this.getAttribute() == psampleClass.getAttribute())
                   System.out.println("INSIDE CONSTRUCTOR : same object");
              if (this.getAttribute().equals(psampleClass.getAttribute()))
                   System.out.println("INSIDE CONSTRUCTOR : equal values");
         public void setAttribute(String pattribute)
              this.attribute = pattribute;
              if (this.attribute == pattribute)
                   System.out.println("INSIDE SETTER : same object");
              if (this.attribute.equals(pattribute))
                   System.out.println("INSIDE SETTER : equal values");
         public String getAttribute()
              return this.attribute;
         public static void main(String[] args) {
    ...and another...
    public class SampleClassUser {
         public static void main(String[] args) {
              SampleClass sc1 = new SampleClass();
              String test = "test";
              sc1.setAttribute(new String(test));
              if (sc1.getAttribute() == test)
                   System.out.println("SampleClassUser MAIN : same object");
              if (sc1.getAttribute().equals(test))
                   System.out.println("SampleClassUser MAIN : equal values");
              SampleClass sc2 = new SampleClass(sc1);
              sc1.setAttribute("test");
              if (sc2.getAttribute() == sc1.getAttribute())
                   System.out.println("sc1 and sc2 : same object");
              if (sc2.getAttribute().equals(sc1.getAttribute()))
                   System.out.println("sc1 and sc2 : equal values");
    }the second class uses the first class. running the second class outputs the following...
    INSIDE SETTER : same object
    INSIDE SETTER : equal values
    SampleClassUser MAIN : equal values
    INSIDE SETTER : same object
    INSIDE SETTER : equal values
    INSIDE CONSTRUCTOR : same object
    INSIDE CONSTRUCTOR : equal values
    INSIDE SETTER : same object
    INSIDE SETTER : equal values
    sc1 and sc2 : equal values
    ...i'm just curios why the last 3 lines are the way they are.
    INSIDE SETTER : same object
    INSIDE SETTER : equal values
    sc1 and sc2 : equal values
    how come while inside the setter method, the objects are the same object, and after leaving the setter method are not the same objects?
    Can anyone point a good book that shows in detail how objects, primitives and collections are referenced, especially when passed to methods. Online reference is preferred since the availability of books can be a problem for me.
    Thanks very much

    You are confusing references with objects.
    This compares two object references:
    if( obj1 == obj2 ) { // ...Whereas this compares two objects:
    if( obj1.equals(obj2) ) { // ...A reference is a special value which indicates where in memory two objects happen to be. If you create two strings with the same value they won't be in the same place in memory:
    String s1 = new String("MATCHING");
    String s2 = new String("MATCHING");
    System.out.println( s1 == s2 ); // false.But they do match:
    System.out.println( s1.equals(s2) ); // trueIf you're using a primitive then you're comparing the value that you're interested in. E.g.
    int x = 42;
    int y = 42;
    System.out.println(x == y); // trueBut if you're comparing references you're usually more interested in the objects that they represent that the references themselves.
    Does that clarify matters?
    Dave.

  • Reference object in Notification and Order

    Hi ,
    I have a requirement to capture following in the reference Object for notification and  Order
    1. Functional Location
    2. Equipment
    3. Material
    4. Serial Number
    Configuration setting for overview of notification type doesn't have  the option to capture all the above fields.
    I am able to get all fields except Functional Location...
    Please guide me
    Regards
    Anil Kumar

    Anil,
    I have just been looking at this same requirement.
    Unfortunately you can only use the standard options for reference objects which does not allow for your requirement.
    There are no user-exits/BADIs either, you would need to build a new screen and screen-logic which is a system modification.
    The best I could do within the standard system is to include these fields on the Enhancement tab (user-exit IWO10018) or build a bespoke front-end via ABAP or HTML. GUIXT is another option.
    PeteA

  • Doc plz on abap object and Module pool prog

    Hi all,
    Please any send the details and use full documents on ABAP objects and Module Programming.
    Its very orgent for me
    THanks and Regards
    vamsin
    [email protected]

    Hi ALL,
    Thank you for your replies, I guess I dint convey my question properly,
    I have called a Selection-Screen in Module Pool .
    These were the steps which i followed to archive this.
    1. Created a subscreen area in your screen layout (Main Screen- Module Pool).
    2.  In the Top Include of  Module pool program declared a Selection-Screen as a subscreen.
         TOP-INCLUDE.
    SELECTION-SCREEN BEGIN OF SCREEN 400 AS SUBSCREEN.
        SELECTION-SCREEN BEGIN OF BLOCK d3 WITH FRAME TITLE text-003.
          PARAMETERS : grdate RADIOBUTTON GROUP r2  DEFAULT 'X' USER-COMMAND FR1.  " GRN date
          PARAMETERS : crdate RADIOBUTTON GROUP r2 .       " Current Date
        SELECTION-SCREEN END OF BLOCK d3.
       SELECTION-SCREEN END OF SCREEN 400.
    3.  In the PBO and PAI of the Main Screen called Subscreen.
          PBO
    CALL SUBSCREEN SUB_SCREEN_STAPLES INCLUDING 'zprogram' '0400'.
         PAI
    CALL SUBSCREEN SUB_SCREEN_STAPLES..
    I have to do certain operations when the user selects the radio button on subscreen (which is actually a Selection-Screen).
    I have tried to assign the function code  to radio button and as this screen is a Selection-Screen I cannot use PAI and PBO.
    Used the below code in TOP-INCLUDE.
    TOP-Include
    AT SELECTION-SCREEN ON RADIOBUTTON GROUP r2.
      CASE ok_rb.
        WHEN 'FR1' .
          IF crdate = 'X'.
            pdate = sy-datum.
          ELSE.
            pdate = sy-datum + 1.
          ENDIF.
      ENDCASE.
    But after executing this logic the flow is going to PAI which is validating the mandatory fields of Module-Pool Screen (which is not part of sub screen), hence not solving my purpose.
    Is there any way by which I can Only trigger the AT-Selection screen for the selection screen.
    or Any other approach which will solve my purpose.
    Thanks a lot for Suggestions and Inputs.

  • Diff b/w reference type and elementary type

    hi all
    can any one what is the diff b/w reference type and elementary type in data element ....
    thanks
    lokesh

    The data type attributes of a data element can be defined by:
    Specifying a domain whose attributes are copied by the data element.
    Specifying a build-in type where the data type, number of places, and possibly decimal places can be directly specified.
    Specifying a reference type, i.e. reference to a class, an interface, a type defined in the Dictionary, a built-in type, or a generic reference to ANY or DATA.
    In the maintenance screen you can set the option you require by setting the appropriate flag (domain, built-in type, reference type) and filling in the corresponding input fields.
    A reference type is a reference to another type. There are the following kinds of reference types:
    Reference to a class or an interface
    Reference to a type defined in the Dictionary
    Generic reference to ANY, OBJECT, or DATA
    Reference to a built-in Dictionary type with specification of the length and possibly also the decimal places
    You can use a reference type to define the data type properties for a data element, or for typing the component of a structure or the line type of a table type.
    In the field Referenced type, enter the name of a class, an interface, the generic references DATA, OBJECT, ANY, or the name of a type defined in the Dictionary. If the reference type is to be a predefined Dictionary type, choose the reference to the predefined type. Enter the number of characters and, if required, the number of decimal places.
    where as
    The data class describes the data format at the user interface.
    If a table field or structure field or a data element is used in an ABAP program, the data class is converted to a format used by the ABAP processor. When a table is created in the database, the data class of a table field is converted to a corresponding data format of the database system used.
    You can find a detailed description of the data classes allowed in the ABAP Dictionary in Overview of the Data Classes.

  • Difference between abap object and function

    hi all,
    i read the book on abap object of the difference between abap object and classical abap.
    i know that there is only 1 instance of a specific function group but somehow i still not so clear why subsequent vehicle cannot use the same function. i also can use the do and loop to call the function? if cannot then why?
    hope can get the advice.
    thanks
    using function *********
    function-pool vehicle.
    data speed type i value 0.
    function accelerate.
    speed = speed + 1.
    endfunction.
    function show_speed.
    write speed.
    endfunction.
    report xx.
    start-of-selection.
    *vehicle 1
    call function 'accelerate'.
    call function 'accelerate'.
    call function 'show_speed'.
    *vehicle 2
    *vehicle 3
    *****abap object*******
    report xx.
    data: ov type ref to vehicle,
             ov_tab type table of ref to vehicle.
    start-of-selection.
    do 5 times.
    create object ov.
    append ov to ov_tab.
    enddo.
    loop at ov_tab into ov.
    do sy-tabix times.
    call method ov->accelerate.
    enddo.
    call method ov->show_speed.
    endloop.

    Hi
    Now try this:
    REPORT ZTEST_VEHICLEOO .
    PARAMETERS: P_CAR   TYPE I,
                P_READ  TYPE I.
    *       CLASS vehicle DEFINITION
    CLASS VEHICLE DEFINITION.
      PUBLIC SECTION.
        CLASS-DATA: MAX_SPEED   TYPE I,
                    MAX_VEHICLE TYPE I,
                    NR_VEHICLES TYPE I.
        CLASS-METHODS CLASS_CONSTRUCTOR.
        METHODS CONSTRUCTOR.
        METHODS ACCELERATE.
        METHODS SHOW_SPEED.
        METHODS GET_SPEED EXPORTING E_SPEED TYPE I.
      PRIVATE SECTION.
        DATA: SPEED      TYPE I,
              NR_VEHICLE TYPE I..
    ENDCLASS.
    *       CLASS vehicle IMPLEMENTATION
    CLASS VEHICLE IMPLEMENTATION.
      METHOD CLASS_CONSTRUCTOR.
        NR_VEHICLES = 0.
      ENDMETHOD.
      METHOD CONSTRUCTOR.
        NR_VEHICLES = NR_VEHICLES + 1.
        NR_VEHICLE  = NR_VEHICLES.
      ENDMETHOD.
      METHOD ACCELERATE.
        SPEED = SPEED + 1.
        IF MAX_SPEED < SPEED.
          MAX_SPEED   = SPEED.
          MAX_VEHICLE = NR_VEHICLE.
        ENDIF.
      ENDMETHOD.
      METHOD SHOW_SPEED.
        WRITE: / 'Speed of vehicle nr.', NR_VEHICLE, ':', SPEED.
      ENDMETHOD.
      METHOD GET_SPEED.
        E_SPEED = SPEED.
      ENDMETHOD.
    ENDCLASS.
    DATA: OV     TYPE REF TO VEHICLE,
          OV_TAB TYPE TABLE OF REF TO VEHICLE.
    DATA: V_TIMES TYPE I,
          FL_ACTION.
    DATA: V_SPEED TYPE I.
    START-OF-SELECTION.
      DO P_CAR TIMES.
        CREATE OBJECT OV.
        APPEND OV TO OV_TAB.
      ENDDO.
      LOOP AT OV_TAB INTO OV.
        IF FL_ACTION = SPACE.
          FL_ACTION = 'X'.
          V_TIMES = SY-TABIX * 2.
        ELSE.
          FL_ACTION = SPACE.
          V_TIMES = SY-TABIX - 2.
        ENDIF.
        DO V_TIMES TIMES.
          CALL METHOD OV->ACCELERATE.
        ENDDO.
        CALL METHOD OV->SHOW_SPEED.
      ENDLOOP.
      SKIP.
      WRITE: / 'Higher speed', VEHICLE=>MAX_SPEED, 'for vehicle nr.',
                VEHICLE=>MAX_VEHICLE.
      SKIP.
      READ TABLE OV_TAB INTO OV INDEX P_READ.
      IF SY-SUBRC <> 0.
        WRITE: 'No vehicle', P_READ.
      ELSE.
        CALL METHOD OV->GET_SPEED IMPORTING E_SPEED = V_SPEED.
        WRITE: 'Speed of vehicle', P_READ, V_SPEED.
      ENDIF.
    Try to repeat this using a function group and I think you'll undestand because it'll be very hard to do it.
    By only one function group how can u read the data of a certain vehicle?
    Yes you can create in the function group an internal table where u store the data of every car: in this way u use the internal table like it was an instance, but you should consider here the example is very simple. Here we have only the speed as characteristic, but really we can have many complex characteristics.
    Max

Maybe you are looking for