alv( application list viewer) and oo concept

Upload: prasad-pandit

Post on 03-Jun-2018

223 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/12/2019 ALV( Application List Viewer) and OO Concept

    1/6

    ALV is Application List viewer. Sap provides a set of ALV (ABAP LIST VIEWER) functionmodules which can be put into use to embellish the output of a report. This set of ALV functionsis used to enhance the readability and functionality of any report output. Cases arise in sap whenthe output of a report contains columns extending more than 255 characters in length. In suchcases, 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 veryefficient tool for dynamically sorting and arranging the columns from a report output. The reportoutput 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 onehand, it stands for the entire ABAP runtime environment. On the other hand, it represents theobject-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 theABAP language. This object-oriented extension of ABAP builds on the existing language, and isfully 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 asthe 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 isstored in a structured form in database tables and function-oriented programs access and workwith it.

    The object-oriented enhancement of ABAP is based on the models of Java and C++. It iscompatible with external object interfaces such as DCOM and CORBA. The implementation ofobject-oriented elements in the kernel of the ABAP language has considerably increasedresponse 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 softwaresolution 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 (alsoknown 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

  • 8/12/2019 ALV( Application List Viewer) and OO Concept

    2/6

  • 8/12/2019 ALV( Application List Viewer) and OO Concept

    3/6

    In this system, the amount of work involved in revising and maintaining the system is reduced asmany 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 programmingdepends directly on how object-oriented language techniques are implemented in the systemkernel.

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

    Object-oriented modeling: The object-orientation modeling of a software system is the mostimportant, 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 --- oneis for the entire ABAP runtime environment and the other represents the new object-orientedgeneration of this language.

    The Runtime Environment

    ABAP Objects, for the entire ABAP runtime environment, are an indication of how SAP has, forsometime, been moving towards object orientation. Object-oriented techniques have been usedexclusively 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 objectsare programs, authorization objects, lock objects, customizing objects, and so on and so forth. Byusing function modules, one can also encapsulate functions in separate programs with a definedlnterface. The Business Object Repository (BOR) allows you to create SAP Business Objects forinternal and external use.

    The Object-Oriented Language Extension

    ABAP Objects support object-oriented programming. The ABAP Objects is a complete set ofobject-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 programmingmodel that unites data and functions in objects. You can not only use ABAP Objects in existing

  • 8/12/2019 ALV( Application List Viewer) and OO Concept

    4/6

    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 isstored in a structured form in database tables and function-oriented programs access and workwith it.

    Moreover, we should know that the object-oriented enhancement of ABAP is based on themodels of Java and C++. It is compatible with external object interfaces such as DCOM andCORBA. The implementation of object-oriented elements in the kernel of the ABAP languagehas considerably increased response times when you work with ABAP Objects. Some otherobjects, such as SAP Business Objects and GUI objects, which are already object-oriented bythemselves, 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 couldsay 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 classesand interfaces in the Class Builder (Transaction SE24.} in the ABAP Workbench. In the R/3Repository, they are stored centrally in class pools in the class library. In an R/3 System, all ofthe 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 thespecified 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. Ifyou are defining a local class that is only used in a single program, then to define the outwardlyvisible components so that it fits into that program is usually sufficient. On the other hand, globalclasses 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 globalclass.

    Defining Local Classes

    Local classes consist of ABAP source code, where the ABAP statements CLASS...ENDCLASSare enclosed. A complete class definition consists of the following parts, a declaration part and, ifrequired, an implementation part. It is found that the declaration part of a class . The new class iscalled the subclass of the class from which it is derived. The original class is called thesuperclass of the new class. It contains the same components as the superclass if you do not addany new declarations to the subclass. However, in the subclass only the public and protectedcomponents of the superclass are visible. The private components of the superclass are not

  • 8/12/2019 ALV( Application List Viewer) and OO Concept

    5/6

    visible though they exist in the subclass. You can declare private components in a subclass thathave the same names as private components of the superclass. It is seen that each class workswith its own private components. The another point that we note is that methods which asubclass inherits from a superclass use the private attributes of the superclass and not any privatecomponents of the subclass with the same names.

    The subclass is an exact replica of the superclass if the superclass does not have any privatevisibility section. However, you can add a new component to the subclass because it allows youto turn the subclass into a specialized version of the superclass. If a subclass is itself thesuperclass 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 withreference to it can also contain references to any of its subclasses. A reference variable definedwith 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 theirsuperclasses and also convey that the interfaces of methods cannot be changed. In particular, youcan define the target variable with reference to the generic class OBJECT.

    Using the CREATE OBJECT statement, when you create an object and a reference variabletyped with reference to a subclass then you can use the TYPE addition to which the reference inthe reference variable will point.

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

    Depending on the position in the inheritance tree at which the referenced object occurs, you canuse a single reference variable to call different implementations of the method. This is possibleonly 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, beaddressed 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. (Youwill find this control on right side tool box).

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

    4. Activate the screen.

  • 8/12/2019 ALV( Application List Viewer) and OO Concept

    6/6

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

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

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

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

    9. then call screen created in step 2.