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: 

Abap Objects

Former Member
0 Kudos

Hi all,

What r the differences between Abap Objects and function modules?

Please tell me the advantages of using objects over fn mods...

Also tell me if there are any advantages of fn mod over objects exists...

3 REPLIES 3

Former Member
0 Kudos

HI

With object orientation, you can create different instances with same object type, only you need to give different values to a attribute(say Reg number) and just call one method to calculate tax based on Reg Number.

With function Module, you need to create different methods for different behaviours.

Maintenance is tough. Difficult to add further functionaity after some bulk.

Advantages of OOPS:

1. Better Programming Structure

2. Real world entity can be modeled very well

3.Stress on data security and access

4. Data encapsulation and abstraction

5. Reduction in code redundancy

Also this may help you

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

Function module

http://help.sap.com/saphelp_nw2004s/helpdata/en/73/d18756b27011d194ef0000e8353423/content.htm

Class introductory example

http://help.sap.com/saphelp_nw2004s/helpdata/en/73/d18759b27011d194ef0000e8353423/content.htm

Object introductory example

http://help.sap.com/saphelp_nw2004s/helpdata/en/48/ad3779b33a11d194f00000e8353423/content.htm

*********************************************************

Object-Oriented Programming Overview

The concepts of Object-Oriented (OO) programming have been around for over four decades. Initially developed in the field of artificial intelligence, OO programming was embraced by Xerox as a means of developing systems that better reflected real life needs and were more user friendly. OO’s popularity and sophistication has increased in the past several years as businesses are abandoning their mainframe systems and incorporating more client-server models to run their businesses and are integrating web technology as a business tool. A change in the overall pace of business has also contributed to the increased popularity of OO programming. One of the primary features of OO programming is its relative flexibility and adaptability to changing business needs.

How is OO programming different from traditional procedural programming?

Traditional programming has the following characteristics:

Functions are written sequentially, so that a change in programming can affect any code that follows it.

If a function is used multiple times in a system (i.e., a piece of code that manages the date), it is often simply cut and pasted into each program (i.e., a change log, order function, fulfillment system, etc). If a date change is needed (i.e., Y2K when the code needed to be changed to handle four numerical digits instead of two), all these pieces of code must be found, modified, and tested.

Code (sequences of computer instructions) and data (information on which the instructions operates on) are kept separate. Multiple sets of code can access and modify one set of data. One set of code may rely on data in multiple places. Multiple sets of code and data are required to work together. Changes made to any of the code sets and data sets can cause problems through out the system.

Object-Oriented programming takes a radically different approach:

Code and data are merged into one indivisible item – an object (the term “component” has also been used to describe an object.) An object is an abstraction of a set of real-world things (for example, an object may be created around “date”) The object would contain all information and functionality for that thing (A date object it may contain labels like January, February, Tuesday, Wednesday. It may contain functionality that manages leap years, determines if it is a business day or a holiday, etc., See Fig. 1). Ideally, information about a particular thing should reside in only one place in a system. The information within an object is encapsulated (or hidden) from the rest of the system.

A system is composed of multiple objects (i.e., date function, reports, order processing, etc., See Fig 2). When one object needs information from another object, a request is sent asking for specific information. (for example, a report object may need to know what today’s date is and will send a request to the date object) These requests are called messages and each object has an interface that manages messages.

OO programming languages include features such as “class”, “instance”, “inheritance”, and “polymorphism” that increase the power and flexibility of an object.

What are the advantages of Object-Oriented programming?

One of the main advantages of OO programming is its ease of modification; objects can easily be modified and added to a system there by reducing maintenance costs. OO programming is also considered to be better at modeling the real world than is procedural programming. It allows for more complicated and flexible interactions. OO systems are also easier for non-technical personnel to understand and easier for them to participate in the maintenance and enhancement of a system because it appeals to natural human cognition patterns.

For some systems, an OO approach can speed development time since many objects are standard across systems and can be reused. Components that manage dates, shipping, shopping carts, etc. can be purchased and easily modified for a specific system.

The best advantages are data encapsulation, and data reusage . The advantages of BADI's and ALVs are a example of this.

ABAP objects and ABAP are inextricably linked.

Advantages:

Simplicity,

Explicitness,

Maintainability,

Purified ABAP,

Scalability,

Adopt the universal approach for modern programming.

Programs are organized into classes and objects and the functionalities are embedded into methods of a class.

Where as process oreinted emphasises on Task,OO programming emphasises on data.

Regards

Vasu

0 Kudos

Hi,

Both Function groups and ABAP Objects group the Data and the Methods.

But We cannot have multiple instances of a Function Group in one program, that is a program can have only one instance of a Function module. <b>Where as A program can create as many instances of a ABAP CLASS as it wants.

That is one main difference and Advantage of ABAP Objects.</b>

Also ABAP classes are more restrictive interms of TYPEING. That is you cannot mention generic types and cannot use LIKE in ABAP objects.

Event based programming is possible in ABAP Objects

<b>One advantage of Function modules over ABAP Objects is they can HAVE SCREENS.</b>

Regards,

Sesh

Former Member
0 Kudos

we cannot retrive the data from outside SAP and another server, but we can retrive the data through function module woth remote enabled function......

we can create the event in the abap objects but in the function moule we cannot create the events.

likewise lot of differences available b/n function module and abap objects.....

regards

velu