Wide casting

Hi all,
Can anybody please tell the usuage of wide casting.
preferable with simple code.
Anirban Bhattacharjee

Hi,
1. Wider/up casting :
This means a ref object used is of a parent. Now here technically speaking you can only call the methods of the parent class and not of the child class. Even if the parent object is referencing to a child object at runtime, the compiler does not allow you to call the child method.
Wide casting does not have run-time errors as the compiler is able to identify the error at compile time only.
Wide casting is helpful when you want to have a generic parameter as the importing parameter in OOPs.
For eg.
Class p1
method x.
Class c1 parent p1
method y.
Class c2 parent p1
method z.
In the above example both class c1 and c2 are subclasses of p1 and therefore has method x.
Now let us say the user at runtime can pass object of c1,c2 or p1 and method x has to be capable of receiving all these, then in such case you can assign reference object of parent to method x.
So method x can be defined as follows
Class p1
method x importing p  -
> where p is type ref to p1.
I hope this explains your query.
Regards,
Saurabh

Similar Messages

  • How important it is to understand Concept of Narrow & Wide casting in ABAP Objects

    Hi Friends,
    I Understood that, it is very important to understand the concept of "Casting ( Narrow Casting & Wide Casting )" properly.
    Let us see the following cases where the concept of "Casting ( Narrow Casting & Wide Casting )" comes into the picture in various practices of Abap, Webdynpro abap and FPM.
    1. ABAP:-
    When we are working with RTTS in abap it is very much important we must know the Casting Techniques. Without knowledge of the Casting of objects, there will be a lot of trouble we may faces.
    Mainly RTTS offers Runtime Type Services, means RTTS Programming enables us to find the type of the particular data obejct or data type or data reference in the run time.
    RTTS also enables us to create the data in the run time very dynamically.
    So, in the run time when we finding the type of the data objects or creation of data objects in the run time, We must do the Wide casting and Narrow casting also some times on the references provided by SAP Dynamically.
    So, here we go to have knowledge on Casting is mandatory.
    2. WEBDYNPRO ABAP:-
    The another point where the concept of casting comes into picture is , When we working with the ALV Reports and Dynamic programming of WEBDYNPRO. Here also we should posses good casting skills.
    3. FPM:-
    The major use of casting comes in hand is none other than FPM. When we working with certain Floor Plans or when we woking with Feeder Class concept of FPM, Casting comes into picture again.
    Along with Casting ( Narrow casting & Wide casting ), We must have the knowledge of 'Field Symbols' and 'Data References (known & Unknown)' to work with our all complex scenarios of Webdynpro and FPM and all.
    So guys, please have Knowledge on the following, befor you master on advanced techniques of WEBDYNPRO and FPM etc.
         1. Field Symbols
         2. Data References (known & unknown)
         3. Casting (Narrow casting & Wide casting)
         4. Brief Idea about RTTS
    All the above 4 concepts will definitely make our life easy when dig more into WEBDYNPRO ABAP and FPM.
    Thank You.
    Please share your comments on the same.

    Hi Shankar,
    It's really good to know.
    It could be great if you can share few technicalities for the concepts explained.
    Regards,
    Rafi

  • Why narrow casting is must before doing wide casting

    Hi everyone,
    I know the concept of wide casting ( assign/pass super class instances to subclass instances). So then why we need to do narrow casting before doing wide casting in our logic. I am just struggling into this concept from last 3 days. I have read many thread and blog but did not get satisfactory answer.
    Regards,
    Seth

    Hello Seth
    You do not need to do narrow casting. But, if you assign an instance of a super class to variable of subclass and try to run a subclass' method on that instance (of superclass) you will get an exception. Because super class does not have a mentioned method.
    Example:
    CLASS lcl_vehicle DEFINITION.
    ENDCLASS.
    CLASS lcl_car DEFINITION INHERITING FROM lcl_vehicle.
      DATA engine TYPE string VALUE 'has_engine'.
    ENDCLASS.
    DATA:
      lo_vehicle TYPE lcl_vehicle,
      lo_car TYPE lcl_car.
    CREATE OBJECT lo_vehicle.
    CREATE OBJECT lo_car.
    WRITE lo_car->engine.
    lo_car ?= lo_vehicle.
    WRITE lo_car->engine.
    regards

  • Narrow casting vs wide casting

    Hello All,
    I have small requriemn..
    I have a super class A and a sub class B.
    In both the classes I have a method XYZ.
    So, A has the following methods
    ABC
    XYZ
    B has the following methods
    XYZ
    Now I have want to access the sub class methods from super class...i.e., in my example...Method XYZ of B class needs to be accessed from method ABC or XYZ or A.
    How do I do?
    And more over..what is the difference between Narrow Casting and Wide casting?
    Kalyan

    Hi Priya,
    Consider the below Example for accessing the subclass method from Superclass:
    CLASS LCL_SUPERCLASS DEFINITION.
       PUBLIC SECTION.
           METHODS: ABC, XYZ.
    ENDCLASS.
    CLASS LCL_SUPERCLASS IMPLEMENTATION.
      METHOD ABC.
       CALL METHOD ME->XYZ.
      ENDMETHOD.
      METHOD XYZ.
      ENDMETHOD.
    ENDCLASS.
    CLASS LCL_SUBCLASS DEFINITION
           INHERITING FROM LCL_SUPERCLASS.
       PUBLIC SECTION.
          METHODS XYZ REDEFINITION.
    ENDCLASS.
    CLASS LCL_SUBCLASS IMPLEMENTATION.
      METHOD XYZ.
      ENDMETHOD.
    ENDCLASS.
    START-OF-SELECTION.
    DATA: O_SUPER TYPE REF TO LCL_SUPERCLASS,
               O_SUB     TYPE REF TO LCL_SUBCLASS.
    CREATE OBJECT: O_SUPER, O_SUB.
    CALL METHOD O_SUPER->ABC.
    CALL METHOD O_SUB->ABC.
    In the above example, When you call the superclass method ABC using CALL METHOD O_SUPER->ABC, as you see in the implementation part of the Method it will inturn call the Superclass method XYZ.
    Here ME will point to the instance of the Superclass.
    But the CALL METHOD O_SUB->ABC will call the method ABC ( this is inherited from Superclass to Subclass )and inturn it calls the method XYZ of the SUbclass since ME now points to the object O_SUB of the Subclass.
    Hope this is clear.
    Regards,
    Nirupamaa.

  • Why ?= used in wide casting

    in wide casting , if we are assigning super class object2 to super class object1 using '?='. having the same effect as '='. so y we need to add '?' in wide casting.
    class lcl_super DEFINITION.
       PUBLIC SECTION.
       METHODS method1.
      ENDCLASS.
      CLASS lcl_super IMPLEMENTATION.
        method method1.
          write : 'super class method'.
          ENDMETHOD.
          ENDCLASS.
      class lcl_sub DEFINITION INHERITING FROM lcl_super.
        PUBLIC SECTION.
        methods : method1 REDEFINITION,
                  method2.
        ENDCLASS.
        CLASS lcl_sub IMPLEMENTATION.
          method method1.
            write ' subclass method1'.
            ENDMETHOD.
            method method2.
              write 'subclass method2'.
              ENDMETHOD.
          ENDCLASS.
    data: obj1 type REF TO lcl_super,
           obj2 type REF TO lcl_sub.
    START-OF-SELECTION.
    create OBJECT obj1.
    CREATE OBJECT obj2.
    obj1 = obj2.                                     "Narrrowing casting
    CALL METHOD obj1->method1.
    data obj3 type REF TO lcl_super.
    create OBJECT obj3.
    obj1 ?= obj3.   or obj1 = obj3             "   is having same effect  in Widecasting,  so why need '?'
    obj1->method1( ).

    Hi vijay,
    in addition to what Rudiger said, to know what ?= means, refer to this link: http://help.sap.com/abapdocu_70/en/ABAPMOVE.htm
    In the next example, ?= is needed:
    DATA:  obj_struct  TYPE REF TO cl_abap_structdescr.
    obj_struct ?= cl_abap_structdescr=>describe_by_name( 'DDTAB_NAME' ).
    Regards,
    Angelo.

  • Wide casting problem

    Hi All,
    Can u explain Wide casting in detail ? already i gone through sdn links but still i didnt get clear .  please go through the follwing code snippet and explain where i made mistake in order to getting wide casting.. my problem is as wide casting i want to access the base class methods with reference of sub class when the base class methods are redefined in sub class(actually sub class reference access the  subclass methods only if we have same methods in base and as well as sub class) in my program after performing wide cast also it is accessing sub class methods only please send the answer.
    REPORT  ZNARROW_WIDE.
    CLASS C1 DEFINITION.
    PUBLIC SECTION.
    METHODS:M1,M2.
    ENDCLASS.
    CLASS C1 IMPLEMENTATION.
    METHOD M1.
    WRITE:/ ' THIS IS SUPER CLASS METHOD M1'.
    ENDMETHOD.
    METHOD M2.
    WRITE:/ ' THIS IS SUPER CLASS METHOD M2'.
    ENDMETHOD.
    ENDCLASS.
    CLASS C2 DEFINITION INHERITING FROM C1.
    PUBLIC SECTION.
    METHODS:M1 REDEFINITION.
    METHODS:M2 REDEFINITION,
                      M3.
    ENDCLASS.
    CLASS C2 IMPLEMENTATION.
    METHOD M1.
    WRITE:/ ' THIS IS SUB CLASS METHOD M1'.
    ENDMETHOD.
    METHOD M2.
    WRITE:/ ' THIS IS SUBCLASS METHOD M2'.
    ENDMETHOD.
    METHOD M3.
    WRITE:/ ' THIS IS SUB CLASS METHOD M3'.
    ENDMETHOD.
    ENDCLASS.
    DATA:O_SUPER TYPE REF TO C1,
         O_SUB TYPE REF TO C2.
    START-OF-SELECTION.
    CREATE OBJECT O_SUPER.
    CREATE OBJECT O_SUB.
    CALL METHOD O_SUPER->M1.
    CALL METHOD O_SUPER->M2.
    CLEAR O_SUPER.
    O_SUPER = O_SUB.
    CALL METHOD O_SUPER->('M3').
    SKIP 5.
    ULINE 1(80).
    CLEAR O_SUB.
    O_SUB ?= O_SUPER.
    CALL METHOD O_SUB->M1.
    CALL METHOD O_SUB->M2.
    CALL METHOD O_SUB->M3.
    Thanks in advance.
    sreenivas P

    Hi,
    consider the following sample code:
    REPORT  ZA_TEST93.
    class class_super definition.
      public section.
        data: var_area type i.
        methods:
        area importing length type i breadth type i.
    endclass.
    class class_super implementation.
      method area.
        var_area = length * breadth.
        write:/ 'Area of rectangle = '.
        write: var_area.
      endmethod.
    endclass.
    class class_sub definition inheriting from class_super.
      public section.
      data:height type i.
      methods:
      area redefinition.
    endclass.
    class class_sub implementation.
      method area.
        var_area = 6 * length * breadth * height.
        write:/ 'Area of the cube ='.
        write: var_area.
      endmethod.
    endclass.
    start-of-selection.
    data: object_superclass type ref to class_super,
          object_subclass type ref to class_sub,
          object2_superclass type ref to class_super.
    create object object_superclass.
    create object object2_superclass.
    create object object_subclass.
    call method object_superclass->area exporting length = 10 breadth = 5.
    "Narrow casting
    object_subclass->height = 10.
    object_superclass = object_subclass.
    call method object_superclass->area exporting length = 10 breadth = 10.
    "Wide casting
    object_superclass ?= object2_superclass.
    call method object_superclass->area exporting length = 10 breadth = 5.
    Explanation:
    In the above code, consider the super class named 'class_super'.
    This class has a method called 'area' which is used to calculate the area of a rectangle.
    Consider the subclass 'class_sub', which inherits all the attributes and methods of super class 'class_super'.
    Now we want to use the same method of super class 'class_super', 'area', but this time we want it to calculate the area of a cube.
    For this purpose we use the 'redefinition' keyword in the definition part of 'class_sub' and enter the code for cube area calculation in the 'area' method body in the implementation part of 'class_sub'.
    From the above code, consider the following code snippet:
    create object object_superclass.
    create object object2_superclass.
    create object object_subclass.
    call method object_superclass->area exporting length = 10 breadth = 5.
    Explanation: Two objects of the superclass and one object of the subclass are created and the 'area' method of the superclass is called to compute the area of a rectangle.
    Now consider what comes next:
    "Narrow casting
    object_subclass->height = 10.
    object_superclass = object_subclass.
    call method object_superclass->area exporting length = 10 breadth = 10.
    Explanation:
    We assign a value of 10 to the 'height' instance variable of the subclass object.
    Then we perform narrow casting in the next line(object_superclass = object_subclass.).
    Now the instance of the superclass(object_superclass) now points or refers to the object of the subclass, thus the modified method 'area' of the subclass is now accessible.
    Then we call this method 'area' of the subclass to compute the area of the cube.
    Moving on to the final piece of code:
    "Wide casting
    object_superclass ?= object2_superclass.
    call method object_superclass->area exporting length = 10 breadth = 5.
    Explanation:
    The object 'object_superclass' now refers to the object of the subclass 'object_subclass'.
    Thus the 'area' method of the superclass cannot be called by this object.
    In order to enable it to call the 'area' method of the superclass, wide casting has to be perfomed.
    For this purpose, the RHS of the wide casting must always be an object of a superclass, and the LHS of the wide casting must always be an object reference declared as 'type ref to' the superclass(objectsuperclass ?= object2_superclass.)._
    Otherwise a runtime error will occur.
    Finally the 'area' method of the superclass can now be called once again to compute the area of the rectangle.
    The output of the above example program is as follows:
    Area of rectangle =          50
    Area of the cube =      6,000
    Area of rectangle =          50
    Also note that wide casting cannot be performed on subclass objects, wide casting can only be performed on superclass objects that have been narrow cast.
    Hope my explanation was useful,
    Regards,
    Adithya.
    Edited by: Adithya K Ramesh on Dec 21, 2011 11:49 AM
    Edited by: Adithya K Ramesh on Dec 21, 2011 11:51 AM

  • Narrow cast and wide cast in ABAP OO

    Hi Xperts
    Considering the code below can the concepts of narrowing cast and widening cast be explained ? Kindly help me in getting a clear picture of the usage of it.
    CLASS C1 DEFINITION.
      PUBLIC SECTION.
        CLASS-DATA: COUNT TYPE I.
        CLASS-METHODS: DISP.
    ENDCLASS.                    "defintion  C1
    CLASS C1 IMPLEMENTATION.
      METHOD DISP.
        WRITE :/ COUNT.
      ENDMETHOD.                    "disp
    ENDCLASS.                    "c1 IMPLEMENTATION
    CLASS C2 DEFINITION INHERITING FROM C1.
      PUBLIC SECTION.
        CLASS-METHODS: GET_PROP.
    ENDCLASS.                    "c2  INHERITING C1
    CLASS C2 IMPLEMENTATION.
      METHOD GET_PROP.
        COUNT = 9.
        CALL METHOD DISP.
      ENDMETHOD.                    "get_prop
    ENDCLASS.                    "c2 IMPLEMENTATION
    START-OF-SELECTION.
      DATA: C1_REF TYPE REF TO C1,
            C2_REF TYPE REF TO C2.
    PS: Pls dont post any links as i already gone thru couple of those in SDN but couldnt get a clear info

    Hi
    I got to know abt narrow cast: referecing a super class ref to a subclass ref so that the methods in subclass can be accessed by the super class reference. Below is snippet of the code i'd checked. Hope this is correct to my understanding. If any faults pls correct me. Also if anyone can explain wideing cast in this context will be very helpful
    FOR NARROW CAST
    {size:8}
    CLASS C1 DEFINITION.
      PUBLIC SECTION.
        CLASS-DATA: COUNT TYPE I.
        CLASS-METHODS: DISP_COUNT.
    ENDCLASS.                    "defintion  C1
    CLASS C1 IMPLEMENTATION.
      METHOD DISP_COUNT.
        WRITE :/ 'Class C1', COUNT.
      ENDMETHOD.                    "disp
    ENDCLASS.                    "c1 IMPLEMENTATION
    CLASS C2 DEFINITION INHERITING FROM C1.
      PUBLIC SECTION.
        CLASS-METHODS: GET_PROP,
                       DISP.
    ENDCLASS.                    "c2  INHERITING C1
    CLASS C2 IMPLEMENTATION.
      METHOD GET_PROP.
        COUNT = 9.
        CALL METHOD DISP.
      ENDMETHOD.                    "get_prop
      METHOD DISP.
        WRITE :/ 'Class C2', COUNT.
      ENDMETHOD.                    "DISP
    ENDCLASS.                    "c2 IMPLEMENTATION
    START-OF-SELECTION.
      DATA: C1_REF TYPE REF TO C1,
            C2_REF TYPE REF TO C2.
      CREATE OBJECT: C2_REF TYPE C2.
    *  CREATE OBJECT: C1_REF TYPE C1.
      BREAK-POINT.
      C1_REF = C2_REF.
      CALL METHOD C1_REF->DISP_COUNT.
      CALL METHOD C1_REF->('GET_PROP').
    {size}
    Edited by: Prabhu  S on Mar 17, 2008 3:25 PM

  • Narrowing cast and widening cast

    Hi All,
           I want to know what is the use of a narrowing cast and a widening cast in ABAP objects.
    Can someone please give an example ?
    Regards,
    Ashish

    Hi,
    Check out this link, This will guide you on ABAP Objects
    http://www.sap-press.de/katalog/buecher/htmlleseproben/gp/htmlprobID-28?GalileoSession=22448306A3l7UG82GU8#level3~3
    Both narrow and wide casting are related to inheritance.
    In Narrow casting, you assign a runtime object of subclass to runtime object of superclass. By this assignment , you can access your subclass by using runtime object of your superclass. But here the important point is that, you are assigning subclass reference to super class reference, so you can only access the inherited components of subclass through super class reference.
    Suppose you have a super class lcl_vehicle. it has two subclasses lcl_car and lcl_truck.
    r_vehicle = r_car.
    In Wide casting, you assign a superclass reference to subclass reference . Before this, you do narrow casting,
    Now when you assign a superclass reference to subclass reference. You can access the inherited as well as the specific components of subclass.
    taking the same example,
    r_car ?= r_vehicle.
    '?='  wide cast operator.
    Regards
    Abhijeet

  • Doubts in narrow casting

    I was looking for narrow casting examples to understand concepts better.
    what i have seen everywhere is that
    after narrow casting that i.e assigining/copying child object to parent object we can use parent object to
    call method  which exits in sub class though redefined (of course it also exists in super class).
    Till here its fine.
    But we can't use parent variable to call method in subclass which does not exist in super class.
    it's showing syntax error but a little change in that have made its syntax correct.
    Take a look at this example....
    REPORT  ZNEWOO6.
    *       CLASS vehicle DEFINITION
    class vehicle definition.
       public section.
         methods: m1 ,
         m2.
    endclass.                    "vehicle DEFINITION
    *       CLASS vehicle IMPLEMENTATION
    class vehicle implementation.
       method m1.
         write /'method m1 super class imple.'.
       endmethod.                    "m1
       method m2.
         write /'method m2 super class imple.'.
       endmethod.                    "m1
    endclass.                    "vehicle IMPLEMENTATION
    *       CLASS truck DEFINITION
    class truck definition inheriting from vehicle.
       public section.
         methods:
         m2 redefinition,
         m4.
    endclass.                    "truck DEFINITION
    *       CLASS truck IMPLEMENTATION
    class truck implementation.
       method m2 .
         write /'method m2 redefination sub class imple.'.
       endmethod.                    "m2
       method m4.
    *      method m1.
         write /'method m4 sub class imple.'.
    *  endmethod.
       endmethod.                    "m4
    endclass.                    "truck IMPLEMENTATION
    start-of-selection .
       data : o_super type ref to vehicle,
             o_sub type ref to truck.
       create object :o_super, o_sub.
       call method o_super->m1.
       call method o_sub->m1.
       call method o_super->m2( ).
       o_super = o_sub."up/narrow casting "assigning child to parent
    *o_sub ?= o_super. "down/wide casting
       create object o_super.
       call method o_super->m2.
       call method o_sub->m2.
       "not possible to access those
    *method which are not defined in super class
    call method o_super->m4. "throw a syntax error
    call method o_super->('m4'). "works fine WHY!!!!!! "Even though m4 is not defined in super class

    Hello Abaper,
    when u assign subclass obj to super class its narrow casting,
    but when u create a new object create object o_super.
    it call the old reffernce so o_super call its own m2 instead of subclass m2
    modified code
    *& Report  ZTESTSWADHIN1
    REPORT ZTESTSWADHIN1.
    *       CLASS vehicle DEFINITION
    class vehicle definition.
       public section.
         methods: m1 ,
         m2.
    endclass.                    "vehicle DEFINITION
    *       CLASS vehicle IMPLEMENTATION
    class vehicle implementation.
       method m1.
         write /'method m1 super class imple.'.
       endmethod.                    "m1
       method m2.
         write /'method m2 super class imple.'.
       endmethod.                    "m1
    endclass.                    "vehicle IMPLEMENTATION
    *       CLASS truck DEFINITION
    class truck definition inheriting from vehicle.
       public section.
         methods:
         m2 redefinition,
         m4.
    endclass.                    "truck DEFINITION
    *       CLASS truck IMPLEMENTATION
    class truck implementation.
       method m2 .
         write /'method m2 redefination sub class imple.'.
       endmethod.                    "m2
       method m4.
    *      method m1.
         write /'method m4 sub class imple.'.
    *  endmethod.
       endmethod.                    "m4
    endclass.                    "truck IMPLEMENTATION
    start-of-selection .
       data : o_super type ref to vehicle,
             o_sub type ref to truck.
       create object :o_super, o_sub.
       call method o_super->m1.
       call method o_sub->m1.
       call method o_super->m2( ).
       o_super = o_sub."up/narrow casting "assigning child to parent
    *o_sub ?= o_super. "down/wide casting
    *   create object o_super.
       call method o_super->m2.
       call method o_sub->m2.
    For Details Have alook
    Check o_sub and o_super value..\
    Hope this help.

  • Internet Explorer ONLY passes parameters to Adobe Reader plugin for hosted files, not local

    WORKS:
    <embed src="http://host.com/test.pdf#page=5"/>
    FAILS:
    <embed src="test.pdf#page=5"/>
    Both code snippets above work when the HTML file is hosted (IIS / Apache).  My web-app needs to be able to run from a USB memory stick and work with IE9.  The #page param is required for a core feature of the app.
    Parameters after the # are passed correctly to the Adobe Reader plugin in Firefox for offline files, eg: file:///C:/test.htm.  The documentation only describes hosted examples: http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/pdf_open_parameters.pdf
    I have tried the <object> route as well with similar results, eg: http://pdfobject.com/
    I have burned over 8 hours looking for a solution. I have tried any logical settings in Adobe Reader X, and with the security zones in IE.  I am not very familiar with IE security zones, but I suspect it could be related to my issue.  I can specify the end-user change any browser or plugin settings as an acceptable solution.

    I am developing a hybrid web-application that needs to work both offline (entire website) and in a hosted environment.  A key part of the product is displaying PDF's with a dynamic index outside of the PDF. This allows us to use PDF's collected from hundreds of contractors, clients and manufacturers and combine them into one searchable product with a consistent interface.  I can specify product requirements including IE browser settings, installed plug-ins etc. I am not trying to cater to a wide audience such as everyone online, but a specific one that is spending $5k-30k for a custom resource.
    I expect the limiation is due to a wide cast net regarding security.  I tried every setting in IE and essentially fully disabling all security options did not resolve it.
    I found a solution, by accessing the ActiveX object directly you can use the exposed classes described here: http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/wwhelp/wwhimpl/common/html/w whelp.htm?context=Acrobat9_HTMLHelp&file=IAC_API_OLE_Objects.103.167.html
    Javascript:
    var pdfO = document.getElementById('pdfObj');
    pdfO.setCurrentPage(pageNumber);
    HTML:
    <OBJECT id ="pdfObj" data="test.pdf" TYPE="application/pdf">
        <a href="test.pdf">Fall-back code</a>
    </OBJECT>
    This actually works much faster as well, since the plugin doesn't need to be re-drawn in the DOM

  • Abap Objects doubts.

    Hi Experts.
    Plz give me some details for the following questions.
    1. what is abstract class.
    2. give me some example program using inheritance.
    3. Some sample programs using events.
    4. Narrow casting & wide casting.. And describe the use of it.
    5. How to declare internal table in ABAP OOPS.
    6. What is the use of table type.?
    7. What is instance.?
    8. Explain friend class.
    Thank in advance.
    Points will be given for the answers.
    regards,
    J.Joe

    HI
    <b>1. what is abstract class.</b>
    Abstract classes are normally used as an incomplete blueprint for concrete (that is, non-abstract) subclasses, for example to define a uniform interface.
    Classes with at least one abstract method are themselves abstract.
    Static methods and constructors cannot be abstract.
    You can specify the class of the instance to be created explicitly: CREATE OBJECT <RefToAbstractClass> TYPE <NonAbstractSubclassName>.
    Abstarct classes themselves can’t be instantiated ( althrough their subclasses can)
    Reference to abstract classes can refer to instance of subclass
    Abstract (instance) methods are difined in the class , but not implemented
    They must be redefined in subclasses
    CLASS LC1 DEFINAITION ABSTARCT
    PUBLIC SECTION
    METHODS ESTIMATE ABSTARCT IMPORTING…
    ENDCLASS.
    <b>2. give me some example program using inheritance.</b>
    The following simple example shows the principle of inheritance within ABAP Objects. It is based on the Simple Introduction to Classes. A new class counter_ten inherits from the existing class counter.
    REPORT demo_inheritance.
    CLASS counter DEFINITION.
      PUBLIC SECTION.
        METHODS: set IMPORTING value(set_value) TYPE i,
                 increment,
                 get EXPORTING value(get_value) TYPE i.
       PROTECTED SECTION .
        DATA count TYPE i.
    ENDCLASS.
    CLASS counter IMPLEMENTATION.
      METHOD set.
        count = set_value.
      ENDMETHOD.
      METHOD increment.
        ADD 1 TO count.
      ENDMETHOD.
      METHOD get.
        get_value = count.
      ENDMETHOD.
    ENDCLASS.
    CLASS counter_ten DEFINITION INHERITING FROM counter.
      PUBLIC SECTION.
        METHODS increment REDEFINITION .
        DATA count_ten.
    ENDCLASS.
    CLASS counter_ten IMPLEMENTATION.
      METHOD increment.
        DATA modulo TYPE I.
         CALL METHOD super->increment .
        write / count.
        modulo = count mod 10.
        IF modulo = 0.
          count_ten = count_ten + 1.
          write count_ten.
        ENDIF.
      ENDMETHOD.
    ENDCLASS.
    DATA: count TYPE REF TO counter,
          number TYPE i VALUE 5.
    START-OF-SELECTION.
       CREATE OBJECT count TYPE counter_ten .
      CALL METHOD count->set EXPORTING set_value = number.
      DO 20 TIMES.
        CALL METHOD count->increment.
      ENDDO.
    The class COUNTER_TEN is derived from COUNTER. It redefines the method INCREMENT. To do this, you must change the visibility of the COUNT attribute from PRIVATE to PROTECTED. The redefined method calls the obscured method of the superclass using the pseudoreference SUPER->. The redefined method is a specialization of the inherited method.
    The example instantiates the subclass. The reference variable pointing to it has the type of the superclass. When the INCREMENT method is called using the superclass reference, the system executes the redefined method from the subclass.
    <b>3. Some sample programs using events.</b>
    Events in ABAP Objects - Example
    The following example shows how to declare, call, and handle events in ABAP Objects.
    Overview
    This object works with the interactive list displayed below. Each user interaction triggers an event in ABAP Objects. The list and its data is created in the class C_LIST. There is a class STATUS for processing user actions. It triggers an event BUTTON_CLICKED in the AT USER-COMMAND event. The event is handled in the class C_LIST. It contains an object of the class C_SHIP or C_TRUCK for each line of the list. Both of these classes implement the interface I_VEHICLE. Whenever the speed of one of these objects changes, the event SPEED_CHANGE is triggered. The class C_LIST reacts to this and updates the list.
    Constraints
    The ABAP statements used for list processing are not yet fully available in ABAP Objects. However, to produce a simple test output, you can use the following statements:
    WRITE [AT] /<offset>(<length>) <f>
    ULINE
    SKIP
    NEW-LINE
    Note: The behavior of formatting and interactive list functions in their current state are not guaranteed. Incompatible changes could occur in a future release.
    Declarations
    This example is implemented using local interfaces and classes. Below are the declarations of the interfaces and classes:
    Interface and Class declarations
    INTERFACE I_VEHICLE.
      DATA     MAX_SPEED TYPE I.
      EVENTS SPEED_CHANGE EXPORTING VALUE(NEW_SPEED) TYPE I.
      METHODS: DRIVE,
               STOP.
    ENDINTERFACE.
    CLASS C_SHIP DEFINITION.
      PUBLIC SECTION.
      METHODS CONSTRUCTOR.
      INTERFACES I_VEHICLE.
      PRIVATE SECTION.
      ALIASES MAX FOR I_VEHICLE~MAX_SPEED.
      DATA SHIP_SPEED TYPE I.
    ENDCLASS.
    CLASS C_TRUCK DEFINITION.
      PUBLIC SECTION.
      METHODS CONSTRUCTOR.
      INTERFACES I_VEHICLE.
      PRIVATE SECTION.
      ALIASES MAX FOR I_VEHICLE~MAX_SPEED.
      DATA TRUCK_SPEED TYPE I.
    ENDCLASS.
    CLASS STATUS DEFINITION.
      PUBLIC SECTION.
       CLASS-EVENTS BUTTON_CLICKED EXPORTING VALUE(FCODE) LIKE SY-UCOMM.
      CLASS-METHODS: CLASS_CONSTRUCTOR,
                    USER_ACTION.
    ENDCLASS.
    CLASS C_LIST DEFINITION.
      PUBLIC SECTION.
      METHODS: FCODE_HANDLER FOR EVENT BUTTON_CLICKED OF STATUS
                                 IMPORTING FCODE,
               LIST_CHANGE   FOR EVENT SPEED_CHANGE OF I_VEHICLE
                                 IMPORTING NEW_SPEED,
               LIST_OUTPUT.
      PRIVATE SECTION.
      DATA: ID TYPE I,
            REF_SHIP  TYPE REF TO C_SHIP,
            REF_TRUCK TYPE REF TO C_TRUCK,
            BEGIN OF LINE,
              ID TYPE I,
              FLAG,
              IREF  TYPE REF TO I_VEHICLE,
              SPEED TYPE I,
            END OF LINE,
            LIST LIKE SORTED TABLE OF LINE WITH UNIQUE KEY ID.
    ENDCLASS.
    The following events are declared in the example:
    The instance event SPEED_CHANGE in the interface I_VEHICLE
    The static event BUTTON_CLICKED in the class STATUS.
    The class C_LIST contains event handler methods for both events.
    Note that the class STATUS does not have any attributes, and therefore only works with static methods and events.
    Implementations
    Below are the implementations of the methods of the above classes:
    Implementations
    CLASS C_SHIP IMPLEMENTATION.
      METHOD CONSTRUCTOR.
        MAX = 30.
      ENDMETHOD.
      METHOD I_VEHICLE~DRIVE.
        CHECK SHIP_SPEED < MAX.
        SHIP_SPEED = SHIP_SPEED + 10.
        RAISE EVENT I_VEHICLE~SPEED_CHANGE
                    EXPORTING NEW_SPEED = SHIP_SPEED.
      ENDMETHOD.
      METHOD I_VEHICLE~STOP.
        CHECK SHIP_SPEED > 0.
        SHIP_SPEED = 0.
        RAISE EVENT I_VEHICLE~SPEED_CHANGE
                    EXPORTING NEW_SPEED = SHIP_SPEED.
      ENDMETHOD.
    ENDCLASS.
    CLASS C_TRUCK IMPLEMENTATION.
      METHOD CONSTRUCTOR.
        MAX = 150.
      ENDMETHOD.
      METHOD I_VEHICLE~DRIVE.
        CHECK TRUCK_SPEED < MAX.
        TRUCK_SPEED = TRUCK_SPEED + 50.
        RAISE EVENT I_VEHICLE~SPEED_CHANGE
                    EXPORTING NEW_SPEED = TRUCK_SPEED.
      ENDMETHOD.
      METHOD I_VEHICLE~STOP.
        CHECK TRUCK_SPEED > 0.
        TRUCK_SPEED = 0.
        RAISE EVENT I_VEHICLE~SPEED_CHANGE
                    EXPORTING NEW_SPEED = TRUCK_SPEED.
      ENDMETHOD.
    ENDCLASS.
    CLASS STATUS IMPLEMENTATION.
      METHOD CLASS_CONSTRUCTOR.
        SET PF-STATUS 'VEHICLE'.
        WRITE 'Click a button!'.
      ENDMETHOD.
      METHOD USER_ACTION.
        RAISE EVENT BUTTON_CLICKED EXPORTING FCODE = SY-UCOMM.
      ENDMETHOD.
    ENDCLASS.
    CLASS C_LIST IMPLEMENTATION.
      METHOD FCODE_HANDLER .
        CLEAR LINE.
        CASE FCODE.
          WHEN 'CREA_SHIP'.
            ID = ID + 1.
            CREATE OBJECT REF_SHIP.
            LINE-ID = ID.
            LINE-FLAG = 'C'.
            LINE-IREF = REF_SHIP.
            APPEND LINE TO LIST.
          WHEN 'CREA_TRUCK'.
            ID = ID + 1.
            CREATE OBJECT REF_TRUCK.
            LINE-ID = ID.
            LINE-FLAG = 'T'.
            LINE-IREF = REF_TRUCK.
            APPEND LINE TO LIST.
          WHEN 'DRIVE'.
            CHECK SY-LILLI > 0.
            READ TABLE LIST INDEX SY-LILLI INTO LINE.
            CALL METHOD LINE-IREF->DRIVE.
          WHEN 'STOP'.
            LOOP AT LIST INTO LINE.
              CALL METHOD LINE-IREF->STOP.
            ENDLOOP.
          WHEN 'CANCEL'.
            LEAVE PROGRAM.
        ENDCASE.
        CALL METHOD LIST_OUTPUT.
      ENDMETHOD.
      METHOD LIST_CHANGE .
        LINE-SPEED = NEW_SPEED.
        MODIFY TABLE LIST FROM LINE.
      ENDMETHOD.
      METHOD LIST_OUTPUT.
        SY-LSIND = 0.
        SET TITLEBAR 'TIT'.
        LOOP AT LIST INTO LINE.
          IF LINE-FLAG = 'C'.
            WRITE / ICON_WS_SHIP AS ICON.
          ELSEIF LINE-FLAG = 'T'.
            WRITE / ICON_WS_TRUCK AS ICON.
          ENDIF.
          WRITE: 'Speed = ', LINE-SPEED.
        ENDLOOP.
      ENDMETHOD.
    ENDCLASS.
    The static method USER_ACTION of the class STATUS triggers the static event BUTTON_CLICKED. The instance methods I_VEHICLEDRIVE and I_VEHICLESTOP trigger the instance event I_VEHICLE~SPEED_CHANGE in the classes C_SHIP and C_TRUCK.
    Using the Classes in a Program
    The following program uses the above classes:
    REPORT OO_EVENTS_DEMO NO STANDARD PAGE HEADING.
    Global data of program
    DATA LIST TYPE REF TO C_LIST.
    Program events
    START-OF-SELECTION.
      CREATE OBJECT LIST.
      SET HANDLER: LIST->FCODE_HANDLER,
                  LIST->LIST_CHANGE FOR ALL INSTANCES.
    AT USER-COMMAND.
      CALL METHOD STATUS=>USER_ACTION.
    The program creates an object of the class C_LIST and registers the event handler method FCODE_HANDLER of the object for the class event BUTTON_CLICKED, and the event handler method LIST_CHANGE for the event SPEED_CHANGE of all instances that implement the interface I_VEHICLE.
    <b>4. Narrow casting & wide casting.. And describe the use of it.</b>
    <b>Narrowing Cast</b>
    The assignment of a subclass instance to a reference variable of the type "reference to superclass" is described as a narrowing cast, because you are switching from a more detailed view to a one with less detail.
    Description up-cast is also used.
    <b>use</b>
    A user who is not interested in the finer points of cars, trucks, and busses (but only, for example, in the fuel consumption and tank gauge) does not need to know about them. This user only wants and needs to work with (references to) the lcl_vehicle class. However, in order to allow the user to work with cars, busses, or trucks, you generally need a narrowing cast.
    <b>Widening cast</b>
    The widening cast logically represents the opposite of the narrowing cast. The widening cast cannot be checked statically, only at runtime. The Cast Operator ?= (or the equivalent MOVE ... ?TO … ) must be used to make this visible.
    It changes from a less detailed view to one with more detail.
    <b>use</b>
    The client, the car rental company  wants to execute a function for specific vehicles form the list (vehicle_list).  For example, the client wants to ascertain the truck with the largest cargo capacity.  However, not all vehicles are in the trucks list, it also includes references to cars and busses.
    <b>5. How to declare internal table in ABAP OOPS.</b>
    BEGIN OF LINE,
              ID TYPE I,
              FLAG,
              IREF  TYPE REF TO I_VEHICLE,
              SPEED TYPE I,
            END OF LINE,
    <b>6. What is the use of table type.?</b>
    Please check the SAP help , as all these things are provided in detail in it .
    In case you find it difficult to find it or search for it here is the link
    http://help.sap.com/saphelp_nw04/helpdata/en/90/8d7304b1af11d194f600a0c929b3c3/frameset.htm
    <b>7. What is instance.?</b>
    Instance methods are called using CALL METHOD <reference>-><instance_method>.
    Static methods (also referred to as class methods) are called using CALL METHOD <classname>=><class_method>.
    If you are calling a static method from within the class, you can omit the class name.
    You access instance attributes using <instance>-><instance_attribute>
    <b>8. Explain friend class.</b>
    In rare cases, classes have to work together so closely that they need access to their protected and private components. To avoid making these components available to all users, there is the concept of friendship between classes.
    To do this you use the FRIENDS additions to the CLASS statement, in which all classes and interfaces that are to be provided friendship are listed
    In principle, providing friendship is one-sided: A class providing friendship is not automatically a friend of its friends. If a class providing friendship wants to access the non-public components of a friend, this friend has to explicitly provide friendship to it.
    Classes that inherit from friends and interfaces that contain a friend as a component interface also become friends. However, providing friendship, unlike the attribute of being a friend, is not inherited. A friend of a superclass is therefore not automatically a friend of its subclasses.
    <b>Reward if usefull</b>

  • Querying wide (multi-record case) table data in oracle 10g

    I've got a set of "wide" (multi-record case data format) tables similar to the format described in Oracle's "Oracle Data Mining Concepts" book in chapter 2 (http://download-west.oracle.com/docs/cd/B14117_01/datamine.101/b10698/2data.htm#1010394).
    I like the flexibility of this format, especially since it can handle thousands of attributes. But the main problem I have with this format is in determining how to write efficient, complex queries against the data.
    I've included some sample data below to demonstrate my problem. I've got two tables, one with people and the other with the attributes and values of age, income, height and weight. If I try to generate a complex query against this data, I seem to either have to rely on multisets and functions, or on a large number of self joins. Neither of which seems to scale well or perform well for large amounts of data. I know I could also add a pipelined TABLE function to filter the data more, but none of these options seem like great solutions. Does anyone have any ideas for a better way to form complex well performing queries against this type of data layout?
    For example, with my sample data below I'd like to select everyone whose (income = 2000) or (income = 50000 and weight = 210), but the only way I see of doing this is with a query like the following (which won't take advantage of any indexes on the data):
    select * from people_attributes_view
    where find_eq_attr(AttributeValue('income',2000),attribute_values) is not null
    or (find_eq_attr(AttributeValue('income',50000),attribute_values) is not null
    and
    find_eq_attr(AttributeValue('weight',210),attribute_values) is not null);
    Any help is greatly appreciated.
    Thanks.
    -- My full example starts here ----------------
    -- Create the sample tables and data
    create table people (id int, name varchar(30));
    create table attributes (id int, attribute varchar(10), value NUMBER);
    insert into people values (1,'tom');
    insert into people values (2,'jerry');
    insert into people values (3,'spike');
    commit;
    insert into attributes values (1,'age',23);
    insert into attributes values (1,'income',1000);
    insert into attributes values (1,'height',5);
    insert into attributes values (1,'weight',120);
    insert into attributes values (2,'age',20);
    insert into attributes values (2,'income',2000);
    insert into attributes values (3,'age',30);
    insert into attributes values (3,'income',50000);
    insert into attributes values (3,'weight',210);
    commit;
    -- Create some types, functions and views for the search
    CREATE OR REPLACE TYPE AttributeValue AS OBJECT
    (attribute varchar(30),
    value NUMBER);
    CREATE OR REPLACE TYPE AttributeValues AS TABLE OF AttributeValue;
    create or replace function find_eq_attr (val AttributeValue, vals AttributeValues) RETURN AttributeValue IS
    begin
    for i in vals.FIRST .. vals.LAST
    LOOP
    if ((val.attribute = vals(i).attribute) and
    (val.value = vals(i).value)) then
    return vals(i);
    end if;
    END LOOP;
    return null;
    end;
    create or replace view people_attributes_view as
    select p.name, p.id,
    cast(multiset(select attribute,value from attributes a where a.id = p.id)
    as AttributeValues) attribute_values
    from people p;
    -- Search for everyone whose (income = 2000) or (income = 50000 and weight = 210)
    select * from people_attributes_view
    where find_eq_attr(AttributeValue('income',2000),attribute_values) is not null
    or (find_eq_attr(AttributeValue('income',50000),attribute_values) is not null
    and
    find_eq_attr(AttributeValue('weight',210),attribute_values) is not null);

    I like the flexibility of this format, especially
    since it can handle thousands of attributes. But the
    main problem I have with this format is in
    determining how to write efficient, complex queries
    against the data. Can't be done. The flexibility is achieved at the cost of simplicity and performance, it is a trade off.
    See this thread for a full discussion on the subject.
    http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:10678084117056

  • When will we have Lens Cast Calibration in Lightroom

    Hi,
    I do postproduction all the time for a couple of other photographers. They send me the raws and I develop them. My favourite tool to do this is Lightroom, especially since the quality improvement in version 3.
    However, I often work on architecture shots that were done with a digital back on a technical camera (TC), mainly PhaseOne and Hasselblad backs. All these backs suffer heavily from colour casts when used with wide-angle lenses on TC's, due to the strong inclination of the lightrays on the sensor.
    These images have to be developed in the raw software of the respective brand, CaptureOne for the Phase backs, and Phocus for the Hasselblads.
    Both have a special function to analyse the cast of a separate image which has to be shot each time with a translucent white cap on the lens.
    These casts are then perfectly filtered out, and one can carry on with the rest of the development of the raw file. But this has to be done within Capture1 or Phocus, 'cause you can't export a DNG with the lens cast corrected. You can of course export a Tiff to Lightroom, but then you loose the whole dynamic range of the raw.
    It's this feature that I'm really missing in Lightroom. I prefer using Lightroom, because I use  the local adjustment (gradients and brushes) all the time.
    None of this is possible in CaptureOne or Phocus, a shame really. I wrote to the developers of CaptureOne to ask for local adjustments and it took me 6 mails before the good man understood what I was talking about. Don't they look at Lightroom?
    So Adobe developers, if you could add Lens Cast Correction (or Scene Calibration as it is called in Hasselblad's Phocus), you have the best RAW program in the world, and I can finally dish all these other brand-infected stuff from my hard disk.
    Steven

    Pixelbound, Adobe, Rob & Ssprengel
    What about this
    Scenario
    Take 2 images, from as close a standpoint, ie with camera on the tripod etc.
    1 is the original image,
    2 is the one through the white lens cap.
    You now have the colour cast from centre to corners in the capped image as a reference to work from.
    All that needs to be done - I guess in photoshop - is to remove the colour as referenced by the capped image from the shot.
    Simple in photoshop - like everything is - a plugin / mask / reverse biased logarithmic flip flop or what ever.
    The process in lightroom would most definitely be a develop setting - where one image would be the reference and this could then be applied to one or a selection or all the images.
    As Ssprengel remarked, this is specalised and probably many people would not need it. Then many people did not want the lens correction, and the number of posts and discussions about that are rising most days.
    Rob, one for your sleepless nights
    subtracting  R,G,B on a  pixel by pixel basis from an image, very very simple to do surely....  I'm sure Pixelbound would be impressed, and another notch on your  bedpost of plugins for lightroom.

  • D11 cast window feature in Windows

    I like to have my cast wndow as a 3 wide column on the far
    right of the screen. Has anyone else seen the resize feature of
    this window? When I go to grab the bottom right tab to resize, it
    automatically shrinks by one row, this also happens if I try to
    resize from the sides or bottom. It does this until it cannot
    shrink anymore. Then you can grab the bottom tab and resize.
    Cool joke, but gets a bit boring after a couple of times.
    This feature is in Windows, yet to cough up the dosh for the
    Mac version so not certain if it happens there too. but I think I
    shall wait, judging by D11 in Windows.

    awayand wrote:minimize all except shaken window
    seems pretty clear to me? At any rate, the things you can make Openbox do are all laid out in the big list of 'Actions' (http://openbox.org/wiki/Help:Actions#ToggleShowDesktop) - ToggleShowDesktop coming closest to what you're describing (basically, it's minimize all and shift focus to desktop). No obvious way to make exceptions, though. 
    As for _how_ you do it, there's the Bindings list. I dont use much mouse in OB, so you'll have to find it yourself.

  • Regarding Narrow casting

    Hi Experts,
    Here i am giving one program about narrow casting in which i am not able to access the method called 'fasting', but here i am able to access dynamically.
    So, while doing narrow casting may i know that only dynamically we can able to access that method?
    and may i know the clear picture of wide castening & narrow castening with example.
    Please help it out.
    REPORT  Z15704_NARROWING.
    CLASS lcl_animal DEFINITION.
       PUBLIC SECTION.
         METHODS: hungry.
         ENDCLASS.
         CLASS lcl_lion DEFINITION INHERITING FROM lcl_animal.
            PUBLIC SECTION.
             METHODS: hungry REDEFINITION,
                     fasting.
             ENDCLASS.
             CLASS lcl_animal IMPLEMENTATION.
               METHOD hungry.
                   WRITE: / 'An animal is hungry'.
                    ENDMETHOD.
                    endclass.
                      "hungryENDCLASS.
    CLASS lcl_lion IMPLEMENTATION.
      METHOD hungry .
         WRITE: / 'A Lion (King of Jungle) is hungry.'.
          ENDMETHOD.                    "hungry  METHOD fasting.
          METHOD fasting.
           WRITE: / 'Stop running. Lion is on Fasting today.'.
           ENDMETHOD.
           ENDCLASS.
           START-OF-SELECTION.
            DATA: lo_animal TYPE REF TO lcl_animal,
                      lo_lion   TYPE REF TO lcl_lion.
           " ** ANIMAL object without NARROW casting
            WRITE: / 'Animal - without NARROW casting'.
             CREATE OBJECT lo_animal.
               CALL METHOD lo_animal->hungry( ).
              CLEAR lo_animal.
              "** ANIMAL object with NARROW CASTING  SKIP 2.
               WRITE: / 'Animal -  NARROW casting from LION'.
               CREATE OBJECT lo_lion.
                lo_animal = lo_lion.
                CALL METHOD lo_animal->hungry( ).
                CALL METHOD lo_animal->fasting( ).
    when i call  this method dynamically CALL METHOD lo_animal->('fasting'). i am able to access.
    Thanks,
    Radhika

    In Narrow casting, we create a object reference to the Subclass (LO_LION) first and than we assign that object reference to the reference of the Superclass (LO_ANIMAL). Here we have moved from more specific object to less specific object.
    Refer: http://help-abap.blogspot.com/2008/09/abap-objects-narrowing-cast-upcasting.html
    In widening cast, we create a object referece to the superclass (LO_ANIMAL)  first and than we assign the object reference to the Subclass (LO_LION). Here we move from General object to Specific object. As the principal of the inheritance, every Subobject (LO_LION) will have more attributes/properties than the General object (LO_ANIMAL). So, it would not be possilbe to just create LO_ANIMAL and move to LO_LION. So, when we do the Widening cast, we need to first use the narrow casting somewhere in the program to assign proper proerties of subobject (LO_LION) to Superobject (LO_ANIMAL). Than you will successfully move that reference back to Superobject (LO_ANIMAL) to different subobject (LO_LION2).
    Refer: http://help-abap.blogspot.com/2008/09/abap-objects-widening-cast-down-casting.html
    Regards,
    Naimesh Patel

Maybe you are looking for