Skip to Content
author's profile photo Former Member
Former Member

Difference between Normal ALV and ALV OOPs

pls give few differences between ALV OOPs and normal ALV

Regards,

Naseer.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

6 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Dec 05, 2007 at 11:55 AM

    Hi,

    Normal alv wil create in the program. The OOALV will create in the SE24 and SE38. If u create the alv in se24 it is global usable. IF u create in the se38 , its specific to that program only.

    Regards

    Srinu

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 05, 2007 at 11:23 AM

    Hi

    ALV is Application List viewer. Sap provides a set of ALV (ABAP LIST VIEWER) function modules which can be put into use to embellish the output of a report. This set of ALV functions is used to enhance the readability and functionality of any report output. Cases arise in sap when the output of a report contains columns extending more than 255 characters in length. In such cases, this set of ALV functions can help choose selected columns and arrange the different columns from a report output and also save different variants for report display. This is a very efficient tool for dynamically sorting and arranging the columns from a report output. The report output can contain up to 90 columns in the display with the wide array of display options.

    We can implement OOPS concepts in SAP using ABAP objets concept.

    ABAP Objects is a new concept in R/3 Release 4.0. The term has two meanings. On the one hand, it stands for the entire ABAP runtime environment. On the other hand, it represents the object-oriented extension of the ABAP language.

    The Object-Oriented Language Extension

    ABAP Objects is a complete set of object-oriented statements that has been introduced into the ABAP language. This object-oriented extension of ABAP builds on the existing language, and is fully compatible with it. You can use ABAP Objects in existing programs, and can also use "conventional" ABAP in new ABAP Objects programs.

    ABAP Objects supports object-oriented programming. Object orientation (OO), also know as the object-oriented paradigm, is a programming model that unites data and functions in objects. The rest of the ABAP language is primarily intended for structured programming, where data is stored in a structured form in database tables and function-oriented programs access and work with it.

    The object-oriented enhancement of ABAP is based on the models of Java and C++. It is compatible with external object interfaces such as DCOM and CORBA. The implementation of object-oriented elements in the kernel of the ABAP language has considerably increased response times when you work with ABAP Objects. SAP Business Objects and GUI objects - already object-oriented themselves - will also profit from being incorporated in ABAP Objects.

    Introduction

    The object orientation can be defined as a problem-solving method in which the software solution reflects objects in the real world. Therefore, a comprehensive introduction to object orientation would go far beyond the limits of this introduction to ABAP Objects as a whole.

    Object

    An object can be defined as a section of source code that contains data and provides services. The attributes of the object are formed by the data. The services are known as methods (also known as operations or functions). Typically, it is seen that the methods operate on private data (the attributes, or state of the object), which is only visible to the methods of the object. Thus, the attributes of an object cannot be changed directly by the user, but by the methods of the object only. This guarantees the internal consistency of the object.

    Classes

    The classes are very important, as they describe the objects. From a technical point of view, the objects are runtime instances of a class. One can create any number of objects based on a single class in theory. Each instance (object) of a class has a unique identity and its own set of values for its attributes.

    Features of Object Orientation

    Encapsulation

    According to this property, objects restrict the visibility of their resources (attributes and methods) to other users. Every object has an interface which plays a very important role. It determines how other objects can interact with it. It is found that the implementation of the object is encapsulated, which means that it is invisible outside the object itself.

    Polymorphism

    According to this property, identical (identically-named) methods behave differently in different classes. Object-oriented programming contains constructions, which are called interfaces. They enable you to address methods with the same name in different objects. The implementation of the method is specific to a particular class, though the form of address is always the same.

    Inheritance

    According to this property, one can use an existing class to derive a new class. The data and methods of the super class are inherited by the derived classes. However, they can overwrite existing methods and add new ones.

    Uses of Object Orientation

    The object-oriented programming is quite useful in many ways. It has various advantages, some of which are mentioned below.

    Since object-oriented structuring provides a closer representation of reality than other programming techniques, complex software systems become easier to understand.

    In object-oriented system, it should be possible to implement changes at class level, without having to make alterations at other points in the system. This reduces the overall amount of maintenance required.

    The object-oriented programming allows reusing individual components through polymorphism and inheritance.

    In this system, the amount of work involved in revising and maintaining the system is reduced as many problems can be detected and corrected in the design phase.

    To achieve these goals, the followings are required:

    Object-oriented programming languages: The efficiency of object-oriented programming depends directly on how object-oriented language techniques are implemented in the system kernel.

    Object-oriented tools: Object-oriented tools allow you to create object-oriented programs in object Oriented languages. They also allow you to model and store development objects and the Relationships between them.

    Object-oriented modeling: The object-orientation modeling of a software system is the most important, most time-consuming, and most difficult requirement for attaining the above goals. These designs involve more than just object-oriented programming and logical advantages that are independent of the actual implementation are provided by it.

    ABAP Objects

    ABAP Objects is a new concept in R/3 System and you can find its two distinct meanings --- one is for the entire ABAP runtime environment and the other represents the new object-oriented generation of this language.

    The Runtime Environment

    ABAP Objects, for the entire ABAP runtime environment, are an indication of how SAP has, for sometime, been moving towards object orientation. Object-oriented techniques have been used exclusively in system design. The ABAP language did not support these techniques earlier.

    The ABAP Workbench will allow creating R/3 Repository objects in this regard. These objects are programs, authorization objects, lock objects, customizing objects, and so on and so forth. By using function modules, one can also encapsulate functions in separate programs with a defined lnterface. The Business Object Repository (BOR) allows you to create SAP Business Objects for internal and external use.

    The Object-Oriented Language Extension

    ABAP Objects support object-oriented programming. The ABAP Objects is a complete set of object-oriented statements, which has been introduced into the ABAP language. This object-oriented extension of ABAP builds on the existing language and is fully compatible with it.

    The Object Orientation (OO), also known as the object-oriented paradigm, is a programming model that unites data and functions in objects. You can not only use ABAP Objects in existing programs, but also work with and use a conventional ABAP in new ABAP Objects programs. The rest of the ABAP language is primarily intended for structured programming, where data is stored in a structured form in database tables and function-oriented programs access and work with it.

    Moreover, we should know that the object-oriented enhancement of ABAP is based on the models of Java and C++. It is compatible with external object interfaces such as DCOM and CORBA. The implementation of object-oriented elements in the kernel of the ABAP language has considerably increased response times when you work with ABAP Objects. Some other objects, such as SAP Business Objects and GUI objects, which are already object-oriented by themselves, are also benefiting from being incorporated into ABAP Objects.

    About Classes

    The classes are templates for objects. An abstract description of an object is the class. You could say it is a set of instructions for building an object. The attributes of objects are defined by the components of the class, which describe the state and behavior of objects.

    Local and Global Classes

    In ABAP Objects, classes can be declared either globally or locally. You define global classes and interfaces in the Class Builder (Transaction SE24.} in the ABAP Workbench. In the R/3 Repository, they are stored centrally in class pools in the class library. In an R/3 System, all of the ABAP programs can access the global classes. The local classes are defined within an ABAP program. Local classes and interfaces can only be used in the program in which they are defined. When you use a class in an ABAP program, the system first searches for a local class with the specified name. If it does not find one, then it looks for a global class. Apart from the visibility question, there is no difference between using a global class and using a local class.

    However, there is a significant difference in the way that local and global classes are designed. If you are defining a local class that is only used in a single program, then to define the outwardly visible components so that it fits into that program is usually sufficient. On the other hand, global classes must be able to be used anywhere. Since the system must be able to guarantee any program using an object of a global class, it can recognize the data type of each interface parameter and then certain restrictions are applied at the time of defining the interface of a global class.

    Defining Local Classes

    Local classes consist of ABAP source code, where the ABAP statements CLASS...ENDCLASS are enclosed. A complete class definition consists of the following parts, a declaration part and, if required, an implementation part. It is found that the declaration part of a class . The new class is called the subclass of the class from which it is derived. The original class is called the superclass of the new class. It contains the same components as the superclass if you do not add any new declarations to the subclass. However, in the subclass only the public and protected components of the superclass are visible. The private components of the superclass are not visible though they exist in the subclass. You can declare private components in a subclass that have the same names as private components of the superclass. It is seen that each class works with its own private components. The another point that we note is that methods which a subclass inherits from a superclass use the private attributes of the superclass and not any private components of the subclass with the same names.

    The subclass is an exact replica of the superclass if the superclass does not have any private visibility section. However, you can add a new component to the subclass because it allows you to turn the subclass into a specialized version of the superclass. If a subclass is itself the superclass of further classes, then you can introduce a new level of specialization.

    Polymorphism

    Reference variables are defined with reference to a superclass or an interface defined with reference to it can also contain references to any of its subclasses. A reference variable defined with reference to a superclass or an interface implemented by a superclass can contain references to instances of any of its subclasses, since subclasses contain all of the components of all of their superclasses and also convey that the interfaces of methods cannot be changed. In particular, you can define the target variable with reference to the generic class OBJECT.

    Using the CREATE OBJECT statement, when you create an object and a reference variable typed with reference to a subclass then you can use the TY PE addition to which the reference in the reference variable will point.

    A reference variable can be used by a static user to address the components visible to it in the superclass to which the reference variable refers. However, any specialization implemented in the subclass cannot be addressed by it.

    Depending on the position in the inheritance tree at which the referenced object occurs, you can use a single reference variable to call different implementations of the method. This is possible only if you redefine an instance method in one or more subclasses. This concept is called polymorphism, in which different classes can have the same interface and, therefore, be addressed using reference variables with a single type.

    Here is the simple code as explained previously.

    Then coming to steps for creation of ALV in OOABAP.

    1. Create a program in se38 and just activate it without any code for now.

    2. Go to module pool and create a screen, put a custom container control on to the screen. (You will find this control on right side tool box).

    3. Give a name to the control created in step 2.

    4. Activate the screen.

    5. Come to the program declare two variables to hold instances of 2 classes CL_GUI_CUSTOM_CONTAINER, CL_GUI_ALV_GRID.

    6. create an instance of the class CL_GUI_CUSTOM_CONTAINER passing container name created in step 3.

    7. create an instance of the class CL_GUI_ALV_GRID passing INSTANCE VARIBALE name created in step 6.

    8. using the ref. variable of previous step call method SET_TABLE FORFIRST_DISPLAY method and pass structure name and internal table containing data.

    9. then call screen created in step 2.

    REPORT zgs_simple_alv.

    DATA : it_mara TYPE TABLE OF mara.

    DATA : container TYPE REF TO cl_gui_custom_container,

    grid TYPE REF TO cl_gui_alv_grid.

    SELECT * FROM mara INTO TABLE it_mara UP TO 10 ROWS.

    CREATE OBJECT container

    EXPORTING

    • PARENT =

    container_name = 'CONTAINER'

    • 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.

    CREATE OBJECT grid

    EXPORTING

    • I_SHELLSTYLE = 0

    • I_LIFETIME =

    i_parent = container

    • I_APPL_EVENTS = space

    • I_PARENTDBG =

    • I_APPLOGPARENT =

    • I_GRAPHICSPARENT =

    • I_NAME =

    • I_FCAT_COMPLETE = SPACE

    • EXCEPTIONS

    • ERROR_CNTL_CREATE = 1

    • ERROR_CNTL_INIT = 2

    • ERROR_CNTL_LINK = 3

    • ERROR_DP_CREATE = 4

    • others = 5

    .

    IF sy-subrc <> 0.

    • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    ENDIF.

    CALL METHOD grid->set_table_for_first_display

    EXPORTING

    • I_BUFFER_ACTIVE =

    • I_BYPASSING_BUFFER =

    • I_CONSISTENCY_CHECK =

    i_structure_name = 'MARA'

    • IS_VARIANT =

    • I_SAVE =

    • I_DEFAULT = 'X'

    • IS_LAYOUT =

    • IS_PRINT =

    • IT_SPECIAL_GROUPS =

    • IT_TOOLBAR_EXCLUDING =

    • IT_HYPERLINK =

    • IT_ALV_GRAPHICS =

    • IT_EXCEPT_QINFO =

    • IR_SALV_ADAPTER =

    CHANGING

    it_outtab = it_mara

    • IT_FIELDCATALOG =

    • IT_SORT =

    • IT_FILTER =

    • EXCEPTIONS

    • INVALID_PARAMETER_COMBINATION = 1

    • PROGRAM_ERROR = 2

    • TOO_MANY_LINES = 3

    • others = 4

    .

    IF sy-subrc <> 0.

    • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    ENDIF.

    CALL SCREEN 100.

    Please check these links ...

    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCABA/BCABA.pdf -- Page no: 1291

    http://esnips.com/doc/5c65b0dd-eddf-4512-8e32-ecd26735f0f2/prefinalppt.ppt

    http://esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf

    http://esnips.com/doc/0ef39d4b-586a-4637-abbb-e4f69d2d9307/SAP-CONTROLS-WORKSHOP.pdf

    http://esnips.com/doc/92be4457-1b6e-4061-92e5-8e4b3a6e3239/Object-Oriented-ABAP.ppt

    http://esnips.com/doc/448e8302-68b1-4046-9fef-8fa8808caee0/abap-objects-by-helen.pdf

    http://esnips.com/doc/39fdc647-1aed-4b40-a476-4d3042b6ec28/class_builder.ppt

    Please reward if useful

    Sivaparvathi

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 05, 2007 at 11:21 AM

    Hi,

    there are some special features in OOALV since it is object oriented reusability i sthe main task. initially u can reuse the custom controller, and design the screen as per our requirement since it is somethng like modulepool. we make use of classes here.

    whereas in normal ALV there is no possibility of reusability since we need to populate and call function module from the scratch.

    and we cannot design our own settings as it comes by default .

    regards,

    Omkar.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 05, 2007 at 11:26 AM
    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 05, 2007 at 11:27 AM

    Hi Naseer,

    In Normal ALV we use Function mnodule and in OOPs we use classes and methods.

    In Normal ALV we cannot place grids on screens but in OOALV we can place grids on screens.

    we can insert logos in OOPS ALV.

    see the code below

    for displaying LOGO in ALV GRID CONTROL, we work with

    Predefined global class. CL_GUI_ALV_TREE_SIMPLE. FOR

    displaying LOGO. AND we use CL_GUI_CUSTOM_CONTAINTER for

    identifies the location where we r goinh to display.

    DECLARATIONS;

    TYPE-POOLS: SDYDO, SLIS.

    DATA: L_LOGO TYPE SDYDO_VALUE,” FOR DISPLAYING LOGO

    L_LIST TYPE SLIS_T_LISTHEADER. ” FOR LIST HEADING

    DATA: LOGO TYPE SCRFNAME VALUE ‘SLOGO’,

    CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,

    LOGO1 TYPE REF TO CL_GUI_ALV_TREE_SIMPLE.

      • CREATE INSTANCE FOR ABOVE DEFINED CLASSES IN PBO EVENT

      OF SCREEN FLOW LOGIC.

      IF CONTAINER IS INITIAL.

      CREATE OBJECT CONTAINER EXPORTING CONTAINER_NAME =

      LOGO.

      CREATE OBJECT LOGO1 EXPORTING I_PARENT = CONTAINER.

          • NOW CALL THE METHOD FOR DISPLAYING LOGO IN GRID CONTROL

          CALL METHOD LOGO->‘CREATE_REPORT_HEADER’

          EXPORTING

          I_LIST_COMMENTARY = L_LIST

          I_LOGO = ’ ’ ” HERE PASS WHERE LOGO EXISTING.

          THE ABOVE METHOD EXISTING

          reward points if helpful..

          Regards,

          Nitin.

          Add a comment
          10|10000 characters needed characters exceeded

        • author's profile photo Former Member
          Former Member
          Posted on Dec 05, 2007 at 11:47 AM

          Hi Naseer,

          1. Normal ALV = alv using function module

          2. OOPS alv = alv using class/object concept

          3. Normal alv is simple to use whereas in oops alv

          we have to design the screen (to put the alv control on screen)

          3. oops alv is cumbersome code.

          Regards,

          Amit Mittal.

          Add a comment
          10|10000 characters needed characters exceeded

        Before answering

        You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
        You must be Logged in to submit an answer.

        Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.