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>

Similar Messages

  • Doubt in abap object classes

    in abap objects v have a class  cl_gui_alv_grid ,but can v use this class only when we are using a container,i mean in normal abap alv report we cannot use this class???
        in normal alv report v use cl_salv_table ...
    can any1 pls provide me some information on this

    Hi,
    This is the sample report for checkbox oops alv report.
    REPORT  YMS_CHECKBOXOOPSALV NO STANDARD PAGE HEADING.
    TYPE-POOLS: slis.
    DATA: BEGIN OF i_data OCCURS 0,
    qmnum LIKE qmel-qmnum,
    qmart LIKE qmel-qmart,
    qmtxt LIKE qmel-qmtxt,
    ws_row TYPE i,
    ws_char(5) TYPE c,
    chk,
    END OF i_data.
    DATA: report_id LIKE sy-repid.
    DATA: ws_title TYPE lvc_title VALUE 'An ALV Report'.
    DATA: i_layout TYPE slis_layout_alv.
    DATA: i_fieldcat TYPE slis_t_fieldcat_alv.
    DATA: i_events TYPE slis_t_event.
    DATA: i_header TYPE slis_t_listheader.
    DATA: i_extab TYPE slis_t_extab.
    SELECT qmnum
    qmart
    qmtxt
    INTO TABLE i_data
    FROM qmel
    WHERE qmnum <= '00030000010'.
    LOOP AT i_data.
    i_data-ws_row = sy-tabix.
    i_data-ws_char = 'AAAAA'.
    MODIFY i_data.
    ENDLOOP.
    report_id = sy-repid.
    PERFORM f1000_layout_init CHANGING i_layout.
    PERFORM f2000_fieldcat_init CHANGING i_fieldcat.
    PERFORM f3000_build_header CHANGING i_header.
    PERFORM f4000_events_init CHANGING i_events.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    I_INTERFACE_CHECK = ' '
    I_BYPASSING_BUFFER =
    I_BUFFER_ACTIVE = ' '
    i_callback_program = report_id
    I_CALLBACK_PF_STATUS_SET = ' '
    I_CALLBACK_USER_COMMAND = ' '
    I_CALLBACK_TOP_OF_PAGE = ' '
    I_CALLBACK_HTML_TOP_OF_PAGE = ' '
    I_CALLBACK_HTML_END_OF_LIST = ' '
    i_structure_name = ' '
    I_BACKGROUND_ID = ' '
    i_grid_title = ws_title
    I_GRID_SETTINGS =
    is_layout = i_layout
    it_fieldcat = i_fieldcat
    IT_EXCLUDING =
    IT_SPECIAL_GROUPS =
    IT_SORT =
    IT_FILTER =
    IS_SEL_HIDE =
    I_DEFAULT = 'X'
    i_save = 'A'
    IS_VARIANT =
    it_events = i_events
    IT_EVENT_EXIT =
    IS_PRINT =
    IS_REPREP_ID =
    I_SCREEN_START_COLUMN = 0
    I_SCREEN_START_LINE = 0
    I_SCREEN_END_COLUMN = 0
    I_SCREEN_END_LINE = 0
    IT_ALV_GRAPHICS =
    IT_ADD_FIELDCAT =
    IT_HYPERLINK =
    IMPORTING
    E_EXIT_CAUSED_BY_CALLER =
    ES_EXIT_CAUSED_BY_USER =
    TABLES
    t_outtab = i_data
    EXCEPTIONS
    program_error = 1
    OTHERS = 2
    IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    *& Form F1000_Layout_Init
    FORM f1000_layout_init USING i_layout TYPE slis_layout_alv.
    CLEAR i_layout.
    i_layout-colwidth_optimize = 'X'.
    i_layout-edit = 'X'.
    ENDFORM. " F1000_Layout_Init
    *& Form f2000_fieldcat_init
    FORM f2000_fieldcat_init CHANGING i_fieldcat TYPE slis_t_fieldcat_alv.
    DATA: line_fieldcat TYPE slis_fieldcat_alv.
    CLEAR line_fieldcat.
    line_fieldcat-fieldname = 'QMNUM'. " The field name and the table
    line_fieldcat-tabname = 'I_DATA'. " name are the two minimum req.
    line_fieldcat-key = 'X'. " Specifies the column as a key (Blue)
    line_fieldcat-seltext_m = 'Notification No.'. " Column Header
    APPEND line_fieldcat TO i_fieldcat.
    CLEAR line_fieldcat.
    line_fieldcat-fieldname = 'QMART'.
    line_fieldcat-ref_tabname = 'I_DATA'.
    line_fieldcat-hotspot = 'X'. " Shows the field as a hotspot.
    line_fieldcat-seltext_m = 'Notif Type'.
    APPEND line_fieldcat TO i_fieldcat.
    CLEAR line_fieldcat.
    line_fieldcat-fieldname = 'QMTXT'.
    line_fieldcat-tabname = 'I_DATA'.
    line_fieldcat-seltext_m = 'Description'.
    APPEND line_fieldcat TO i_fieldcat.
    CLEAR line_fieldcat.
    line_fieldcat-fieldname = 'WS_ROW'.
    line_fieldcat-tabname = 'I_DATA'.
    line_fieldcat-seltext_m = 'Row Number'.
    APPEND line_fieldcat TO i_fieldcat.
    CLEAR line_fieldcat.
    line_fieldcat-fieldname = 'WS_CHAR'.
    line_fieldcat-tabname = 'I_DATA'.
    line_fieldcat-seltext_l = 'Test Character Field'.
    line_fieldcat-datatype = 'CHAR'.
    line_fieldcat-outputlen = '15'. " You can specify the width of a
    APPEND line_fieldcat TO i_fieldcat. " column.
    CLEAR line_fieldcat.
    line_fieldcat-fieldname = 'CHK'.
    line_fieldcat-tabname = 'I_DATA'.
    line_fieldcat-seltext_l = 'Checkbox'.
    line_fieldcat-checkbox = 'X'. " Display this field as a checkbox
    line_fieldcat-edit = 'X'. " This option ensures that you can
    " edit the checkbox. Else it will
    " be protected.
    APPEND line_fieldcat TO i_fieldcat.
    ENDFORM. " f2000_fieldcat_init
    *& Form f3000_build_header
    FORM f3000_build_header USING i_header TYPE slis_t_listheader.
    DATA: gs_line TYPE slis_listheader.
    CLEAR gs_line.
    gs_line-typ = 'H'.
    gs_line-info = 'This is line of type HEADER'.
    APPEND gs_line TO i_header.
    CLEAR gs_line.
    gs_line-typ = 'S'.
    gs_line-key = 'STATUS 1'.
    gs_line-info = 'This is line of type STATUS'.
    APPEND gs_line TO i_header.
    gs_line-key = 'STATUS 2'.
    gs_line-info = 'This is also line of type STATUS'.
    APPEND gs_line TO i_header.
    CLEAR gs_line.
    gs_line-typ = 'A'.
    gs_line-info = 'This is line of type ACTION'.
    APPEND gs_line TO i_header.
    ENDFORM. " f3000_build_header
    *& Form f4000_events_init
    FORM f4000_events_init CHANGING i_events TYPE slis_t_event.
    DATA: line_event TYPE slis_alv_event.
    CLEAR line_event.
    line_event-name = 'TOP_OF_PAGE'.
    line_event-form = 'F4100_TOP_OF_PAGE'.
    APPEND line_event TO i_events.
    CLEAR line_event.
    line_event-name = 'PF_STATUS_SET'.
    line_event-form = 'F4200_PF_STATUS_SET'.
    APPEND line_event TO i_events.
    ENDFORM. " f3000_events_init
    FORM F4100_TOP_OF_PAGE *
    FORM f4100_top_of_page.
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
    it_list_commentary = i_header.
    ENDFORM.
    FORM F4200_PF_STATUS_SET *
    FORM f4200_pf_status_set USING i_extab TYPE slis_t_extab.
    REFRESH i_extab.
    PERFORM f4210_exclude_fcodes CHANGING i_extab.
    SET PF-STATUS 'STANDARD' OF PROGRAM 'SAPLSALV' EXCLUDING i_extab.
    ENDFORM.
    *& Form f4210_exclude_fcodes
    FORM f4210_exclude_fcodes USING i_extab TYPE slis_t_extab.
    DATA: ws_fcode TYPE slis_extab.
    CLEAR ws_fcode.
    ws_fcode = '&EB9'. " Call up Report.
    APPEND ws_fcode TO i_extab.
    ws_fcode = '&ABC'. " ABC Analysis.
    APPEND ws_fcode TO i_extab.
    ws_fcode = '&NFO'. " Info Select.
    APPEND ws_fcode TO i_extab.
    ws_fcode = '&LFO'. " Information.
    APPEND ws_fcode TO i_extab.
    ENDFORM. " f4210_exclude_fcodes
    Thanks,
    Sankar M

  • Re : select-options in abap objects

    Dear friends,
    I want to give select-options in abap-objects program. How to give that.
    Thanking You
    with regards,
    Mani

    HI Mani,
    It's common mix ABAP Procedural with ABAP Objects in the same program.
    You should use the same way used in ABAP procedural program as Marco Cerdelli sad.
    But inside ABAP OBJECTS classes you can't use is these statement type.
    Don't forget to close this thread and all yours previous when your question be answered ! In case of doubt read the [rules of engagement|https://forums.sdn.sap.com/].
    Best Regards.
    Marcelo Ramos

  • ABAP Objects-Initialising

    Hi,
    IF cc_txt IS INITIAL.
          CREATE OBJECT cc_txt
            EXPORTING
    *      parent                      =
              container_name               = 'CC_TXT'
    *      style                       =
    *      lifetime                    = lifetime_default
    *      repid                       =
    *      dynnr                       =
    *      no_autodef_progid_dynnr     =
            EXCEPTIONS
              cntl_error                  = 1
              cntl_system_error           = 2
              create_error                = 3
              lifetime_error              = 4
              lifetime_dynpro_dynpro_link = 5
              OTHERS                      = 6
          IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
          ENDIF.
    cc_txt is declared as below.
    data:cc_txt TYPE REF TO cl_gui_custom_container.
    I am displaying some  text at two levels of a report using the same cc_txt.If it is working at the Primary level it is not working at the secondary level and vice versa.New to ABAP Objects,can anyone here let me know how to INITIALIZE this CC_TXT.
    Thanks,

    Hello
    I doubt whether anybody else except you understands what is your problem.
    Is it too difficult to pose a comprehensible question???
    What could be meant by primary and secondary level?
    Two different screens at the same screen level (e.g. level '0' for main screens)?
    A main screen (level=0) and a popup (level=1)?
    Here are my answers to this incomprehensible question:
    If you want to use the same container on two different main screens (e.g. screen 100 and 200, both having level=0, i.e . neither of them is displayed as popup) then use the LINK method of the container.
    If you want to use the same container on two different screen levels (e.g. main screen and popup) then I think this is not possible and you need to define a second container.
    Regards
      Uwe

  • Logical Database in Abap Objects

    Hi to All
    I want do it a program report using a Logical Database.
    Is this possible ??? But when I make a GET <node>, occurs the following error:
             "" Statement "ENDMETHOD" missing.  ""
    I'm doing the following:
    CLASS MONFIN IMPLEMENTATION.
           METHOD TRAER_DATOS.
                   GET VBRK.
           ENDMETHOD.
    ENDCLASS.
    Please, somebody tell me how I use the logical database in Abap Objects.
    Thank you very much
    Regards
    Dario R.

    Hi there
    Logical databases whilst of "some use" are not really part of OO.
    If you want to use a logical database in an abap OO program I would create a special class which just does the get data from your DB and pass this either at record or table level.
    Techniques such as GET XXXX LATE aren't really part of any OO type of application since at Object Instantiation time you should be able to access ALL the attributes of that object.
    As far as OO is concerned Logical databases are a throwback to "Dinosaur Technology".
    Since however modules such as SD and FI are still heavily reliant on relational structures (i.e linked tables etc)  then there is still some limited life in this stuff but for OO try and solve it by another method.
    If you really must use this stuff in OO then do it via a FMOD call and save the data in a table which your method will pass back to your application program.
    You can't issue a GET command directly in a method.
    Cheers
    Jimbo

  • Adding leading zeros in abap objects.

    Can anyone explain me
    1. How to add leading zeros to a field in abap objects.
    For eg:
    data: dmb(6) type c value '123456',
    actually the output value of c should have leading zeros added to it for length 16.
    i.e '0000000000123456' . If the length of dmb is less than 16 then leading zeros should be added to that value to make it 16 as length.
    Please tell me how to do it in ABAP Objects.

    Hi Camila
    Try to use the statement
    DATA: ALPHABET(15) VALUE '     ABCDEFGHIJ',
          M1(4)        VALUE 'ABCD',
          M2(6)        VALUE 'BJJCA '.
    SHIFT ALPHABET LEFT DELETING LEADING M1.
    The field
    ALPHABET
    remains unchanged.
    SHIFT ALPHABET LEFT DELETING LEADING SPACE.
    The field ALPHABET now has the following contents:
    'ABCDEFGHIJ     '.
    SHIFT ALPHABET RIGHT DELETING TRAILING M2.
    <b>ALPHABET</b> now has the following contents:
    '      ABCDEFGHI'.
    <u><b>IN CHARACTER MODE</b></u>
    <b>Effect</b>
    This is the default setting (see above), and the addition is therefore optional.
    <b>Note
    Performance:</b>
    For performance reasons, you should avoid using SHIFT in WHILE loops.
    The runtime required to shift a field with length 10 by one character to the right or left requires about 5 msn (standardized microseconds). A cyclical shift requires around 7 msn. The runtime for the ...
    LEFT DELETING LEADING
    ... variant is around 3.5 msn, for ...
    RIGHT DELETING TRAILING
    ... around 4.5 msn.
    Reward all helpfull answers
    Regards
    Pavan

  • Significance of Interfaces in ABAP Objects

    Hi Guys, here I have a query -
    Why do we use Interfaces in ABAP Objects?, and what is the significance of Interfaces in ABAP Objects?
    Please clarify the above with a suitable example.

    Moderator message - Welcome to SCN.
    But
    Moderator message - But this isn't a training forum. Please ask a specific question - post locked

  • Exception 'error_message' in ABAP Objects

    I've got a heterogeneous scenario with new program parts in ABAP objects and older parts in classical ABAP.
    In the older parts some R/3 standard functions are called which dump dialog messages which are not allowed at that state of the program flow ('on commit').
    The simple solution in classical ABAP was to use standard exception 'error_message' in the top level 'call function' statement thus catch all dialog messages in lower levels.
    I am looking for an analog solution in object oriented ABAP. But exception 'error_message' is not allowed with 'call method'. It cannot be defined statically in the methods declaration. And the system exception caused by the dialog error message is not included in the set of catchable system errors.
    I would be grateful for any hints concerning this problem.

    Hi
    Excuse me! But I didn't want to sent you my answer.
    Anyway:
    CLASS lcl_my_class DEFINITION.
      PUBLIC SECTION.
        METHODS my_method
                  EXPORTING
                    EXCEPTION TYPE CHAR1
                  EXCEPTIONS error_messages.
    ENDCLASS.                    "LCL_MY_CLASS DEFINITION
    CLASS lcl_my_class IMPLEMENTATION.
      METHOD my_method.
        IF EXCEPTION = 'X'.
          MESSAGE e208(00) WITH 'Message error'
                      RAISING error_messages.
        ELSE.
          MESSAGE I208(00) WITH 'OK!'.
        ENDIF.
      ENDMETHOD.                    "MY_METHOD
    ENDCLASS.                    "LCL_MY_CLASS IMPLEMENTATION
    So you did want to do a call like this:
    CALL METHOD lcl_my_class=>my_method
       EXCEPTIONS
         error_messages = 1
         error_message  = 2
         OTHERS         = 3.
    No! you can't do it, but you try to insert your call in fm where you use ERROR_MESSAGE addition. I think you can do it if your methods are std.
    Max
    Message was edited by: max bianchi

  • Re : select-options in abap-objects program

    Dear friends,
                      I want to give select-options in abap-objects program. How to give that.
                                 Thanking You
    with regards,
    Mani

    In the transaction SE24, enter your class name, click modify.
    in the tab named "Types" you have to declare two types. By example, if you want to receive one select-options that in your program that uses this class is declared like:
    " P_SAKNR FOR SKAT-SAKNR".
    you've got to declare two types in the class:
    a- TYPES:  begin of E_S_SAKNR,
                          sign(1),
                          option(2),
                          low(10),
                          high(10),
                      end of E_S_SAKNR.
    b - TYPES E_T_SAKNR type standard table of E_S_SAKNR.
    so, in the class method that you want to receive P_SAKNR as importing parameter. You got to do this:
    method TEST importing ET_SAKNR type E_T_SAKNR.
    now, in the implementation of this method you should be able to use ET_SAKNR as the same way as you usually use a parameter or a select-option. You could use it in a select with the operator IN by example..

  • Java package concept in ABAP Objects

    Hi, just a question on grouping of classes in ABAP Objects.
    In Java, you can group classes by "package" to avoid
    namespace collision, my question, in ABAP Objects, how
    do you group classes to avoid namespace collision?
    I know that there is package concept in SAP/ABAP but it
    is different concept in Java.
    Thanks in advanced for your reply.

    Hello One and Lonley,
    the package concept in ABAP and Java is quite different. In java the package name is part of the development object in ABAP not. So any class pool name is global unique. In combination with the restriction on 30 chars this leads often to somehow cryptic names.
    The only way to escape this somehow is the excessive use of local classes. That mean classes defined within main programs. If you are on 7.00 you may check FuGr SAPLSAUNIT_TREE_CTRL_LISTENER for this technique.
    Best Regards
      klaus

  • Poll: Development in ABAP Objects / Webdynpro vs. classical Dynpro

    Hey there ABAP developers,
    I just want to ask if you can give me one or two minutes of your attention for two poll questions.
    At the moment I´m writing my master thesis about the development of a monitoring tool in ABAP. One of my bigger chapters is about the decision, which programming paradigm should be used for new development projects in SAP. And another important one is about WebDynpro vs. classical Dynpros.
    Because of the fact, that I can´t create any polls in here, I just started this discussion and hope for many replies .
    It would be very nice if some of you could give me an answer to the following questions (only 2 ), so that I can maybe use the result of this poll in my master thesis, if there are enough responses.
    1. What percentage of new development projects are you developing in ABAP Objects? (Not to be considered small reports that just runs for only one time)
         A. 0 %
         B. less than 25%
         C. 25% - 49%
         D. 50% - 75%
         E. more than 75%
    2. Which GUI technology do you prefer?
         A. Classical Dynpro
         B. WebDynpro
         C. Business Server Pages (BSP)
         D. others (please mention)
    I want to thank you in advance for answering the questions,
    Best regards,
    Christoph

    Hi,
    Present SAP Implementation projects are very rare, maximum projects are support and up gradations only .
    If they want Implement the  SAP  newly  , defiantly they should creating ABAP Objects.
    Why Because  ABAP Objects are Object Oriented Concepts,  so,  for  future reference and re usability..etc .
    Now Come to the First Quetion.
    if it is implementation project   ABAP Objects are   25% - 49%.
    if it is Support project ABAP Objects are   25%
    Now Come to the Second Quetion.
    Depend upon Reqmnt, but Most of the Applications are Webdynpro .  i.e 70%.
    Remaining 30% All ( BSP and GUI ....Etc..)
    This is my opinion.
    Sambaiah.Paidipelli.

  • Dynamic documents in ABAP Objects (weblog)

    Hi SDNers,
    Do you want to implement the following features in ABAP Screens?
    1. Large font sizes and more colour options than traditional ABAP/4 (There are some limitations also)
    2. ICONS and pictures in different sizes
    3. Texts
    4. Links
    5. Pushbuttons
    6. Input fields
    7. Dropdown list boxes
    8. Tables with row span and with column span
    9. Tables with frames and without frames
    10. Tables with buttons, icons, pictures, input elements and texts in it.
    Then please read the below weblog to incorporate these features...
    <a href="/people/venkata.ramisetti/blog/2005/12/20/dynamic-documents-in-abap-objects">Dynamic Documents in ABAP Objects</a>
    Thanks,
    Ramakrishna

    one limitation which comes to my mind immediately is that you cannot create spool output of the dynamic document.
    Regards
    Raja

  • Help in abap objects

    hallow
    i wont example in regular abap like select stetmet and how i do that in abap objects (the same code)and which benefit i have in using objects.
    Regards

    hi,
    check the below links lot of info and examples r there
    http://www.sapgenie.com/abap/OO/index.htm
    http://www.geocities.com/victorav15/sapr3/abap_ood.html
    http://www.brabandt.de/html/abap_oo.html
    Check this cool weblog:
    /people/thomas.jung3/blog/2004/12/08/abap-persistent-classes-coding-without-sql
    /people/thomas.jung3/blog/2004/12/08/abap-persistent-classes-coding-without-sql
    http://help.sap.com/saphelp_nw04/helpdata/en/c3/225b6254f411d194a60000e8353423/frameset.htm
    http://www.sapgenie.com/abap/OO/
    http://www.sapgenie.com/abap/OO/index.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/c3/225b5654f411d194a60000e8353423/content.htm
    http://www.esnips.com/doc/375fff1b-5a62-444d-8ec1-55508c308b17/prefinalppt.ppt
    http://www.esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
    http://www.esnips.com/doc/5c65b0dd-eddf-4512-8e32-ecd26735f0f2/prefinalppt.ppt
    http://www.allsaplinks.com/
    http://www.sap-img.com/
    http://www.sapgenie.com/
    http://help.sap.com
    For funtion module to class
    http://help.sap.com/saphelp_47x200/helpdata/en/c3/225b5954f411d194a60000e8353423/content.htm
    for classes
    http://help.sap.com/saphelp_47x200/helpdata/en/c3/225b5c54f411d194a60000e8353423/content.htm
    for methods
    http://help.sap.com/saphelp_47x200/helpdata/en/08/d27c03b81011d194f60000e8353423/content.htm
    for inheritance
    http://help.sap.com/saphelp_47x200/helpdata/en/dd/4049c40f4611d3b9380000e8353423/content.htm
    for interfaces
    http://help.sap.com/saphelp_47x200/helpdata/en/c3/225b6254f411d194a60000e8353423/content.htm
    4) http://esnips.com/doc/0ef39d4b-586a-4637-abbb-e4f69d2d9307/SAP-CONTROLS-WORKSHOP.pdf
    5) http://esnips.com/doc/92be4457-1b6e-4061-92e5-8e4b3a6e3239/Object-Oriented-ABAP.ppt
    6) http://esnips.com/doc/448e8302-68b1-4046-9fef-8fa8808caee0/abap-objects-by-helen.pdf
    7) http://esnips.com/doc/39fdc647-1aed-4b40-a476-4d3042b6ec28/class_builder.ppt
    8) http://www.amazon.com/gp/explorer/0201750805/2/ref=pd_lpo_ase/102-9378020-8749710?ie=UTF8

  • Wa in ABAP Objects

    Hello!
    How can I write wa in ABAP Objects?
    CLASS money DEFINITION.
      PUBLIC SECTION.
        CLASS-DATA: wa TYPE zaa_sflight,
        wa1 TYPE TABLE OF wa.
        CLASS-METHODS zmoney.
    ENDCLASS.
    The program says, wa is unknown. How can I write it correct?
    Thanks!!

    Hi Andrei Algaier,
        This is because wa is not defined as datatype in datadictionary or in program with types statement.
    example:
    types : wa type c.
    data : xyz type wa.
    xyz will be of type c.
    This might be helpful.
    Regards,
    Kalyan.

  • Select-option in ABAP objects

    Hi Guys,
               I need a small help from you. I want to know how to populate the value from select-option to abap object. Please help me, it is very important

    check this code
    REPORT ZSELOPT_TO_CLASS .
    TABLES: VBRK.
    SELECT-OPTIONS: S_VBELN FOR VBRK-VBELN.
    DATA: IT_VBELN TYPE RSELOPTION.
    DATA: X_VBELN TYPE RSDSSELOPT.
    CLASS C1 DEFINITION.
    PUBLIC SECTION.
    DATA: IT_VBRP TYPE VBRP_TAB,
          X_VBRP LIKE LINE OF IT_VBRP.
    METHODS: GET_DATA IMPORTING S_VBELN TYPE RSELOPTION.
    METHODS: DISP_DATA.
    ENDCLASS.
    CLASS C1 IMPLEMENTATION.
    METHOD GET_DATA.
      *SELECT * FROM VBRP*
       INTO TABLE IT_VBRP
       WHERE VBELN IN S_VBELN.
    ENDMETHOD.
    METHOD DISP_DATA.
      LOOP AT IT_VBRP INTO X_VBRP.
        WRITE:/ X_VBRP-VBELN,
                X_VBRP-POSNR.
      ENDLOOP.
    ENDMETHOD.
    ENDCLASS.
    START-OF-SELECTION.
    DATA OBJ TYPE REF TO ZCL_SELOPT.
    CREATE OBJECT OBJ.
    LOOP AT S_VBELN.
      MOVE S_VBELN-LOW TO X_VBELN-LOW.
      MOVE S_VBELN-HIGH TO X_VBELN-HIGH.
      MOVE S_VBELN-SIGN TO X_VBELN-SIGN.
      MOVE S_VBELN-OPTION TO X_VBELN-OPTION.
      APPEND X_VBELN TO IT_VBELN.
    ENDLOOP.
    CALL METHOD OBJ->GET_DATA
                        EXPORTING
                          S_VBELN = IT_VBELN.
    CALL METHOD OBJ->DISP_DATA.
    Edited by: moazam hai on May 17, 2008 6:17 AM
    Edited by: moazam hai on May 17, 2008 6:19 AM

Maybe you are looking for