sapdev logo background
sapdev logo sapdev logo
Comments

SAP NEWS-610-OBJECTS documentation, setup help and example usage



Return to SAP documentation index



ABAP Objects in Release 6.10

1 Dynamic access : Dynamic access to object attributes
2 CALL METHOD optional when calling methods
3 Friends - friendship between classes
4 New additions for implementing interfaces
5 Pass by parameter in dynamic instantiations
6 OO transactions
7 Enhanced syntax for interfaces
8 Enhanced syntax for event handling
9 Enhanced syntax in the instance constructor of subclasses
10 Dynamic access to interface constants


ABAP_MODIFICATION_1 Dynamic Access : Dynamic Access to Object Attributes

The following variants of the statement ASSIGN make it possible to access the attributes of classes dynamically:
assign oref- (f) to fs .
assign iref- (f) to fs .
assign (f1)= (f2) to fs .
assign c= (f) to fs .
assign (f)= f to fs .
The attribute search is first carried out for the static type. If the search was unsuccessful or the attributes are not visible in the context, then the system performs a search for the dynamic type.


ABAP_MODIFICATION_2 CALL METHOD Optional when Calling Methods

In static method calls of the form
CALL METHOD meth( ) , the CALL METHOD expression is optional. It is sufficient to simply write meth( ) .


ABAP_MODIFICATION_3 Friends - Friendship Between Classes

The Friends concept means that a class can offer friendship to other classes or interfaces ( GLOBAL FRIENDS and LOCAL FRIENDS are possible here). These friends can then access all the components of the provider class, and can always instantiate the class. The
PROTECTED and PRIVATE components always become PUBLIC for friends. Classes offer friendship to other classes or interfaces using the addition FRIENDS of the statement
CLASS ... DEFINITION . The new concept makes the previous language construction DATA TYPE REF TO class %_friend obsolete.


ABAP_MODIFICATION_4 New Additions for Implementing Interfaces

The statement INTERFACES has the new additions ABSTRACT | FINAL METHODS and ALL METHODS ABSTRACT | FINAL , which make it possible to make methods in the implementing class abstract or final. DATA VALUES is another new addition. It assigns start values to interface attributes when implemented in a class.


ABAP_MODIFICATION_5 Pass by Parameter in Dynamic Instantiations

Parameters can now be passed and classic exceptions handled in the dynamic variant CREATE OBJECT (class) .


ABAP_MODIFICATION_6 OO Transactions

When defining transactions , a transaction code can be classified as an OO transaction. The transaction code is then associated with a global or local class of a program, either using the transaction service of ABAP - Object Services for persistent objects, or using any method. When this type of transaction is called, the system loads the program associated with the class, generates an object for instance methods, and executes the method.


ABAP_MODIFICATION_7 Enhanced Syntax for Interfaces

All the component interfaces of a compound interface are treated equally in the interface and in the implementing class. This means that the components of inner interfaces can be accessed directly using interface references. Previously, this was only possible using class reference variables.

INTERFACE i1.
DATA a1.
ENDINTERFACE.

INTERFACE i2.
INTERFACES i1.
DATA a2 LIKE i1~a1.
ENDINTERFACE.

DATA iref TYPE REF TO i2.

WRITE iref->i1~a1.

In previous releases, this example would have caused a syntax error with the expressions containing i1~a1 and it would have been necessary to use aliases. In Release 6.10, however, the interface component selector (~) should only be used outside classes or interfaces in exceptional circumstances.


ABAP_MODIFICATION_8 Enhanced Syntax for Event Handling

In the statement SET HANDLER , the system now checks the precise type of the reference variable that points to a triggering object. The type must be of the same class or subclass as the one listed in the declaration of
event handlers as METHODS after FOR EVENT evt OF . This means objects of superclasses cannot be registered, even if the event was inherited from a superclass. If an interface has been declared after FOR EVENT evt OF , the type of the reference variable must either be the interface itself, a class/subclass that implements the interface, or another interface that contains the interface as a component.

From Release 6.10 onwards, the type of the implicit event parameter
sender (which can be imported by a handler method and passed using RAISE EVENT ) is determined using the class/interface specified in the declaration of the event handler (after the addition FOR EVENT OF of the statement
METHODS ). In previous releases, the type was determined by the class/interface where the event was declared using
EVENTS .


ABAP_MODIFICATION_9 Enhanced Syntax in the Instance Constructor of Subclasses

In the instance constructor of subclasses, the constructor of the superclass must always be called using [CALL METHOD] super- constructor , even if this superclass was not explicitly defined there. Direct subclasses of the root class OBJECT are the only exception. This means instance constructors can be implemented in superclasses retroactively, without invalidating the subclasses. If the superclass constructor is not called, the following program produces a syntax warning in Release 6.10 and higher.
CLASS c1 DEFINITION INHERITING FROM object.
PUBLIC SECTION.
...
ENDCLASS.

CLASS c1 IMPLEMENTATION.
...
ENDCLASS.

CLASS c2 DEFINITION INHERITING FROM c1.
PUBLIC SECTION.
METHODS constructor.
ENDCLASS.

CLASS c2 IMPLEMENTATION.
METHOD constructor.
...
super->constructor( )
...
ENDMETHOD.
ENDCLASS.


ABAP_MODIFICATION_10 Dynamic Access to Interface Constants

Interface constants can now be accessed dynamically using
INTF= KONST . To make this possible, the logic for dynamic ASSIGN
, dynamic access , and dynamic invoke was changed so that global classes are now obscured by local types or interfaces. In previous releases, if constants were accessed using CLASS= ATTR , the system only searched for class names.
Documentation extract taken from SAP system, � Copyright SAP AG. All rights reserved




NEWS-610-LISTEN
NEWS-610-OBJECT_SERVICES




comments powered by Disqus