Explicitly destroy an object in ABAP

Hi,
i like to destroy an Object explicitly. After the paricular statment the object must be destroyed.
if i set the reference of the object to null.when the object will be deleted? immediately or during automatic garbage collection.
Thanks and regards,
Prakash.

Hi,
you can do in OLE also.
INCLUDE OLE2INCL.
DATA EXCEL TYPE OLE2_OBJECT.
CREATE OBJECT EXCEL 'Excel.Application'.
FREE   OBJECT EXCEL.
in OO ABAP
FREE OBJECT <b>OBJ</b> .
here OBJ is object reference to some class.
Regards
Vijya

Similar Messages

  • How do i destroy an object explicitly ?

    I need to explicitly destroy an object ... how do i do it ?
    1) set object to null
    2) call finalize on the object
    3) ur suggestion pls...

    I need to explicitly destroy an objectNo, you don't.
    ... how do i
    do it ?You can't.
    1) set object to nullObjects are never null. Only references can be null. If you set the only reachable reference to the object to null (or to any value other than pointing at that object), then the object becomes eligible to be garbage collected. When--or if--it actually gets cleaned up is beyond your control, but it's guaranteed to happen if the memory is needed.
    2) call finalize on the objectNo. Never call finalize. The GC calls it for you. (And you should rarely if ever override finalize.)
    3) ur suggestion pls...Read up on Java's garbage collection so that you understand why you don't need to do this.
    This article is about something else, but it starts off with a decent intro to GC. You can also google for java garbage collection tutorial or something.
    http://java.sun.com/developer/technicalArticles/ALT/RefObj/

  • Object oriented abap

    hello abapers,
    am new to object oriented abap.cud u pls help me out in explaining me object oriented abap with examples.cud u also pls send me some links related to OO ABAP..
    explanation wid suitable examples will b rewarded higher pints.
    regards,
    praveen

    Hi,
    please find the below material with examples,
    reward points if helpful.
    Public attributes
    Public attributes are defined in the PUBLIC section and can be viewed and changed from outside the class. There is direct access to public attributes. As a general rule, as few public attributes should be defined as possible.
    PUBLIC SECTION.
      DATA: Counter type i.
    Private attributes
    Private attributes are defined in the PRIVATE section. The can only be viewes and changed from within the class. There is no direct access from outside the class.
    PRIVATE SECTION.
        DATA: name(25) TYPE c,
              planetype LIKE saplane-planetyp,
    Instance attributes
    There exist one instance attribute for each instance of the class, thus they exist seperately for each object. Instance attributes are declared with the DATA keyword.
    Static attributes
    Static attributes exist only once for each class. The data are the same for all instances of the class, and can be used e.g. for instance counters. Static attributes are defined with the keyword CLASS-DATA.
    PRIVATE SECTION.
      CLASS-DATA: counter type i,  
    Public methods
    Can called from outside the class
    PUBLIC SECTION.
      METHODS:  set_attributes IMPORTING p_name(25) TYPE c,
                                                                p_planetype LIKE saplane-planetyp,
    Private methods
    Can only be called from inside the class. They are placed in the PRIVATE section of the class.
    Constructor method
    Implicitly, each class has an instance constructor method with the reserved name constructor and a static constructor method with the reserved name class_constructor.
    The instance constructor is executed each time you create an object (instance) with the CREATE OBJECT statement, while the class constructor is executed exactly once before you first access a class.
    The constructors are always present. However, to implement a constructor you must declare it explicitly with the METHODS or CLASS-METHODS statements. An instance constructor can have IMPORTING parameters and exceptions. You must pass all non-optional parameters when creating an object. Static constructors have no parameters.
    Static constructor
    The static constructor is always called CLASS_CONSTRUCTER, and is called autmatically before the clas is first accessed, that is before any of the following actions are executed:
    •     Creating an instance using CREATE_OBJECT
    •     Adressing a static attribute using 
    •     Calling a ststic attribute using CALL METHOD
    •     Registering a static event handler
    •     Registering an evetm handler method for a static event
    The static constructor cannot be called explicitly.
    Protected components
    When we are talking subclassing and enheritance there is one more component than Public and Private, the Protected component. Protected components can be used by the superclass and all of the subclasses. Note that Subclasses cannot access Private components.
    Polymorphism
    Polymorphism: When the same method is implemented differently in different classes. This can be done using enheritance, by redefining a method from the superclass in subclasses and implement it differently.
    Template for making a class
    Delete the parts that should not be used
    Definition part
    CLASS xxx DEFINITION.
    Public section
      PUBLIC SECTION.
        TYPES:
        DATA:
      Static data
        CLASS-DATA:
      Methods
        METHODS:
        Using the constructor to initialize parameters
           constructor    IMPORTING xxx type yyy,
        Method with parameters
          mm1 IMPORTING iii   TYPE ttt.
        Method without parameters
          mm2.
      Static methods
        CLASS-METHODS: 
    Protected section. Also accessable by subclasses
      PROTECTED SECTION.
    Private section. Not accessable by subclasses
      PRIVATE SECTION.
    ENDCLASS.
    Implementation part
    CLASS lcl_airplane IMPLEMENTATION.
      METHOD constructor.
      ENDMETHOD.
      METHOD mm1.
      ENDMETHOD.
      METHOD mm2.
      ENDMETHOD.
    ENDCLASS.
    Template for calling a class
    Create reference to class lcl_airplane
    DATA: airplane1 TYPE REF TO lcl_airplane.
    START-OF-SELECTION.
    Create instance using parameters in the cosntructor method
      CREATE OBJECT airplane1 exporting im_name = 'Hansemand'
                                        im_planetype = 'Boing 747'.
    Calling a method with parameters
      CALL METHOD: airplane1->display_n_o_airplanes,
                   airplane1->display_attributes.
    Subclass
    CLASS xxx DEFINITION INHERITING FROM yyy.
    Using af class as a parameter for a method
    The class LCL_AIRPLANE is used as a parameter for method add_a_new_airplane:
    METHODS:
      add_a_new_airplane importing im_airplane TYPE REF to lcl_airplane.
    Interfaces
    In ABAP interfaces are implemented in addition to, and independently of classes. An interface only has a declaration part, and do not have visibillity sections. Components (Attributes, methods, constants, types) can be defined the same way as in classes.
    •     Interfaces are listed in the definition part lof the class, and must always be in the PUBLIC SECTION.
    •     Operations defined in the interface atre impemented as methods of the class. All methods of the interface must be present in the
    •     implementation part of the class.
    •     Attributes, events, constants and types defined in the interface are automatically available to the class carying out the implementation.
    •     Interface components are adresse in the class by ]
    Define, implement and use simple class
    ***INCLUDE ZBC404_HF_LCL_AIRPLANE .
    Definition part
    CLASS lcl_airplane DEFINITION.
    Public section
      PUBLIC SECTION.
        TYPES: t_name(25) TYPE c.
        METHODS:
          constructor,
          set_attributes IMPORTING p_name       TYPE t_name
                                   p_planetype  TYPE saplane-planetype,
          display_attributes,
          display_n_o_airplanes.
    Private section
      PRIVATE SECTION.
      Private attributes
        DATA: name(25) TYPE c,
              planetype TYPE saplane-planetype.
      Private static attribute
        CLASS-DATA n_o_airplanes TYPE i.
    ENDCLASS.
    Implementation part
    CLASS lcl_airplane IMPLEMENTATION.
      METHOD constructor.
      Counts number of instances
        n_o_airplanes = n_o_airplanes + 1.
      ENDMETHOD.
      METHOD set_attributes.
        name      = p_name.
        planetype = p_planetype.
      ENDMETHOD.
      METHOD display_attributes.
        WRITE:/ 'Name:', name, 'Planetype:', planetype.
      ENDMETHOD.
      METHOD display_n_o_airplanes.
        WRITE: / 'No. planes:', n_o_airplanes.
      ENDMETHOD.
    ENDCLASS.
    REPORT zbc404_hf_maintain_airplanes .
    INCLUDE zbc404_hf_lcl_airplane.
    Create reference to class lcl_airplane
    DATA: airplane1 TYPE REF TO lcl_airplane,
          airplane2 TYPE REF TO lcl_airplane.
    START-OF-SELECTION.
    Create instance
      CREATE OBJECT airplane1.
      CALL METHOD: airplane1->display_n_o_airplanes.
      CREATE OBJECT airplane2.
    Setting attributes using a method with parameters
      CALL METHOD airplane1->set_attributes EXPORTING p_name      = 'Kurt'
                                                      p_planetype = 'MD80'.
    END-OF-SELECTION.
    Using methods
      CALL METHOD: airplane1->display_n_o_airplanes,
                   airplane1->display_attributes. 
    The resulting report:
    Maintain airplanes                                                                               
    No. planes:          1                                
    No. planes:          2                                
    Name: Kurt                      Planetype: MD80       
    Use constructor to create an object with parameters
    CLASS lcl_airplane DEFINITION.
      PUBLIC SECTION.
        TYPES: t_name(25) TYPE c.
        METHODS:
          constructor    importing p2_name      type t_name
                                   p2_planetype  TYPE saplane-planetype,
    ..... more code .......
    CLASS lcl_airplane IMPLEMENTATION.
      METHOD constructor.
        name      = p2_name.
        planetype = p2_planetype.
    ..... more code .......
    START-OF-SELECTION.
      CREATE OBJECT airplane1 exporting p2_name = 'Hansemand'
                                        p2_planetype = 'Boing 747'.
    Subclassing
    This example uses a superclass LCL_AIRPLANE and subclasses it into LCL_PASSENGER_AIRPLANE and LCL_CARGO_PLANE.
    LCL_AIRPLANE has a method display_n_o_airplanes that displays the number of object instances.
    LCL_PASSENGER_AIRPLANE has the private instance attribute n_o_seats, and redefines the superclass method display_attributes, so it also displays n_o_seats.
    LCL_CARGO_PLANE has the private instance attribute cargomax, and redefines the superclass method display_attributes, so it also displays cargomax.
    All instance attributes are provided by the cunstructor method.
    Superclass LCL_AIRPLANE
    ***INCLUDE ZBC404_HF_LCL_AIRPLANE .
    Definition part
    CLASS lcl_airplane DEFINITION.
    Public section
      PUBLIC SECTION.
        TYPES: t_name(25) TYPE c.
        METHODS:
          constructor    IMPORTING im_name      TYPE t_name
                                   im_planetype  TYPE saplane-planetype,
          display_attributes.
      Static methods
        CLASS-METHODS:
          display_n_o_airplanes.
    Protected section
      PROTECTED SECTION.
      Private attributes
        DATA: name(25) TYPE c,
              planetype TYPE saplane-planetype.
      Private static attribute
        CLASS-DATA n_o_airplanes TYPE i.
    ENDCLASS.
    Implementation part
    CLASS lcl_airplane IMPLEMENTATION.
      METHOD constructor.
        name      = im_name.
        planetype = im_planetype.
      Counts number of instances
        n_o_airplanes = n_o_airplanes + 1.
      ENDMETHOD.
      METHOD display_attributes.
        WRITE:/ 'Name:', name, 'Planetype:', planetype.
      ENDMETHOD.
      METHOD display_n_o_airplanes.
        WRITE: / 'No. planes:', n_o_airplanes.
      ENDMETHOD.
    ENDCLASS.
    Sub class LCL_PASSENGER_AIRPLANE
    ***INCLUDE ZBC404_HF_LCL_PASSENGER_PLANE .
    This is a subclass of class lcl_airplane
    CLASS lcl_passenger_airplane DEFINITION INHERITING FROM lcl_airplane.
      PUBLIC SECTION.
      The constructor contains the parameters from the superclass
      plus the parameters from the subclass
        METHODS:
          constructor IMPORTING im_name      TYPE t_name
                                im_planetype TYPE saplane-planetype
                                im_n_o_seats TYPE sflight-seatsmax,
        Redefinition of superclass method display_attributes
          display_attributes REDEFINITION.
      PRIVATE SECTION.
        DATA: n_o_seats TYPE sflight-seatsmax.
    ENDCLASS.
    CLASS lcl_passenger_airplane IMPLEMENTATION.
      METHOD constructor.
      The constructor method of the superclass MUST be called withing the
      construtor
        CALL METHOD super->constructor
                              EXPORTING im_name      = im_name
                                        im_planetype = im_planetype.
        n_o_seats = im_n_o_seats.
      ENDMETHOD.
      The redefined  display_attributes method
      METHOD display_attributes.
        CALL METHOD super->display_attributes.
        WRITE: / 'No. seats:', n_o_seats.
      ENDMETHOD.
    ENDCLASS.
    Sub class LCL_CARGO_PLANE
    ***INCLUDE ZBC404_HF_LCL_CARGO_PLANE .
    This is a subclass of class lcl_airplane
    CLASS lcl_cargo_plane DEFINITION INHERITING FROM lcl_airplane.
      PUBLIC SECTION.
        METHODS:
        The constructor contains the parameters from the superclass
        plus the parameters from the subclass
          constructor IMPORTING im_name      TYPE t_name
                                im_planetype TYPE saplane-planetype
                                im_cargomax  type scplane-cargomax,
        Redefinition of superclass method display_attributes
          display_attributes REDEFINITION.
      PRIVATE SECTION.
        DATA:cargomax TYPE scplane-cargomax.
    ENDCLASS.
    CLASS lcl_cargo_plane IMPLEMENTATION.
      METHOD constructor.
      The constructor method of the superclass MUST be called withing the
      constructor
        CALL METHOD super->constructor
                              EXPORTING im_name      = im_name
                                        im_planetype = im_planetype.
        cargomax = im_cargomax.
      ENDMETHOD.
      METHOD display_attributes.
      The redefined  display_attributes method
        CALL METHOD super->display_attributes.
        WRITE: / 'Cargo max:', cargomax.
      ENDMETHOD.
    ENDCLASS.
    The Main program that uses the classes
    REPORT zbc404_hf_main .
    Super class
    INCLUDE zbc404_hf_lcl_airplane.
    Sub classes
    INCLUDE zbc404_hf_lcl_passenger_plane.
    INCLUDE zbc404_hf_lcl_cargo_plane.
    DATA:
    Type ref to sub classes. Note: It is not necesssary to make typeref to the superclass
      o_passenger_airplane TYPE REF TO lcl_passenger_airplane,
      o_cargo_plane        TYPE REF TO lcl_cargo_plane.
    START-OF-SELECTION.
    Display initial number of instances = 0
      CALL METHOD  lcl_airplane=>display_n_o_airplanes.
    Create objects
      CREATE OBJECT o_passenger_airplane
        EXPORTING
          im_name      = 'LH505'
          im_planetype = 'Boing 747'
          im_n_o_seats = 350.
      CREATE OBJECT o_cargo_plane
        EXPORTING
          im_name      = 'AR13'
          im_planetype = 'DC 3'
          im_cargomax = 35.
    Display attributes
      CALL METHOD o_passenger_airplane->display_attributes.
      CALL METHOD o_cargo_plane->display_attributes.
    Call static method display_n_o_airplanes
    Note: The syntax for calling a superclass method, differs from the syntax when calling a subclass method.
    When calling a superclass => must be used instead of ->
      CALL METHOD  lcl_airplane=>display_n_o_airplanes.
    Result:
    No. planes: 0
    Name: LH505 Planetype: Boing 747
    No. seats: 350
    Name: AR13 Planetype: DC 3
    Cargo max: 35,0000
    No. planes: 2
    Polymorphism
    Polymorphism: When the same method is implemented differently in different classes. This can be done using enheritance, by redefining a method from the superclass in subclasses and implement it differently.
    Classes:
    •     lcl_airplane Superclass
    •     lcl_cargo_airplane Subclass
    •     lcl_passenger_airplane Subclass
    The method estimate_fuel_consumption is implemented differently in the 3 classes, as it depends on the airplane type.
    Object from different classes are stored in an internal table (plane_list) consisting of references to the superclass, and the processed
    identically for all the classes.
    What coding for the estimate_fuel_consumption method taht is actually executed, depends on the dynamic type of the plane reference variable,
    that is, depends on which object plane points to.
    DATA: cargo_plane            TYPE REF to lcl_cargo_airplane,
              passenger_plane    TYPE REF to lcl_passenger_airplane,
              plane_list                  TYPE TABLE OF REF TO lcl_airplane.
    Creating the list of references
    CREATE OBJECT cargo_plane.
    APPEND cargo_plane to plane_list.
    CREATE OBJECT passenger_plane
    APPEND passenger_plane to plane list.
    Generic method for calucalting required fuel
    METHOD calculate required_fuel.
      DATA: plane TYPE REF TO lcl_airplane.
      LOOP AT plane_list INTO plane.
        re_fuel = re_fuel + plane->estimate_fuel_consumption( distance ).
      ENDLOOP.
    ENDMETHOD.
    Working example:
    This example assumes that the classes lcl_airplane,  lcl_passnger_airplane and lcl_cargo plane (Se Subcallsing)  exists.
    Create objects of type lcl_cargo_plane and lcl_passenger_airplane, adds them to a list in lcl_carrier, and displays the list. 
    *& Include  ZBC404_HF_LCL_CARRIER                                      *
          CLASS lcl_carrier DEFINITION                                   *
    CLASS lcl_carrier DEFINITION.
      PUBLIC SECTION.
        TYPES: BEGIN OF flight_list_type,
                  connid   TYPE sflight-connid,
                  fldate   TYPE sflight-fldate,
                  airplane TYPE REF TO lcl_airplane,
                  seatsocc TYPE sflight-seatsocc,
                  cargo(5) TYPE p DECIMALS 3,
               END OF flight_list_type.
        METHODS: constructor IMPORTING im_name TYPE string,
                 get_name RETURNING value(ex_name) TYPE string,
                 add_a_new_airplane IMPORTING
                                       im_airplane TYPE REF TO lcl_airplane,
        create_a_new_flight importing
                              im_connid   type sflight-connid
                              im_fldate   type sflight-fldate
                              im_airplane type ref to lcl_airplane
                              im_seatsocc type sflight-seatsocc
                                        optional
                            im_cargo    type p optional,
         display_airplanes.
      PRIVATE SECTION.
        DATA: name              TYPE string,
              list_of_airplanes TYPE TABLE OF REF TO lcl_airplane,
              list_of_flights   TYPE TABLE OF flight_list_type.
    ENDCLASS.
          CLASS lcl_carrier IMPLEMENTATION
    CLASS lcl_carrier IMPLEMENTATION.
      METHOD constructor.
        name = im_name.
      ENDMETHOD.
      METHOD get_name.
        ex_name = name.
      ENDMETHOD.
      METHOD create_a_new_flight.
        DATA: wa_list_of_flights TYPE flight_list_type.
        wa_list_of_flights-connid   = im_connid.
        wa_list_of_flights-fldate   = im_fldate.
        wa_list_of_flights-airplane = im_airplane.
        IF im_seatsocc IS INITIAL.
          wa_list_of_flights-cargo = im_cargo.
        ELSE.
          wa_list_of_flights-seatsocc = im_seatsocc.
        ENDIF.
        APPEND wa_list_of_flights TO list_of_flights.
      ENDMETHOD.
      METHOD add_a_new_airplane.
        APPEND im_airplane TO list_of_airplanes.
      ENDMETHOD.
      METHOD display_airplanes.
        DATA: l_airplane TYPE REF TO lcl_airplane.
        LOOP AT list_of_airplanes INTO l_airplane.
          CALL METHOD l_airplane->display_attributes.
        ENDLOOP.
      ENDMETHOD.
    ENDCLASS.
    REPORT zbc404_hf_main .
    This reprort uses class LCL_AIRPLNAE and subclasses
    LCL_CARGO_PLANE and LCL_PASSENGER_AIRPLANE and class LCL_CARRIER
    Super class for airplanes
    INCLUDE zbc404_hf_lcl_airplane.
    Sub classes for airplanes
    INCLUDE zbc404_hf_lcl_passenger_plane.
    INCLUDE zbc404_hf_lcl_cargo_plane.
    Carrier class
    INCLUDE zbc404_hf_lcl_carrier.
    DATA:
    Type ref to classes
      o_passenger_airplane  TYPE REF TO lcl_passenger_airplane,
      o_passenger_airplane2 TYPE REF TO lcl_passenger_airplane,
      o_cargo_plane         TYPE REF TO lcl_cargo_plane,
      o_cargo_plane2        TYPE REF TO lcl_cargo_plane,
      o_carrier             TYPE REF TO lcl_carrier.
    START-OF-SELECTION.
    Create objects
      CREATE OBJECT o_passenger_airplane
        EXPORTING
          im_name      = 'LH505'
          im_planetype = 'Boing 747'
          im_n_o_seats = 350.
      CREATE OBJECT o_passenger_airplane2
        EXPORTING
          im_name      = 'SK333'
          im_planetype = 'MD80'
          im_n_o_seats = 110.
      CREATE OBJECT o_cargo_plane
        EXPORTING
          im_name      = 'AR13'
          im_planetype = 'DC 3'
          im_cargomax = 35.
      CREATE OBJECT o_cargo_plane2
        EXPORTING
          im_name      = 'AFL124'
          im_planetype = 'Iljutsin 2'
          im_cargomax = 35000.
      CREATE OBJECT o_carrier
        EXPORTING im_name = 'Spritisch Airways'.
    Add passenger and cargo planes to the list of airplanes
      CALL METHOD o_carrier->add_a_new_airplane
         EXPORTING im_airplane = o_passenger_airplane.
      CALL METHOD o_carrier->add_a_new_airplane
         EXPORTING im_airplane = o_passenger_airplane2.
      CALL METHOD o_carrier->add_a_new_airplane
         EXPORTING im_airplane = o_cargo_plane.
      CALL METHOD o_carrier->add_a_new_airplane
         EXPORTING im_airplane = o_cargo_plane2.
    Display list of airplanes
      call method o_carrier->display_airplanes.
    Result:
    Name: LH505                     Planetype: Boing 747        
    No. seats:       350                                        
    Name: SK333                     Planetype: MD80             
    No. seats:       110                                        
    Name: AR13                      Planetype: DC 3             
    Cargo max:             35,0000                              
    Name: AFL124                    Planetype: Iljutsin 2       
    Cargo max:         35.000,0000                              
    Events
    Below is a simple example of how to implement an event.
    REPORT zbc404_hf_events_5.
          CLASS lcl_dog DEFINITION
    CLASS lcl_dog DEFINITION.
      PUBLIC SECTION.
      Declare events
        EVENTS:
          dog_is_hungry
            EXPORTING value(ex_time_since_last_meal) TYPE i.
        METHODS:
          constructor
              IMPORTING im_name TYPE string,
          set_time_since_last_meal
              IMPORTING im_time TYPE i,
          on_dog_is_hungry FOR EVENT dog_is_hungry OF lcl_dog
              IMPORTING ex_time_since_last_meal.
    ENDCLASS.
          CLASS lcl_dog IMPLEMENTATION
    CLASS lcl_dog IMPLEMENTATION.
      METHOD constructor.
        WRITE: / 'I am a dog and my name is', im_name.
      ENDMETHOD.
      METHOD set_time_since_last_meal.
        IF im_time < 4.
          SKIP 1.
          WRITE: / 'You fool, I am not hungry yet'.
        ELSE.
       Subsrcribe for event:
       set handler <Event handler method>
       FOR <ref_sender>!FOR ALL INSTANCES [ACTIVATION <var>]
          SET HANDLER on_dog_is_hungry FOR ALL INSTANCES ACTIVATION 'X'.
       Raise event
          RAISE EVENT dog_is_hungry
            EXPORTING ex_time_since_last_meal = im_time.
        ENDIF.
      ENDMETHOD.
      METHOD on_dog_is_hungry.
      Event method, called when the event dog_is_hungry is raised
        SKIP 1.
        WRITE: /  'You son of a *****. I have not eaten for more than',
                  ex_time_since_last_meal, ' hours'.
        WRITE: / 'Give me something to eat NOW!'.
      ENDMETHOD.
    ENDCLASS.
          R E P O R T
    DATA: o_dog1 TYPE REF TO lcl_dog.
    START-OF-SELECTION.
      CREATE OBJECT o_dog1 EXPORTING im_name = 'Beefeater'.
      CALL METHOD o_dog1->set_time_since_last_meal
        EXPORTING im_time = 2.
    This method call will raise the event dog_is_hungy
    because time > 3
      CALL METHOD o_dog1->set_time_since_last_meal
        EXPORTING im_time = 5.
    Result:
    I am a dog and my name is Beefeater
    You fool, I am not hungry yet
    You son of a *****. I have not eaten for more than 5 hours
    Give me something to eat NOW!
    1. Simple class
    This example shows how to create a simple employee class. The constructor method is used to initialize number and name of thje employee when the object is created. A display_employee method can be called to show the attributes of the employee, and CLASS-METHOD dosplay_no_of_employees can be called to show the total number of employees (Number of instances of the employee class).
    REPORT zbc404_hf_events_1.
    L C L _ E M P L O Y E E
    *---- LCL Employee - Definition
    CLASS lcl_employee DEFINITION.
      PUBLIC SECTION.
    The public section is accesible from outside  
        TYPES:
          BEGIN OF t_employee,
            no  TYPE i,
            name TYPE string,
         END OF t_employee.
        METHODS:
          constructor
            IMPORTING im_employee_no TYPE i
                      im_employee_name TYPE string,
          display_employee.
      Class methods are global for all instances      
        CLASS-METHODS: display_no_of_employees.
      PROTECTED SECTION.
    The protecetd section is accesible from the class and its subclasses 
      Class data are global for all instances      
        CLASS-DATA: g_no_of_employees TYPE i.
      PRIVATE SECTION.
    The private section is only accesible from within the classs 
        DATA: g_employee TYPE t_employee.
    ENDCLASS.
    *--- LCL Employee - Implementation
    CLASS lcl_employee IMPLEMENTATION.
      METHOD constructor.
        g_employee-no = im_employee_no.
        g_employee-name = im_employee_name.
        g_no_of_employees = g_no_of_employees + 1.
      ENDMETHOD.
      METHOD display_employee.
        WRITE:/ 'Employee', g_employee-no, g_employee-name.
      ENDMETHOD.
      METHOD display_no_of_employees.
        WRITE: / 'Number of employees is:', g_no_of_employees.
      ENDMETHOD.
    ENDCLASS.
    R E P O R T
    DATA: g_employee1 TYPE REF TO lcl_employee,
          g_employee2 TYPE REF TO lcl_employee.
    START-OF-SELECTION.
      CREATE OBJECT g_employee1
        EXPORTING im_employee_no = 1
                  im_employee_name = 'John Jones'.
      CREATE OBJECT g_employee2
        EXPORTING im_employee_no = 2
                  im_employee_name = 'Sally Summer'.
      CALL METHOD g_employee1->display_employee.
      CALL METHOD g_employee2->display_employee.
      CALL METHOD g_employee2->display_no_of_employees.
    2. Inheritance and polymorphism
    This example uses a superclass lcl_company_employees and two subclasses lcl_bluecollar_employee and lcl_whitecollar_employee to add employees to a list and then display a list of employees and there wages. The wages are calcukated in the method add_employee, but as the wages are calculated differently for blue collar employees and white collar emplyees, the superclass method add_employee is redeifined in the subclasses.
    Principles:
    Create super class LCL_CompanyEmployees.
    The class has the methods:
    •     Constructor
    •     Add_Employee - Adds a new employee to the list of employees
    •     Display_Employee_List - Displays all employees and there wage
    •     Display_no_of_employees - Displays total number of employees
    Note the use of CLASS-DATA to keep the list of employees and number of employees the same from instance to instance.
    Create subclasses lcl_bluecollar_employee and lcl_whitecollar_employee. The calsses are identical, except for the redifinition of the add_employee method, where the caclculation of wage is different.
    Methodes:
    •     Constructor. The constructor is used to initialize the attributes of the employee. Note that the constructor in the supclasss has to be called from within the constructor of the subclass.
    •     Add_Employee. This is a redinition of the same method in the superclass. In the redefined class the wage is calcuated, and the superclass method is called to add the employees to the emploee list.:
    The program
    REPORT zbc404_hf_events_2 .
    Super class LCL_CompanyEmployees
    CLASS lcl_company_employees DEFINITION.
      PUBLIC SECTION.
        TYPES:
          BEGIN OF t_employee,
            no  TYPE i,
            name TYPE string,
            wage TYPE i,
         END OF t_employee.
        METHODS:
          constructor,
          add_employee
            IMPORTING im_no   TYPE i
                      im_name TYPE string
                      im_wage TYPE i,
          display_employee_list,
          display_no_of_employees.
      PRIVATE SECTION.
        CLASS-DATA: i_employee_list TYPE TABLE OF t_employee,
                    no_of_employees TYPE i.
    ENDCLASS.
    *-- CLASS LCL_CompanyEmployees IMPLEMENTATION
    CLASS lcl_company_employees IMPLEMENTATION.
      METHOD constructor.
        no_of_employees = no_of_employees + 1.
      ENDMETHOD.
      METHOD add_employee.
      Adds a new employee to the list of employees
        DATA: l_employee TYPE t_employee.
        l_employee-no = im_no.
        l_employee-name = im_name.
        l_employee-wage = im_wage.
        APPEND l_employee TO i_employee_list.
      ENDMETHOD.
      METHOD display_employee_list.
      Displays all employees and there wage
        DATA: l_employee TYPE t_employee.
        WRITE: / 'List of Employees'.
        LOOP AT i_employee_list INTO l_employee.
          WRITE: / l_employee-no, l_employee-name, l_employee-wage.
        ENDLOOP.
      ENDMETHOD.
      METHOD display_no_of_employees.
      Displays total number of employees
        SKIP 3.
        WRITE: / 'Total number of employees:', no_of_employees.
      ENDMETHOD.
    ENDCLASS.
    Sub class LCL_BlueCollar_Employee
    CLASS lcl_bluecollar_employee DEFINITION
              INHERITING FROM lcl_company_employees.
      PUBLIC SECTION.
        METHODS:
            constructor
              IMPORTING im_no             TYPE i
                        im_name           TYPE string
                        im_hours          TYPE i
                        im_hourly_payment TYPE i,
             add_employee REDEFINITION.
      PRIVATE SECTION.
        DATA:no             TYPE i,
             name           TYPE string,
             hours          TYPE i,
             hourly_payment TYPE i.
    ENDCLASS.
    *---- CLASS LCL_BlueCollar_Employee IMPLEMENTATION
    CLASS lcl_bluecollar_employee IMPLEMENTATION.
      METHOD constructor.
      The superclass constructor method must be called from the subclass
      constructor method
        CALL METHOD super->constructor.
        no = im_no.
        name = im_name.
        hours = im_hours.
        hourly_payment = im_hourly_payment.
      ENDMETHOD.
      METHOD add_employee.
      Calculate wage an call the superclass method add_employee to add
      the employee to the employee list
        DATA: l_wage TYPE i.
        l_wage = hours * hourly_payment.
        CALL METHOD super->add_employee
          EXPORTING im_no = no
                    im_name = name
                    im_wage = l_wage.
      ENDMETHOD.
    ENDCLASS.
    Sub class LCL_WhiteCollar_Employee
    CLASS lcl_whitecollar_employee DEFINITION
        INHERITING FROM lcl_company_employees.
      PUBLIC SECTION.
        METHODS:
            constructor
              IMPORTING im_no                 TYPE i
                        im_name               TYPE string
                        im_monthly_salary     TYPE i
                        im_monthly_deductions TYPE i,
             add_employee REDEFINITION.
      PRIVATE SECTION.
        DATA:
          no                    TYPE i,
          name                  TYPE string,
          monthly_salary        TYPE i,
          monthly_deductions    TYPE i.
    ENDCLASS.
    *---- CLASS LCL_WhiteCollar_Employee IMPLEMENTATION
    CLASS lcl_whitecollar_employee IMPLEMENTATION.
      METHOD constructor.
      The superclass constructor method must be called from the subclass
      constructor method
        CALL METHOD super->constructor.
        no = im_no.
        name = im_name.
        monthly_salary = im_monthly_salary.
        monthly_deductions = im_monthly_deductions.
      ENDMETHOD.
      METHOD add_employee.
      Calculate wage an call the superclass method add_employee to add
      the employee to the employee list
        DATA: l_wage TYPE i.
        l_wage = monthly_salary - monthly_deductions.
        CALL METHOD super->add_employee
          EXPORTING im_no = no
                    im_name = name
                    im_wage = l_wage.
      ENDMETHOD.
    ENDCLASS.
    R E P O R T
    DATA:
    Object references
      o_bluecollar_employee1  TYPE REF TO lcl_bluecollar_employee,
      o_whitecollar_employee1 TYPE REF TO lcl_whitecollar_employee.
    START-OF-SELECTION.
    Create bluecollar employee obeject
      CREATE OBJECT o_bluecollar_employee1
          EXPORTING im_no  = 1
                    im_name  = 'Gylle Karen'
                    im_hours = 38
                    im_hourly_payment = 75.
    Add bluecollar employee to employee list
      CALL METHOD o_bluecollar_employee1->add_employee
          EXPORTING im_no  = 1
                    im_name  = 'Gylle Karen'
                    im_wage = 0.
    Create whitecollar employee obeject
      CREATE OBJECT o_whitecollar_employee1
          EXPORTING im_no  = 2
                    im_name  = 'John Dickens'
                    im_monthly_salary = 10000
                    im_monthly_deductions = 2500.
    Add bluecollar employee to employee list
      CALL METHOD o_whitecollar_employee1->add_employee
          EXPORTING im_no  = 1
                    im_name  = 'Karen Johnson'
                    im_wage = 0.
    Display employee list and number of employees. Note that the result
    will be the same when called from o_whitecollar_employee1 or
    o_bluecolarcollar_employee1, because the methods are defined
    as static (CLASS-METHODS)
      CALL METHOD o_whitecollar_employee1->display_employee_list.
      CALL METHOD o_whitecollar_employee1->display_no_of_employees.
    The resulting report
    List of Employees
    1 Karen Johnson 2.850
    2 John Dickens 7.500
    Total number of employees: 2
    3. Interfaces
    This example is similiar to th eprevious example, however an interface is implemented with the method add_employee. Note that the interface is only implemented in the superclass ( The INTERFACE stament), but also used in the subclasses.
    The interface in the example only contains a method, but an iterface can also contain attrbutes, constants, types and alias names.
    The output from example 3 is similiar to the output in example 2.
    All changes in the program compared to example 2 are marked with red.
    REPORT zbc404_hf_events_3 .
          INTERFACE lif_employee
    INTERFACE lif_employee.
      METHODS:
        add_employee
           IMPORTING im_no   TYPE i
                      im_name TYPE string
                      im_wage TYPE i.
    ENDINTERFACE.
    Super class LCL_CompanyEmployees
    CLASS lcl_company_employees DEFINITION.
      PUBLIC SECTION.
        INTERFACES lif_employee.
        TYPES:
          BEGIN OF t_employee,
            no  TYPE i,
            name TYPE string,
            wage TYPE i,
         END OF t_employee.
        METHODS:
          constructor,
         add_employee      "Removed
            IMPORTING im_no   TYPE i
                      im_name TYPE string
                      im_wage TYPE i,
          display_employee_list,
          display_no_of_employees.
      PRIVATE SECTION.
        CLASS-DATA: i_employee_list TYPE TABLE OF t_employee,
                    no_of_employees TYPE i.
    ENDCLASS.
    *-- CLASS LCL_CompanyEmployees IMPLEMENTATION
    CLASS lcl_company_employees IMPLEMENTATION.
      METHOD constructor.
        no_of_employees = no_of_employees + 1.
      ENDMETHOD.
      METHOD lif_employee~add_employee.
      Adds a new employee to the list of employees
        DATA: l_employee TYPE t_employee.
        l_employee-no = im_no.
        l_employee-name = im_name.
        l_employee-wage = im_wage.
        APPEND l_employee TO i_employee_list.
      ENDMETHOD.
      METHOD display_employee_list.
      Displays all employees and there wage
        DATA: l_employee TYPE t_employee.
        WRITE: / 'List of Employees'.
        LOOP AT i_employee_list INTO l_employee.
          WRITE: / l_employee-no, l_employee-name, l_employee-wage.
        ENDLOOP.
      ENDMETHOD.
      METHOD display_no_of_employees.
      Displays total number of employees
        SKIP 3.
        WRITE: / 'Total number of employees:', no_of_employees.
      ENDMETHOD.
    ENDCLASS.
    Sub class LCL_BlueCollar_Employee
    CLASS lcl_bluecollar_employee DEFINITION
              INHERITING FROM lcl_company_employees.
      PUBLIC SECTION.
        METHODS:
            constructor
              IMPORTING im_no             TYPE i
                        im_name           TYPE string
                        im_hours          TYPE i
                        im_hourly_payment TYPE i,
             lif_employee~add_employee REDEFINITION..
      PRIVATE SECTION.
        DATA:no             TYPE i,
             name           TYPE string,
             hours          TYPE i,
             hourly_payment TYPE i.
    ENDCLASS.
    *---- CLASS LCL_BlueCollar_Employee IMPLEMENTATION
    CLASS lcl_bluecollar_employee IMPLEMENTATION.
      METHOD constructor.
      The superclass constructor method must be called from the subclass
      constructor method
        CALL METHOD super->constructor.
        no = im_no.
        name = im_name.
        hours = im_hours.
        hourly_payment = im_hourly_payment.
      ENDMETHOD.
      METHOD lif_employee~add_employee.
      Calculate wage an call the superclass method add_employee to add
      the employee to the employee list
        DATA: l_wage TYPE i.
        l_wage = hours * hourly_payment.
        CALL METHOD super->lif_employee~add_employee
          EXPORTING im_no = no
                    im_name = name
                    im_wage = l_wage.
      ENDMETHOD.
    ENDCLASS.
    Sub class LCL_WhiteCollar_Employee
    CLASS lcl_whitecollar_employee DEFINITION
        INHERITING FROM lcl_company_employees.
      PUBLIC SECTION.
        METHODS:
            constructor
              IMPORTING im_no                 TYPE i
                        im_name               TYPE string
                        im_monthly_salary     TYPE i
                        im_monthly_deductions TYPE i,
             lif_employee~add_employee REDEFINITION.
      PRIVATE SECTION.
        DATA:
          no                    TYPE i,
          name                  TYPE string,
          monthly_salary        TYPE i,
          monthly_deductions    TYPE i.
    ENDCLASS.
    *---- CLASS LCL_WhiteCollar_Employee IMPLEMENTATION
    CLASS lcl_whitecollar_employee IMPLEMENTATION.
      METHOD constructor.
      The superclass constructor method must be called from the subclass
      constructor method
        CALL METHOD super->constructor.
        no = im_no.
        name = im_name.
        monthly_salary = im_monthly_salary.
        monthly_deductions = im_monthly_deductions.
      ENDMETHOD.
      METHOD lif_employee~add_employee.
      Calculate wage an call the superclass method add_employee to add
      the employee to the employee list
        DATA: l_wage TYPE i.
        l_wage = monthly_salary - monthly_deductions.
        CALL METHOD super->lif_employee~add_employee
          EXPORTING im_no = no
                    im_name = name
                    im_wage = l_wage.
      ENDMETHOD.
    ENDCLASS.
    R E P O R T
    DATA:
    Object references
      o_bluecollar_employee1  TYPE REF TO lcl_bluecollar_employee,
      o_whitecollar_employee1 TYPE REF TO lcl_whitecollar_employee.
    START-OF-SELECTION.
    Create bluecollar employee obeject
      CREATE OBJECT o_bluecollar_employee1
          EXPORTING im_no  = 1
                    im_name  = 'Gylle Karen'
                    im_hours = 38
                    im_hourly_payment = 75.
    Add bluecollar employee to employee list
      CALL METHOD o_bluecollar_employee1->lif_employee~add_employee
          EXPORTING im_no  = 1
                    im_name  = 'Karen Johnson'
                    im_wage = 0.
    Create whitecollar employee obeject
      CREATE OBJECT o_whitecollar_employee1
          EXPORTING im_no  = 2
                    im_name  = 'John Dickens'
                    im_monthly_salary = 10000
                    im_monthly_deductions = 2500.
    Add bluecollar employee to employee list
      CALL METHOD o_whitecollar_employee1->lif_employee~add_employee
          EXPORTING im_no  = 1
                    im_name  = 'Gylle Karen'
                    im_wage = 0.
    Display employee list and number of employees. Note that the result
    will be the same when called from o_whitecollar_employee1 or
    o_bluecolarcollar_employee1, because the methods are defined
    as static (CLASS-METHODS)
      CALL METHOD o_whitecollar_employee1->display_employee_list.
      CALL METHOD o_whitecollar_employee1->display_no_of_employees.
    4. Events
    This is the same example as example 4. All changes are marked with red. There have been no canges to the subclasses, only to the superclass and the report, sp the code for th esubclasses is not shown.
    For a simple example refer to Events in Examples.
    REPORT zbc404_hf_events_4 .
          INTERFACE lif_employee
    INTERFACE lif_employee.
      METHODS:
        add_employee
           IMPORTING im_no   TYPE i
                      im_name TYPE string
                      im_wage TYPE i.
    ENDINTERFACE.
    Super class LCL_CompanyEmployees
    CLASS lcl_company_employees DEFINITION.
      PUBLIC SECTION.
        TYPES:
        BEGIN OF t_employee,
          no  TYPE i,
          name TYPE string,
          wage TYPE i,
       END OF t_employee.
      Declare event. Note that declaration could also be placed in the
      interface

  • Can you destroy an object?

    I have been looking around for an answer to this question a little while and have also posted on the Java .net forums too.
    But Im writing a little game where things appear on the screen, then because of user interaction, they dissapear. simple enough, I have my objects stored in a sequence, that I bind to a Group{} in my main Frame.
    The issue is that each of these objects get removed from the game via the *delete sequence* code segment and because they have their own timelines which does its own collision detection, the object never seems to get de-referenced and after a while I get out of memory exceptions and the game slows down to a halt.
    Firstly, I added functions to stop all timelines in each element before deleting it from the sequence, but it didnt appear to work as the game still slows down.
    So my question is, can you destroy an object? I just need it gone completly, and if there is a work-around, how can I be sure that it works? Currently the netbeans profiler isnt too easy to read, but that just maybe me (anyone else having issues reading the results of a JavaFX profiled app?)
    Thanks for any help that you can think of...
    Mark

    Are you 100% certain that there are no references to the object left after you remove it from the sequence? There is no way to explicitly destroy objects in Java; and this behavior extends to JavaFX. If you check the code and you're 100% sure that no references are left hanging out there, check Jira.
    [http://openjfx.java.sun.com/jira/|http://openjfx.java.sun.com/jira/]

  • Issue with internal table in object oriented ABAP.

    Hello Gurus,
    I am having trouble defining internal table in Object oriented ABAP. for following:
    DATA: BEGIN OF IT_TAB OCCURS 0.
            INCLUDE STRUCTURE ZCUSTOM.
    DATA    tot_sum   TYPE char40.
    DATA END OF IT_TAB.
    Can someone help ?
    Regards,
    Jainam.
    Edited by: Jainam Shah on Feb 5, 2010 8:33 PM
    Edited by: Jainam Shah on Feb 5, 2010 8:33 PM
    Moderator message - Please post in the correct forum. You can easily find out for yourself by looking at SAP help for internal tables using OOP - thread locked
    Edited by: Rob Burbank on Feb 5, 2010 2:49 PM

    No, you can not declare internal table with header line in OO context. You have to declare the work are/header line separately
    Example:
    TYPES: BEGIN OF ty_it_tab.
            INCLUDE STRUCTURE mara.
    TYPES:  tot_sum TYPE char40.
    TYPES: END OF ty_it_tab.
    DATA: it_tab TYPE STANDARD TABLE  OF ty_it_tab.
    DATA: wk_tab TYPE ty_it_tab.
    LOOP AT it_tab INTO wk_tab.
    ENDLOOP.
    Edited by: Dean Q on Feb 5, 2010 8:50 PM

  • DB02 = Missing Tables and Indexes = Unknown objects in ABAP Dictionary = DB views

    Hi SAP Gurus,
    on our SAP NetWeaver 7.x BW (based on AIX/Oracle) I find via transaction DB02 (path = Diagnostics => Missing Tables and Indexes) under "Unknown objects in ABAP Dictionary" under DB views a BW object /BI0/.....
    When I make a double click on the object, I am getting the popup window "Display not possible for this object":
    How can I identify the object and clarify with the BW application expert, if needed, how to resolve this object?
    I searched already via RSA1 for the object, but I wasn't able to find anything so far ...
    Thanks for your help and ideas.
    Best regards
    Carlos

    Hello Carlos
    The database view in question is a temporary database object created during a query execution.
    Please read this SAP note 449891 - Temporary database objects in BW 3.x to understand what that view is all about and impact if those views are removed.
    The SAP notes 449891 and 1139396 suggests to run the report SAP_DROP_TMPTABLES to drop these temporary objects. Whether the objects are still required or not is a question to be put across to the BW team. If the temporary objects are removed when they are used by a query, then the query will fail.
    Have a nice day
    RB

  • Unknown Objects in ABAP Dictionary

    Hello Everyone,
    I am getting a few objects that come up when running the Missing tables and Indexes command in the DBCOCKPIT. Under Unknown Objects in ABAP Dictionary I have the following objects appear:
    sap_tabstats
    V_MSSDWDLLS
    sap_tabstats_V_newest
    sap_tabstats_V_oldest
    I cannot find anything referencing how to correct this issue. Can anyone be of any assistance? I would greatly appreciate it. Thanks!

    Hi:
    for  sap_tabstats, sap_tabstats_V_oldest and sap_tabstats_V_newest you can find in note 1027512 :
    4.  IMPORTANT CHANGES IN DATA COLLECTION AND HISTORY                                                                               
    o  Applying SP12 on a SQL Server system will introduce a new method
            for collecting database and table size histories.  This new    
            methode relies on t-sql objects sap_tabstats,                  
            sap_tabstats_V_newest, and sap_tabstats_V_oldest.  These items 
            aren't in the data dictionary and should be ignored in any     
            discrepancy reports.  They are added to an exception table for 
            SP13.                                                          
    For V_MSSDWDLLS you should read note 1020865. The view can be ignored.
    Regards
      Clas

  • Unknown object in ABAP Dictionary

    Hello
    In st04 in  "Missing tables and indexes" are many  indexes have reported unknown "Unknown object in ABAP Dictionary".
    This is because indexex are created directly in DB. Is there a way to solve this problem?
    We have db : oracle 10.2.04 and sap SAP ECC 6.0 (Pkg. lvl. 254).

    Hi,
    In ST04, If you click Missing tables and indexes then next to "Unknown object in ABAP Dictionary"  there is a information button which says as below, kindly go through it which could help you.
    " Here objects which were found on the database but which are not defined
    in the ABAP Dictionary are displayed. These objects are displayed for
    information only, since they generally do not belong to the SAP System.
    These objects normally do not cause problems.
    The objects are generally created directly with database means. If the
    author is unknown, the purpose of the table can sometimes be determined
    using the display function. Any data can only be displayed with database
    means since the SAP tools for displaying data are based on the
    definition in the ABAP Dictionary.
    In some cases, such objects were already overlooked by SAP at delivery
    or occurred during upgrading. To check this, search in OSS using the
    keyword DB02 and the Release level for a corresponding Note.
    Customer tables, views and indexes should always be created with the
    ABAP Dictionary. This is the only way to ensure that the objects are
    recognized by the SAP System and that for example collisions can be
    avoided during an upgrade."
    Regards,
    Sharath

  • Unknown object in ABAP dictionary- TADIR^SRCDEP

    Hi,
    I found an entry in unknown object in ABAP dictionary while monitoring the system.
    This this the location I found this entry DBACOCKPIT-> Diagnostics-> missing table and indexes-> unknown object in ABAP dictionary.
    Could you please help to figure out how to solve this?
    Thanks in advance.
    Regards,
    Pradeep

    Hello,
    You can ignore the index TADIR^SRCDEP in transaction DB2.
    The installation creates the index TADIR^SRCDEP to avoid hanging
    situations on the database while executing reports. When the
    installation is finished you can delete this index.
    Drop the index TADIR^SRCDEP on the database:
        o  start SQL Server Management Studio
        o  connect to your SQL Server
        o  open a query window and execute the following command (replace
           SID by the uppercase system name, sid by the lowercase system
           name):
           drop index [TADIR^SRCDEP] on SID.sid.TADIR
    Best regards
      Clas

  • BOR Object and ABAP Class

    Hi,
        Can anybody say when to use BOR object and Abap class in the task with an example.
    Thanks,
    Mugundhan

    There is no any specific condition or rule that for this purpose you need to use BOR and Class , it depends on your requirement. not only the requirement but also the new techniques to make classes not just as simple way to create objects but when you use classes in the Workflows they are not simple classes but they are BUSINESS CLASSES which makes a lot of difference.
    Check the blogs of [Jocelyn Dart|https://www.sdn.sap.com/irj/scn/wiki?path=/pages/viewpage.action%3fpageid=55566]

  • Problem in creating new objects in ABAP workbench

    Hi ,
        I am getting error in a newly installed SAP system when try to create new objects in ABAP workbench. The error is like'No changes for the user allowed'.
    Can you tell me what the error is here? What can be done for this so that I can create new object.
    Thanks,
    Manas

    Hi,
    Run tcode SU01. (Provided if u hav authorization to run this Tcode)
    Enter SAP* as user and click on the Copy button.
    Enter the name for your new user in the dialog box and click Continue
    Enter a password for your new user.
    Goto Profile sheet and adjust the profiles to be SAP_ALL and SAP_NEW.
    Save the user and logon with it.
    Now you'll be able to do your changes.
    Reward Points if useful.
    Regards
    Rose
    Edited by: Rose Preethi on Mar 31, 2008 5:20 PM

  • How do I get a variable, or object from ABAP STACK.

    Hey Gurus,
    How do I get a variable, or object from ABAP STACK.
    Example: I start my FM. I can see in the ABAP STACK the variable I need. I can see the object; I could use to get my variable. I need to use it in my FM; however I need to reference it in the run time. How do I do that?
    Is there a method I can use for reading ABAP STACK?
    Do I just use command: get reference of u2026?
    Does anyone have an example code?
    Basis version 7
    Thanks in advance
    Martin

    Ah, you mean you want to access a variable from another program in the call stack, yes?  You can do this using field symbols, but please don't try to change a value while doing this, it could really screw things up. 
    this example, is using two programs, where the second is accessing variables of the first program.  Basically just notice that we are using the program name and the variable name when assigning the field symbol.
    report zrich_0006 .
    tables: mara.
    parameters: p_matnr type mara-matnr..
    data: matnr type mara-matnr.
    data: imarc type table of marc with header line.
    matnr = p_matnr.
    select * from marc into table imarc up to 10 rows
                   where matnr = p_matnr.
    perform in in program zrich_0007.
    report zrich_0007 .
    *       FORM in                                                       *
    form in.
      data: field(50).
      data: xmarc type marc.
      field-symbols: <matnr>.
      field-symbols: <imarc> type marc_upl_tt.
    * Assign an individual variable
      field = '(ZRICH_0006)matnr'.
      assign (field) to <matnr>.
    * Assign an internal table
      field = '(ZRICH_0006)IMARC[]'.
      assign (field) to <imarc>.
    * Write out your data
      write <matnr>.
      loop at <imarc> into xmarc.
        write: / xmarc-werks.
      endloop.
    endform.
    Regards,
    Rich Heilman

  • Explicitly tagging an object as unused

    Just read an article on gc tuning (http://www-106.ibm.com/developerworks/java/library/j-perf06304/?ca=dgr-lnxw07BlogFix)
    where memory leaks are caused by the so called "unintentionally retained objects".
    Currently, detecting memory leak in Java is done using memory profiler to monitor
    memory usage and select which objects are suspected to cause of memory leaks.
    Then, the programmer must decide/guess which of the suspected objects really cause
    memory leaks.
    Is it worthed to provide an API that explicitly tags an object as unused, so that memory
    profilers can find which objects are 100% the cause of memory leak? The notion of this
    API is similar to free in C, however, this API does not affect the decision made by gc
    regarding the reclaimability of an object, nor does it force gc to reclaimed the object.
    Object marked by this API means "I'm no longer needed by the user/program/algorithm.
    Hence, I should be able to be reclaimed by gc. If gc deemed I'm still referenced, this
    means the programmers make mistakes, and thus, they must fix the program".

    Just read an article on gc tuning where memory leaks are caused by the so called "unintentionally retained objects".Quote: From the final memory profile (Figure 3), with the major memory leak eliminated, we can see that there still is another "low grade" leak, but this leak is small enough that it can be ignored until the next release.
    If you are getting memory management advice from articles by people who are happy to release software that they know is leaky, then you're in trouble. (OK, so my background is flight control software where leaks would be a matter of life and death, but these people seem to have no sense of personal honour.)
    Currently, detecting memory leak in Java is done using memory profiler to monitor memory usage and select which objects are suspected to cause of memory leaks.Only do what is necessary to perform the required functionality. If having a reference to an object is functionally necessary, then that reference is required and will not be a leak. If you have a reference that is not required for the functionality, then you shouldn't have that reference any more. Cases where performance requires that a value be cached in case it is may be needed are already catered for with the WeakReference and SoftReference APIs.
    Is it worthed to provide an API that explicitly tags an object as unused, so that memory profilers can find which objects are 100% the cause of memory leak? No, for the same reason that there is no goto in Java. If you are writing software that is so convoluted you don't know what objects are referencing each other, adding an API that encourages you do that more will not help you.
    If gc deemed I'm still referenced, this means the programmers make mistakes, and thus, they must fix the program".If you are debugging badly written code, and do not have access to a static analysis tool which will tell you where your objects are being referenced, then you have the option of creating a reference queue and a phantom reference to your suposedly unreferenced object, clearing all references in your algorithm, forcing gc, and then asserting that the phantom reference was cleared.
    Pete

  • HOW TO CREATE AUTHORISATION OBJECT IN ABAP PLEASE HELP

    HOW TO CREATE AUTHORISATION OBJECT IN ABAP PLEASE HELP

    You can Use Transaction code: RSSM
    Check the following link
    http://www.sap-img.com/bc042.htm
    In SU20 you will have to create a CLass.
    After saving this double click this and you will taken to another screen where you can create Auth Object.
    You can create authorization fields in SU21 or use existing ones.
    You can also do above thru tcode SE80 Edit -> Other Object. In one the tabs you will see Auth. Objects .

  • Procedure to Call Workflow Object from ABAP program in Se38

    Hi All,
    I have one scenario like i have to call one Workflow object from ABAP program in SE38.The scenario is like below.....
    I have to select some records from database table.For example there are 100 records in the internal table.
    For all that records i have to invoke Workflow for getting approval from the authorized persons. Once Approval has come to program, It will post one document in SAP and process ends.
    Please suggest me how to move forward with this scenario.
    Regards
    Manas Ranjan Panda

    Hi,
    So you want to start a workflow from an ABAP, if an event exists for that particular workflow then the best way is to use fm SAP_WAPI_CREATE_EVENT,
    to start a workflow from an ABAP you can use fm SAP_WAPI_START_WORKFLOW.
    Kind regards, Rob Dielemans

Maybe you are looking for

  • Sending Process Message from PI Sheets without "Completing" it

    Hi, We have long running process orders in our scenarios (typically lasting 3 days). We are planning to use PI sheets to manage our goods issue/receipts/confirmations. During the brief evaluation of characteristics based PI sheets, we found that all

  • 4GB Flash Drive not loading on Mac (but on Windows and Ubuntu)

    Hello, I have a 4GB flash drive (probably from LG) that I bought about 3 years ago. It was working just fine all this time but now, all of a sudden, it's gone. Not working, showing up neither in Finder nor in Disk Utility. But it works just fine on W

  • Can i use the S4 4GLTE in india with local sim card

    Hi, Your advise would be highly appreciated , i have samsung s4 4G LTE . I am on contract and will be suspending my US service for 6 months Can i use the Phone with indian Local sim?  will it work ? Verizon customer support told me 4G LTE phones are

  • Problem with import atribute of page Directive

    Hi, I am try to implement the fnality of a shopping cart using jsp. I have a java class called Magazine under cart package. In my jsp page i wanted use the magazine class so i gave like this <%@ page import="cart.Magazine" %> and then in my scriptle(

  • How to have a generic typed column in a database table

    Hi, I have to create a table with one column which should be able to hold values of any data type. At runtime I will get values from different fields of different tables.  Any idea how to achieve thi as there is no generic data type available with AB