0% found this document useful (0 votes)
263 views3 pages

Abap Objects - Abap 7.40

For ABAP Objects in Release 7.40, there are two improvements: 1) Functional methods can now have exporting and changing parameters in addition to importing and returning parameters. 2) Test classes implementing interfaces can now use the keyword PARTIALLY IMPLEMENTED to avoid implementing all interface methods, which simplifies creating test doubles.

Uploaded by

GouravJena
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
263 views3 pages

Abap Objects - Abap 7.40

For ABAP Objects in Release 7.40, there are two improvements: 1) Functional methods can now have exporting and changing parameters in addition to importing and returning parameters. 2) Test classes implementing interfaces can now use the keyword PARTIALLY IMPLEMENTED to avoid implementing all interface methods, which simplifies creating test doubles.

Uploaded by

GouravJena
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

For ABAP Objects itself - meaning the statements for dealing with classes and objects in ABAP there

are two small but nice improvements in Release 7.40.

Parameter Interface of Functional Methods


Before Release 7.40 a functional method could have only importing parameters besides its
returning parameter.
A functional method can now have exporting and changing parameters besides its returning
parameter.
In functional method calls you can use the additions EXPORTING, IMPORTING,
and CHANGING to pass parameters.

Example
The following kind of functional method declaration and invocation was not possible before
Release 7.40.
CLASS class DEFINITION.
PUBLIC SECTION.
CLASS-METHODS do_something IMPORTING p1 TYPE i
p2 TYPE i
EXPORTING p3 TYPE i
p4 TYPE i
RETURNING VALUE(r) TYPE i.
ENDCLASS.
...
IF

class=>do_something( EXPORTING p1 = 333


p2 = 444
IMPORTING p3 = a1
p4 = a2 ) = 0.
"work with a1, a2

ENDIF.

Interfaces in Test Classes


You know that you have to implement all the methods of each interface that you include in your
classes with theINTERFACES statement.While this is OK for normal classes, since the user
expects the interfaces to be implemented, it can be become rather tedious in test classes of
ABAP Unit. Especially when creating test doubles by implementing interfaces in test classes it is
cumbersome to implement (sometimes many, many ) empty interface methods that are not
needed for testing. And since empty method implementations are reported by the extended
program check, you even have to add a pragma ##needed to each of those!
Fortunately, there is now a new addition PARTIALLY IMPLEMENTED to the
statement INTERFACES that can be used in test classes and makes an end to these problems
(don't tell me that you don't have such problems since you are not testing ...).

Example
The following example is an excerpt from an test include of a http-handler class. Since a httphandler normally works with objects like request or response of the ICF-framework, for
standalone testing you have to create appropriate test doubles (mock framework) by
implementing the according interfaces. In the case shown here, a class for a mock request is
created by implementing if_http_request. Before Release 7.40 this was rather awkward,
since you had to implement all of the about 50 interface methods! In Release 7.40 you have to
implement only those that are needed for testing.
Before Release 7.40
CLASS mock_request DEFINITION FOR TESTING FINAL.
PUBLIC SECTION.
INTERFACES if_http_request.
ENDCLASS.
CLASS mock_request IMPLEMENTATION.
METHOD if_http_request~get_form_field.
value = SWITCH spfli-carrid( name WHEN 'carrid' THEN 'LH'

ELSE space ).
ENDMETHOD.
METHOD if_http_entity~set_cdata.

ENDMETHOD.

METHOD if_http_entity~set_data.

"##needed

ENDMETHOD.

"##needed

METHOD if_http_entity~add_multipart. ENDMETHOD.

"##needed

METHOD if_http_entity~append_cdate.

"##needed

ENDMETHOD.

...

ENDCLASS.

Release 7.40
CLASS mock_request DEFINITION FOR TESTING FINAL.
PUBLIC SECTION.
INTERFACES if_http_request PARTIALLY IMPLEMENTED.
ENDCLASS.
CLASS mock_request IMPLEMENTATION.
METHOD if_http_request~get_form_field.
value = SWITCH spfli-carrid( name WHEN 'carrid' THEN 'LH'
ELSE space ).
ENDMETHOD.
ENDCLASS.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy