You are on page 1of 12

What are the main differences between Procedural and Object oriented programming

?
Sl No Procedure Oriented
Object Oriented
1
Emphasis on doing things.
Emphasis on data rather than procedure.
2
Large programs are divided into smaller programs known as functions.
Programs are divided into objects.
3
Most of the functions share global data.
Data structures are desi
gned such that they characterized the objects.
4
Data move openly around the system from function to function. Function
s that operate on the data of an object are tied together in the data structure.
Data is hidden and cannot be accessed by external functions.
5
Top-down approach.
Bottom-up approach.
6
In general:
1)functions
2)modules
3)call
4)variable
1) methods
2)objects
3)message
4)attribute
What are the advantages of ABAP OOPS?
1.
Through inheritance we can eliminate redundant code and extend the use o
f existing class.
2.
We can develop programs from the existing classes given by SAP.
3.
The concept of data hiding helps the programmer to build secure programs
that cannot be invaded by code in other parts of programs.
4.
OOP system can be easily upgraded from smaller system to larger system.
5.
Software complexity can be easily managed.
6.
Code reusability.
7.
For interfacing ABAP with Microsoft technologies, Java as all these are
Build on the concept of OOP .
8.
To easily understand the recent concepts of ABAP ex BAPI, BADI workflow.
What are the core ABAP oops concepts?
Inheritance: Inheritance is the ability of an object to inherit the properties a
nd methods of another object. This characteristic leads to the creation of famil
ies of objects (just like families exist for humans) with parent objects and chi
ld objects.
Polymorphism: Polymorphism is about an objects ability to provide context when m
ethods or operators are called on the object.
Definition: Polymorphism
In object-oriented programming, polymorphism (from the Greek meaning "having mul
tiple forms") is the characteristic of being able to assign a different meaning
to a particular symbol or "operator" in different contexts. The simple example i
s two classes that inherit from a common parent and implement the same virtual
method.
Encapsulation: Encapsulation is the ability that an object has to contain and re
strict the access to its members. Encapsulation is a key concept of object progr
amming that ensures the autonomy and integrity of the objects.
Abstraction: Another OOP concept related to encapsulation that is less widely us
ed but gaining ground is abstration.
Definition: Abstraction
Through the process of abstraction, a programmer hides all but the relevant data
about an object in order to reduce complexity and increase efficiency. In the s
ame way that abstraction sometimes works in art, the object that remains is a re
presentation of the original, with unwanted detail omitted. The resulting object
itself can be referred to as an abstraction, meaning a named entity made up of

selected attributes and behavior specific to a particular usage of the originati


ng entity.
What is UML?
UML (Unified Modeling Language) is a standardized modeling language. It is used
for the specification, construction, visualization and documentation of models f
or software systems and enables uniform communication between various users.
UML does not describe the steps in the object-oriented development process.
SAP uses UML as the company-wide standard for object-oriented modeling.
UML describes a number of different diagram types in order to represent differen
t views of a system.
What are the types of Objects and Classes?
In general there are two types of Objects: Instance Object and Static Object an
d as such there are two types of Classes: Instance class and Static Class.
Specifically when it comes to visibility, Private class, Protected class and Pub
lic classes are the types of classes one can have.
What are the types of classes which can be created?
We can create four types of classes under final and only modeled category(option
al) with the private, protected, public and abstract instantiation.
Usual Abap Class.
Exception Class(With/Without messages).
Persistent Class.
Test Class(ABAP Unit).
What are local and global classes?
classes in ABAP Objects can be declared either globally or locally.
You define global classes and interfaces in the Class Builder (Transaction SE24)
in the ABAP Workbench.
They are stored centrally in class pools in the class library in the R/3 Reposit
ory. All of the ABAP programs in an R/3 System can access the global classes.
Local classes are defined within an ABAP program. Local classes and interfaces c
an 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 c
lass with the specified name. If it does not find one, it then looks for a globa
l class.
Apart from the visibility question, there is no difference between using a globa
l class and using a local class.
If you are defining a local class that is only used in a single program, it is u
sually sufficient to define the outwardly visible components so that it fits int
o that program.
Global classes, on the other hand, must be able to be used anywhere. This means
that certain restrictions apply when you define the interface of a global class,
since the system must be able to guarantee that any program using an object of
a global class can recognize the data type of each interface parameter.
Local classes consist of ABAP source code, enclosed in the ABAP statements CLASS
... ENDCLASS. A complete class definition consists of a declaration part and, i
f required, an implementation part. The declaration part of a class <class> is a
statement block:
CLASS <class> DEFINITION.
...
ENDCLASS.
It contains the declaration for all components (attributes, methods, events) of
the class. When you define local classes, the declaration part belongs to the gl
obal program data. You should therefore place it at the beginning of the program
.
If you declare methods in the declaration part of a class, you must also write a
n implementation part for it. This consists of a further statement block:
CLASS <class> IMPLEMENTATION.
...
ENDCLASS.
The implementation part of a class contains the implementation of all methods of
the class. The implementation part of a local class is a processing block. Subs

equent coding that is not itself part of a processing block is therefore not acc
essible.
rt of a processing block is therefore not accessible.
What is a reference variable?
Objects can only be created and addressed using reference variables. Reference v
ariables allow you to create and address objects. Reference variables can be def
ined in classes, allowing you to access objects from within a class.
Ex.
...
CLASS lcl_vehicle DEFINITION.
PUBLIC SECTION.
PRIVATE SECTION.
ENDCLASS.
CLASS lcl_vehicle IMPLEMENTATION.
ENDCLASS.
DATA: r_vehicle1 TYPE REF TO lcl_vehicle,
r_vehicle2 TYPE REF TO lcl_vehilce.
START-OF_SELECTION.
rt of a processing block is therefore not accessible.
What is a reference variable?
Objects can only be created and addressed using reference variables. Reference v
ariables allow you to create and address objects. Reference variables can be def
ined in classes, allowing you to access objects from within a class.
Ex.
...
CLASS lcl_vehicle DEFINITION.
PUBLIC SECTION.
PRIVATE SECTION.
ENDCLASS.
CLASS lcl_vehicle IMPLEMENTATION.
ENDCLASS.
DATA: r_vehicle1 TYPE REF TO lcl_vehicle,
r_vehicle2 TYPE REF TO lcl_vehilce.
START-OF_SELECTION.
What are Abstract classes and an Abstract Method?
Abstract classes themselves cannot be instantiated (although their subclasses ca
n) References to abstract classes can refer to instances of subclasses. Abstract
(instance) methods are defined in the class, but not implemented. They must be
redefined in subclasses.
Abstract instance methods are used to specify particular interfaces for subclass
es, without having to immediately provide implementation for them. Abstract meth
ods need to be redefined and thereby implemented in the subclass (here you also
need to include the corresponding redefinition statement in the DEFINITION part
of the subclass).
Classes with at least one abstract method are themselves abstract.
Static methods and constructors cannot be abstract (they cannot be redefined).
Abstract method
Abstract instance methods are used to specify particular interfaces for subclass
es, without having to immediately provide implementation for them. Abstract meth
ods need to be redefined and thereby implemented in the subclass (here you also
need to include the corresponding redefinition statement in the DEFINITION part
of the subclass). Classes with at least one abstract method are themselves abstr
act. Static methods and constructors cannot be abstract (they cannot be redefine
d).

What is the difference between Abstract method and a Final method?


Abstract method
Abstract instance methods are used to specify particular interfaces for subclass
es, without having to immediately provide implementation for them. Abstract meth
ods need to be redefined and thereby implemented in the subclass (here you also
need to include the corresponding redefinition statement in the DEFINITION part
of the subclass). Classes with at least one abstract method are themselves abstr
act. Static methods and constructors cannot be abstract (they cannot be redefine
d).
Abstract (instance) methods are defined in the class, but not implemented
They must be redefined in subclasses.
CLASS lcl_vehicle DEFINITION ABSTRACT.
PUBLIC SECTION.
METHODS estimate_fuel_consumption ABSTRACT
IMPORTING ...
ENDCLASS.
Final method
Final classes cannot have subclasses.
Final methods cannot be redefined in subclasses.
A final class implicitly only contains final methods. In this case, you cannot e
nter FINAL explicitly for these methods. Methods cannot be both final and abstra
ct. Classes, on the other hand, that are both abstract and final can be useful:
Only static components can be used.
Final methods cannot be redefined in subclasses
CLASS lcl_bus DEFINITION INHERITING FROM lcl_vehicle.
PUBLIC SECTION.
METHODS estimate_number_of_free_seats FINAL.
ENDCLASS.
What is a super class? How can it be implemented?
A superclass is a generalization of its subclasses. The subclass in turn is a sp
ecialization of its superclasses.
CLASS lcl_vehicle DEFINITION.
PUBLIC SECTION.
METHODS estimate_fuel
IMPORTING im_distance TYPE ty_distance
RETURNING VALUE(re_fuel) TYPE ty_fuel.
ENDCLASS.
CLASS lcl_truck DEFINITION INHERITING FROM lcl_vehicle.
PUBLIC SECTION.
METHODS estimate_fuel REDEFINITION.
...
ENDCLASS.
CLASS lcl_truck IMPLEMENTATION.
METHOD estimate_fuel.
...
super->estimate_fuel(...)
ENDMETHOD.
ENDCLASS.
What is a Narrowing Cast? How can you implement it?
The assignment of a subclass instance to a reference variable of the type "refer
ence to superclass" is described as a narrowing cast, because you are switching
from a more detailed view to a one with less detail.
It can be implemented as follows.
After the narrowing cast, you can use the r_vehicle reference to access the comp
onents of the truck instance that were inherited from lcl_vehicle - obviously, i
n some cases with the limitations entailed by their visibility. You can no longe
r access the truck-specific part of the instance (get_cargo in the above example
) using the r_vehicle reference.
DATA: r_vehicle TYPE REF TO lcl_vehicle,

r_truck TYPE REF TO lcl_truck.


CREATE OBJECT r_truck.
* Narrowing Cast
r_vehicle = r_truck
Principle of Narrowing Cast
_r_truck_
_r_vehicle_
What is a Widening Cast?
The widening cast is, as with inheritance, the opposite of the narrowing cast: H
ere it is used to retrieve a class reference from an interface reference.
METHOD get_max_cargo.
DATA: r_vehicle TYPE REF TO lcl_vehicle,
r_truck TYPE REF TO lcl_truck.
LOOP AT vehicle_list INTO r_vehicle.
TRY.
r_truck ?= r_vehicle.
* put max cargo in variable re_cargo...
CATCH cx_sy_move_cast_error.
* react on that cast error
ENDTRY.
ENDLOOP.
What is a singleton?
If it is to be impossible to instantiate a class more than once (for example, be
cause it serves as a data administrator or data container), you can use the sing
leton concept. The class is defined with the addition CREATE PRIVATE and FINAL a
nd instantiated using its static constructor. A public static component could th
en make the reference to the class available to an external user.
DATA: r_single type ref to cl_singleton.
START-OF-SELECTION.
r_single = cl_singleton=>get_singleton( ).
What is a constructor?
Special method for creating objects with defined initial state, Only has IMPORTI
NG,
parameters and EXCEPTIONS, Is executed only once per instance.
Example of Constructor
CLASS my_class DEFINITION.
PUBLIC SECTION.
METHODS CONSTRUCTOR.
note constructor should be always declared in public.
ENDCLASS.
CLASS my_class IMPLEMENTATION.
METHODS CONSTRUCTOR.
write :/ this is constructor method .
ENDMETHOD.
What are the limitations of redefining a method?
Inherited methods can be redefined in subclasses Redefined methods must be re-im
plemented in subclasses. The signature of redefined methods cannot be changed St
atic methods cannot be redefined. In inheritance, static components are "shared"
: A class shares its non-private static attributes with all its subclasses. In A
BAP Objects, you can not only add new components, but also provide inherited met
hods with new implementations. This is known as redefinition. You can only redef
ine (public and protected) instance methods, other components (static methods, a
ttributes and so on) cannot be redefined. Changes to method parameters (signatur
e changes) are not possible.
ENDCLASS.
What are static components? What is a component selector ?
In inheritance, static components are "shared": A class shares its non-private s
tatic attributes with all its subclasses. => and -> are the component selectors
used to refer.
What are component instance?

A component instance is a running component that can be run in parallel with oth
er instances of the same component.
How is Encapsulation implemented in OOPs?
Encapsulation means that the implementation of an object is hidden from other co
mponents in the system, so that they cannot make assumptions about the internal
status of the object and therefore dependencies on specific implementations do n
ot arise.
What are interfaces? What are the advantages of interfaces?
Interfaces are the means of choice for describing external points of contact or
protocols, without linking them to a type of implementation. An extra layer is i
ntroduced between the client and the server to protect the client explicitly fro
m the server, thereby making the client independent. Interfaces enable you to wo
rk uniformly with different classes (providers/servers). In particular, they alw
ays ensure polymorphic behavior as they do not have their own implementation, bu
t instead allow the providers to carry it out. The definition of an interface is
always an abstraction: The user wants to handle various providers in the same w
ay and must therefore abstract concrete implementations to a description of the
services required to fulfill the task. You can also use interfaces to achieve mu
ltiple inheritance by defining the functionality to be inherited by a second cla
ss as an interface that the inheriting class then has to implement.
INTERFACE lif_partners.
METHODS: display_partner.
ENDINTERFACE.
CLASS lcl_rental DEFINITION.
PUBLIC SECTION.
INTERFACES lif_partners.
ENDCLASS.
CLASS lcl_rental IMPLEMENTATION.
METHOD lif_partners~display_partner.
* just call existing method that fits
display_attributes( ).
...
ENDMETHOD.
ENDCLASS.
What are BADIs? What are BADI filters?
BADI Business Add Ins are enhancements to the standard version of the code of SA
P.
Filter Badi- Business Add-Ins may be implemented on the basis of a filter value.
If an enhancement for country-specific versions is provided for in the standard
version, it is likely that different partners will want to implement this enhan
cement. The individual countries can create and activate their own implementatio
n.
How can an event be raised and handled?
Events link objects or classes more loosely than direct method calls do. Method
calls establish precisely when and in which statement sequence the method is cal
led. However, with events, the reaction of the object to the event is triggered
by the event itself. Events are most often used in GUI implementations. At the m
oment of implementation, a class defines its:
Instance events (using the EVENTS statement)
Static events (using the CLASS-EVENTS statement)
Classes or their instances that receive a message when an event is triggered at
runtime and want to react to this event define event handler methods.
Statement:
[CLASS-]METHODS <handler_method> FOR EVENT <event> OF <classname>.
These classes or their instances are registered to one or more events
at runtime.
Statement: SET HANDLER <handler_method> FOR <reference>. (for instance events)
SET HANDLER <handler_method>. (for static events)
A class or instance can trigger an event at runtime using the RAISE EVENT statem
ent.

What are Exceptions? How can an Exception be raised?


1.
Exceptions that occur in procedures (methods, function modules, or subro
utines) do not necessarily need to be handled there; they can be passed along to
the calling program.
2.
The calling program can then handle the exception itself or also pass it
along to its own caller, and so on.
3.
The highest levels to which an exception can be passed are processing bl
ocks without local data areas - that is, event blocks or dialog modules.
4.
The exceptions passed along by the called procedures must be dealt with
there, as must any exceptions raised within this processing block itself. Otherw
ise a runtime error occurs.
5.
To pass along an exception from a procedure, you generally use the RAISI
NG addition when defining the procedure interface. In methods of local classes a
nd subroutines, specify the RAISING addition directly when defining the procedur
e
(METHODS meth ...
RAISING cx_... cx_...,
FORM form ...
RAISING cx_... cx_...).
6.After RAISING, list the exception classes whose objects are to passed along.
7.In methods of global classes, the exception classes whose objects are to be pr
opagated are entered in the exception table of the method in the Class Builder.
Check the Exception Class field in this exception table.
8.Similarly, exceptions raised by function modules are passed along by being ent
ered in the Function Builder.
Ex.
the exception we have defined (zcx_wrong_planetype) is raised if the airplane ty
pe passed to the method get_technical_attributes is not stored in the table sapl
ane.
Here, however, the exception is only raised in the method get_technical_attribut
es, not handled there.
To pass the exception along to the caller of the method, we enter it after the R
AISING keyword.
Now, the caller - that is, the method display_attributes - handles the exception
. For this purpose, we have implemented a TRY-ENDTRY control structure in this m
ethod. The method get_technical_attributes is now called in the TRY block of thi
s control structure.
If the exception is raised in the method get_technical_attributes, the program c
ontinues by handling this exception. That is, the method get_technical_attribute
s is terminated and the appropriate CATCH block is processed within the caller.
Note in particular that the program no longer executes the WRITE statements ente
red in the TRY block after get_technical_attributes is called.
What are the types of Exception classes?
a. Global
b. Local Exceptions Class.
Where can a protected method be accessed?
Protected components Only visible within the class and its sub classes.
What is a signature of a method?
Methods have a parameter interface (called signature ) that enables them to rece
ive values when they are called and pass values back to the calling program.
In ABAP Objects, methods can have IMPORTING, EXPORTING, CHANGING, and RETURNING
parameters as well as exception parameters.
CLASS <classname> DEFINITION.
...
METHODS: <method_name>
[ IMPORTING <im_var> TYPE <type>
EXPORTING <ex_var> TYPE <type>
CHANGING <ch_var> TYPE <type>
RETURNING VALUE(<re_var>) TYPE <type>

EXCEPTIONS <exception>
RAISING <class_exception> ].
ENDCLASS.(signature of a method).
CLASS <classname> IMPLEMENTATION.
METHOD <method_name>.
...
ENDMETHOD.
ENDCLASS.
Syntax to find out if a reference variable is referring to an object?
CLASS lcl_vehicle DEFINITION.
PUBLIC SECTION.
...
PRIVATE SECTION.
...
ENDCLASS.
CLASS lcl_vehicle IMPLEMENTATION.
...
ENDCLASS.
DATA: r_vehicle1 TYPE REF TO lcl_vehicle,
r_vehicle2 TYPE REF TO lcl_vehilce.
START-OF_SELECTION.
. . . . . . . . . . . . . .
Explain syntax Definition Load .
CLASS CL_GUI_CFW DEFINITION LOAD.
To access the static methods of a class we define it with LOAD.
As in BADI we use the static methods of the Class which is been used in the BADI
.
so we define the class using the kewowrd LOAD.
DEFERRED
CLASS lcl_event_receiver DEFINITION DEFERRED.
1. It means "load all the definition of the class lcl_event_receiver". After thi
s statement, you can then access methods and attributes of lcl_event_receiver, e
ven though it may be defined considerably later in the class.
2. Definition deferred means that you can refer to objects in your program which
haven't yet been defined but will be later on in your code. You could have two
classes in an abap say and data elements / types in the first class refer to the
2nd class such as obj1 type ref to zclass2 definition deferred. The zclass2 def
inition will appear later in your abap.
3. If you don't put definition deferred then when you check the program it will
give a syntax error of zclass2 not found.
DELEGATION
In delegation, two objects are involved in handling a request: The recipient of
the request delegates the execution of the request to a delegate.
What is an alias in ABAP OOPS?
Within a class, attribute names, method names, event names, constant names, type
names and alias names all share the same namespace. In ABAP Objects, the same c
omponents can be defined in interfaces and in classes. This allows you to shift
part of the public point of contact of a class into an interface, even though th
e class is already in use; users will not notice the difference as long as you u
se alias names (see appendix) for the components that are now in the interface.
To simplify accessing interface methods you can work with alias names.
1. Alias names can only appear in the in the declaration part of a class or in t
he interface definition.
Example for an alias in the interface: ALIASES a1 FOR lif_interface~method1
2. An alias defined in this way can be directly addressed using r_ref->a1.
What is a Persistent Class? Explain.
To use the Persistence Service for objects, the classes of these objects must be
created as persistent classes in the Class Builder. The term persistent class d
oes not imply that a class is persistent. (As a template for objects, every clas

s is persistent). Rather, it means that the objects of that class and their stat
e are managed by the Persistence Service. For example, the objects of these clas
ses are instantiated in the ABAP program with a method of the Persistence Servic
e, which ensures that the initialization is correct (not with the usual CREATE O
BJECT statement). When the Class Builder creates a persistent class, it automati
cally generates an associated class, known as the class actor or class agent, wh
ose methods manage the objects of persistent classes. As well as their identity,
persistent classes can contain key attributes, which allow the Persistence Serv
ice to ensure that the content of each persistent object is unique.
What is a functional Method?
Methods that have a RETURNING parameter are described as functional methods. The
se methods cannot have EXPORTING or CHANGING parameters, but has many (or as few
) IMPORTING parameters and exceptions as required.
Functional methods can be used directly in various expressions:
1.
Logical expressions (IF, ELSEIF, WHILE, CHECK, WAIT)
2.
The CASE statement (CASE, WHEN)
3.
The LOOP statement
4.
Arithmetic expressions (COMPUTE)
5.
Bit expressions (COMPUTE)
6.
The MOVE statement.
Functional Method Example.
CLASS lcl_vehicle DEFINITION.
PUBLIC SECTION.
METHODS: get_average_fuel
IMPORTING im_distance TYPE s_distance,
im_fuel TYPE ty_fuel
RETURNING VALUE(re_fuel) TYPE ty_fuel,
ENDCLASS.
DATA: r_vehicle1 TYPE REF TO lcl_vehicle,
r_vehicle2 TYPE REF TO lcl_vehicle,
avg_fuel TYPE ty_fuel.
...
* example for short syntax in aritmet. operation
avg_fuel =
r_vehicle1->get_average_fuel( im_distance = 500 im_fuel = 50 )
+ r_vehicle2->get_average_fuel( im_distance = 600 im_fuel = 60 ).
What is a de-referenced variable? What is a garbage collector?
To go to an address before performing the operation a dereferenced variable is a
pointer to the variable, not the variable itself. A pointer can be re-assigned
any number of times while a reference cannot be reassigned after initialization.
Field symbols are similar to dereferenced pointers. Thus, you can only access t
he content of the data object to which the field symbol points. (That is, field
symbols use value semantics). If you want to access the content of the data obje
ct, you need to dereference the data reference first.
Example.
As soon as no more references point to an object, the Garbage Collector removes
it from the memory. The Garbage Collector is a system routine that automatically
deletes objects that can no longer be addressed from the main memory and releas
es the memory space they occupied.
Procedure how garbage collector works..
Independent references are references that have not been defined within a class.
What is a Framework?
Automation Controller
The automation controller is the central instance at the frontend. It administer
s all instances of custom controls.

The Automation Controller also contains a list of the events that a custom contr
ol can trigger. All communication between the controls at the frontend and the a
pplication program at the backend runs through the Automation Controller.
ABAP Objects Control Framework
The ABAP Objects Control Framework has a similar function at the backend to that
of the
Automation Controller at the frontend. All method calls from an application prog
ram to a custom control run through the Control Framework. In order to avoid eac
h method call establishing a separate connection to the frontend, the method cal
ls are buffered in the automation queue. The automation queue is not sent to the
frontend until you reach a synchronization point. Like the Automation Controlle
r, the Control Framework has a list of control events. This list also contains t
he corresponding handler methods that need to be called when the event occurs. T
he Control Framework also maintains a list of the control instances you have cre
ated. This list is the basis for the lifetime management of controls.
What is a Static Constructor? What are the advantages?
1.
The static constructor is a special static method in a class with the na
me class_constructor.
2.
It is executed precisely once per program.
3.
The static constructor of a class <classname> is called automatically wh
en the class is first accessed, but before any of the following actions are exec
uted:
4.
Creating an instance in the class using CREATE OBJECT <obj>, where <obj>
has the data type REF TO <classname>
5.
Addressing a static attribute using <classname>=><attribute>
6.
Calling a static attribute using CALL METHOD <classname>=><classmethod>
7.
Registering a static event handler method using SET HANDLER
<classname>=><handler_method> FOR <obj>
8. Registering an event handler method for a static event in class <classname>.
9. The static constructor cannot be called explicitly.
Advantages:
1.
For static constructors, unlike instance constructors, the static constr
uctor in the superclass is called automatically, that is the runtime system auto
matically ensures that the static constructors of all its superclasses have alre
ady been executed before the static constructor in a particular class is execute
d.
2.
For static constructors, unlike instance constructors, the static constr
uctor in the superclass is called automatically, that is the runtime system auto
matically ensures that the static constructors of all its superclasses have alre
ady been executed before the static constructor in a particular class is execute
d.
3.
the static constructor of the class creates exactly one instance of this
class, which points to the attribute . This object is part of the persistence s
ervice and its methods are used to manage the object of the persistent class.
What is Private Constructor? Limitations?
Private constructors are used to restrict the instantiation of object using 'new
' operator. This type of constructors are mainly used for creating singleton obj
ect.
Limitations:
1.
A private constructor is a special instance constructor. It is commonly
used in classes that contain static members only.
2.
If a class has one or more private constructors and no public constructo
rs, then other classes (except nested classes) are not allowed to create instanc
es of this class.
3.
An instance constructor will always run after a static constructor.
4.
Private constructors prevent a class from being explicitly instantiated
by callers.
Can a class be defined without a constructor?
Yes, class can be created without any constructor. Default constructor will be c
reated when we define a class without constructor.

What is a Friend class?


A class can provide friendship to other classes and interfaces (and hence all cl
asses that Implement the interface).
To do this you use the FRIENDS additions to the CLASS statement, in which all cl
asses and interfaces that are to be provided friendship are listed.
Friends are allowed to access the protected and private components of the class
providing the friendship and can always create instances of this class, regardle
ss of the CREATE addition to the CLASS statement.
In principle, providing friendship is one-sided: A class providing friendship is
not automatically a friend of its friends. If a class providing friendship want
s 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 comp
onent interface also become friends. Therefore, extreme caution is advised when
providing friendship. The higher up a friend is in the inheritance tree, the mor
e subclasses can access all components of a class providing friendship. 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 sub clas
ses.
Explain syntax type table of ref to .
DATA: waitlist_buffer TYPE TABLE OF REF TO cl_taw10_waitlist,
waitlist TYPE TABLE OF REF TO cl_taw10_customer.
Example:
DATA: r_vehicle TYPE REF TO lcl_vehicle,
itab TYPE TABLE OF REF TO lcl_vehicle.
CREATE OBJECT r_vehicle.
APPEND r_vehicle TO itab.
CREATE OBJECT r_vehicle.
APPEND r_vehicle TO itab.
(2) lcl_object
(3) lcl_object
LOOP AT itab INTO r_vehicle.
* work with the current instance
ENDLOOP.
If you want to keep several objects from the same class in your program, you can
define an internal table, which, for example, only consist of one column contai
ning the object references for this class. You can process the objects using a L
OOP through the internal table.
What are RTTI classes?
RTTS (RunTime Type Services) allows to get the definition of variables or to cre
ate them during program execution. RTTS is made of 2 components:
1.
RTTI (RunTime Type Identification) is used to get the definition of exis
ting variables or existing types
2.
RTTC (RunTime Type Creation) is used to create new variables with any de
finition; they must be followed by the ABAP statement CREATE DATA ... TYPE HANDL
E ... to create the variable.
Can I pass an internal table through IMPORTING parameter of a method?
Yes.
Structure of a local class definition?
Local classes are only visible in the program they were defined in.
No global access possible.
Not stored in the Repository, no where-used list, and so on.
Local classes and interfaces are only known within the program in which they are
defined and implemented.
Local classes and interfaces are not stored in the Repository (no TADIR entry).
There is no "global" access to these classes or interfaces (for example, from ot
her programs).
What is MVC?
Model View Controller, is widely used in the user interface programming field an
d which has proved its worth, as an extension of the previous BSP implementation

model. Its controller-based use ensures an even clearer distinction between ap


plication logic and presentation logic in BSP applications. You can structure gr
aphical user interfaces clearly and organize them in logical units, even with co
mplex applications.
Using the MVC design pattern has the following advantages:
?
Structuring BSP applications is simplified, since the view is cleanly sep
arated from the controller and the model. This not only facilitates changing BS
P applications, but also considerably improves their maintenance.
?
You have the option of generating program-driven layout. The HTML/XML out
put is therefore created by program code instead of a page with scripting.
?
Navigation using the <bsp:goto> element and call using the <bsp:call> ele
ment. The advantage of using <bsp:goto> navigation over redirect is that there i
s no additional network traffic. Furthermore, you remain in the same work proces
s, which can have advantages for creating objects and memory space. The call usi
ng <bsp:call> element is more variable than adding them using INCLUDE directive,
since it is triggered at runtime.
With the call option using <bsp:call>, you can also distribute the user interfac
e into components.
?
Optimized performance due to fewer redirects.
?
Intuitive and easy-to-use interface for application development.

You might also like