Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

advanced example using oops

Former Member
0 Kudos

can any body send me advanced example sample program using oops with clear explanation

Thanks in advance

3 REPLIES 3

Former Member
0 Kudos

Hi

You may find the following programs useful in getting to grips with tree controls:

SAPSIMPLE_TREE_CONTROL_DEMO

SAPCOLUMN_TREE_CONTROL_DEMO

SAPTLIST_TREE_CONTROL_DEMO

Event Handling

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/cda3992d-0e01-0010-90b2-c4e1f899...

use ABAPDOCU transaction in SAP.

here check... BCALV_EDIT_01 - BCALV_EDIT_08 programs which are OOPS related...

Also, check below links...

http://www.erpgenie.com/abap/controls/alvgrid.htm

Former Member
0 Kudos

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 . Events have a similar parameter interface to methods, but only have output parameters. These parameters are passed by the trigger (RAISE EVENT statement) to the event handler method, which receives them as input parameters.

Using the SET HANDLER statement, the link between trigger and handler is established dynamically in a program. The trigger and handlers can be objects or classes, depending on whether you have instance or static events and event handler methods. When an event is triggered, the corresponding event handler methods are executed in all registered handling classes.

Features

Encapsulation

The three visibility areas (public section, protected section, private section) are the basis for one of the important features of object orientation, Encapsulation. You should take great care in designing the public components and try to declare as few public components as possible when you define a class. Once you have released the class, the public components of global classes may not be changed.

Public attributes are visible externally and form a part of the interface between an object and its users. If you want to encapsulate the state of an object fully, then you cannot declare any public attributes. Apart from defining the visibility of an attribute, you can also protect it from changes using the READ-ONLY addition.

Inheritance

Inheritance allows you to derive a new class from an existing class. It is done by using the INHERITING FROM addition in the statement:

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.

Conclusion

I have explained object orientation which is such an important aspect in SAP. The discussion began with the features of Object Orientation and includes the runtime environment, the language extension, the classes and the class components. Apart from that I have also discussed for new first time readers event handling, inheritance encapsulation and polymorphism.

Refer these basics

OO ABAP

http://www.sapgenie.com/abap/OO/eg.htm

http://www.sapgenie.com/abap/OO/syntax.htm

http://www.sapgenie.com/abap/OO/index.htm

http://www.sapgenie.com/abap/OO/defn.htm

Detailed

OOPS – OO ABAP

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

http://www.amazon.com/gp/explorer/0201750805/2/ref=pd_lpo_ase/102-9378020-8749710?ie=UTF8

http://help.sap.com/saphelp_nw04/helpdata/en/c3/225b5654f411d194a60000e8353423/content.htm

http://help.sap.com/saphelp_nw2004s/helpdata/en/c3/225b5654f411d194a60000e8353423/content.htm

You can go through this document as a starter...

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

You can refer these docs for more information...

http://esnips.com/web/OOP

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://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://www.sapgenie.com/abap/OO/

http://www.sapgenie.com/abap/OO/index.htm

http://www.sapgenie.com/abap/controls/index.htm

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

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

http://www.sapgenie.com/abap/OO/index.htm

http://help.sap.com/saphelp_erp2005/helpdata/en/ce/b518b6513611d194a50000e8353423/frameset.htm

these links

http://help.sap.com/saphelp_47x200/helpdata/en/ce/b518b6513611d194a50000e8353423/content.htm

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

For Materials:

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

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

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

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

😎 http://www.amazon.com/gp/explorer/0201750805/2/ref=pd_lpo_ase/102-9378020-8749710?ie=UTF8

1) http://www.erpgenie.com/sap/abap/OO/index.htm

2) http://help.sap.com/saphelp_nw04/helpdata/en/ce/b518b6513611d194a50000e8353423/frameset.htm

Please give me reward points...

uwe_schieferstein
Active Contributor
0 Kudos

Hello Narayana

You may have a look at my sample reports posted within the SDN. Simply search (from the SDN homepage within the Forums) for <b>ZUS_SDN</b>.

Each report usually demonstrates a specific aspect of ALV programming. Since all of these reports look very similar (in terms of coding) you should be able to understand the crucial parts of ALV programming soon.

In addition, have a look at the excellent tutorial

<a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e8a1d690-0201-0010-b7ad-d9719a415907">An Easy Reference For ALV Grid Control</a>

Regards

Uwe