Escolar Documentos
Profissional Documentos
Cultura Documentos
40
Horst Keller, TIP Core ABAP Platform & VM Tech, SAP AG
Disclaimer
This presentation outlines our general product direction and should not be relied on in making a
purchase decision. This presentation is not subject to your license agreement or any other agreement
with SAP. SAP has no obligation to pursue any course of business outlined in this presentation or to
develop or release any functionality mentioned in this presentation. This presentation and SAP's
strategy and possible future developments are subject to change and may be changed by SAP at any
time for any reason without notice. This document is provided without a warranty of any kind, either
express or implied, including but not limited to, the implied warranties of merchantability, fitness for a
particular purpose, or non-infringement. SAP assumes no responsibility for errors or omissions in this
document, except if such damages were caused by SAP intentionally or grossly negligent.
Objectives
At the end of this presentation, you will be able to:
Name key features of ABAP language for Release 7.40
Perform development tasks with the new ABAP features
Agenda
ABAP Language in Releases
Important ABAP Language News in AS ABAP 7.40
ABAP Releases
ABAP Language and ABAP Runtime Environment as seen by sy-saprl
ABAP 7.40
ABAP 7.03/7.31
ABAP 7.3
ABAP 7.02
ABAP 7.2
AS ABAP for NGAP
ABAP 7.01
ABAP 7.1/7.11
ABAP 7.0
ABAP 8.0x
Development
No development
Backport
Agenda
ABAP Language in Releases
Important ABAP Language News in AS ABAP 7.40
ABAP Objects
Internal Tables
Database Access
External Interfaces
Documentation
Further News
Expressions
Inline Declarations
Inline Declarations
... DATA(var) ...
... FIELD-SYMBOL(<fs>) ...
The new declaration operators DATA and FIELD-SYMBOL allow inline declarations of variables and field
symbols with declaration expressions in declaration positions.
Declaration positions are write positions where the operand type can be determined from the context
statically.
Expressions
Inline Declarations DATA( )
Examples for Declaration Positions for Inline Declaration DATA(var)
LOOP AT itab INTO DATA(wa).
...
ENDLOOP.
READ TABLE itab INTO DATA(wa) ...
and many
more!
10
Expressions
Inline Declarations DATA( )
Example for Usage
DATA ixml
TYPE REF TO if_ixml.
DATA stream_factory TYPE REF TO if_ixml_stream_factory.
DATA document
TYPE REF TO if_ixml_document.
ixml
= cl_ixml=>create( ).
stream_factory = ixml->create_stream_factory( ).
document
= ixml->create_document( ).
DATA(ixml)
= cl_ixml=>create( ).
DATA(stream_factory) = ixml->create_stream_factory( ).
DATA(document)
= ixml->create_document( ).
11
Expressions
Inline Declarations FIELD-SYMBOL( )
Declaration Positions for Inline Declaration FIELD-SYMBOL(<fs>)
ASSIGN ... TO FIELD-SYMBOL(<fs>).
12
Expressions
Inline Declarations FIELD-SYMBOL( )
Example for Usage
FIELD-SYMBOLS <line> LIKE LINE OF itab.
LOOP AT itab ASSIGNING <line>.
...
ENDLOOP.
13
Expressions
Constructor Expressions
Constructor Expressions
... NEW|VALUE|REF|EXACT|CONV|CAST|COND|SWITCH type( ... ) ...
The new constructor operators
14
Expressions
Constructor Expressions NEW( )
Instance Operator NEW
15
Expressions
Constructor Expressions VALUE( )
Value Operator VALUE
DATA itab
DATA wa
wa-col1 =
APPEND wa
wa-col1 =
APPEND wa
TYPE t_itab.
LIKE LINE OF itab.
1. wa-col2 = 2.
TO itab.
3. wa-col2 = 4.
TO itab.
meth( itab ).
meth( VALUE t_itab(
( col1 = 1 col2 = 2 )
( col1 = 3 col2 = 4 ) ) ).
16
Expressions
Constructor Expressions REF( )
Reference Operator REF
DATA dref TYPE REF TO string.
GET REFERENCE OF para INTO dref.
DATA(ptab) =
VALUE abap_parmbind_tab(
( name = name
kind = cl_abap_objectdescr=>exporting
value = dref ) ).
DATA(ptab) =
CALL METHOD (class)=>(meth) PARAMETER-TABLE
ptab.
VALUE abap_parmbind_tab(
( name = name
kind = cl_abap_objectdescr=>exporting
value = REF #( para ) ) ).
CALL METHOD (class)=>(meth) PARAMETER-TABLE ptab.
2013 SAP AG. All rights reserved.
17
Expressions
Constructor Expressions EXACT( )
Lossless Operator EXACT
TYPES numtext TYPE n LENGTH 255.
DATA number TYPE numtext.
TRY.
MOVE EXACT '4 Apples + 3 Oranges' TO number.
CATCH cx_sy_conversion_error INTO DATA(exc).
...
ENDTRY.
TYPES numtext TYPE n LENGTH 255.
TRY.
DATA(number) = EXACT numtext( '4 Apples + 3 Oranges' ).
CATCH cx_sy_conversion_error INTO DATA(exc).
...
ENDTRY.
same for
COMPUTE
2013 SAP AG. All rights reserved.
18
Expressions
Constructor Expressions CONV( )
Conversion Operator CONV
IF 1 / 3 > 0.
...
ENDIF.
IF ' ' = ` `.
...
ENDIF.
2013 SAP AG. All rights reserved.
19
Expressions
Constructor Expressions CAST( )
Casting Operator CAST
DATA structdescr TYPE REF TO cl_abap_structdescr.
structdescr ?= cl_abap_typedescr=>describe_by_name( 'T100' ).
DATA(components) = structdescr->components.
DATA(components) =
CAST cl_abap_structdescr(
cl_abap_typedescr=>describe_by_name( 'T100' )
)->components.
20
Expressions
Constructor Expressions COND( )
Conditional Operator COND
DATA time TYPE string.
IF sy-timlo < '120000'.
time = |{ sy-timlo TIME = ISO } AM|.
ELSEIF sy-timlo > '120000'.
time = |{ CONV t( sy-timlo - 12 * 3600 )
TIME = ISO } PM|.
DATA(time) =
ELSEIF sy-timlo = '120000'.
COND string(
time = |High Noon|.
WHEN sy-timlo < '120000' THEN
ELSE.
|{ sy-timlo TIME = ISO } AM|
RAISE EXCEPTION TYPE cx_cant_be.
WHEN sy-timlo > '120000' THEN
ENDIF.
|{ CONV t( sy-timlo - 12 * 3600 )
TIME = ISO } PM|
WHEN sy-timlo = '120000' THEN
|High Noon|
ELSE
THROW cx_cant_be( ) ).
2013 SAP AG. All rights reserved.
21
Expressions
Constructor Expressions SWITCH( )
Conditional Operator SWITCH
DATA number TYPE string.
CASE sy-index.
WHEN 1.
number = 'one'.
WHEN 2.
number = 'two'.
WHEN 3.
number = 'three'.
WHEN OTHERS.
RAISE EXCEPTION TYPE cx_overflow.
ENDCASE.
DATA(number) =
SWITCH string( sy-index
WHEN 1 THEN 'one'
WHEN 2 THEN 'two'
WHEN 3 THEN 'three'
ELSE THROW cx_overflow( ) ).
22
Expressions
Table Expressions
Table Expressions
... itab[ ... ] ...
The new table expressions itab[ ] enable read access to internal tables at operand positions.
The operand positions can be read positions and also some write positions
Table expressions are LHS-expressions
23
Expressions
Table Expressions table line
Line Specification
READ TABLE itab INDEX idx INTO wa.
wa = itab[ idx ].
24
Expressions
Table Expressions result
Controlling the Intermediate Result
READ TABLE ... ASSIGNING ...
25
Expressions
Table Expressions chaining
... itab[ ... ]-comp ...
... struct-comp[ ... ] ...
... itab[ ... ][ ... ] ...
11
12
13
14
15
16
17
18
10
26
Expressions
Miscellaneous
Many new expression enabled positions ...
Some new formatting options for string templates ...
New built-in function ipow:
cl_demo_output=>display( |** : { '1.2' ** 2 } \n| &&
|ipow: { ipow( base = '1.2' exp = 2 ) }| ).
27
Expressions
ABAP is Extensively Expression Enabled
Skip Old Fashioned Style!
LHS = RHS.
28
29
ABAP Objects
Functional Methods
Parameter Interface of Functional Methods
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.
CLASS-METHODS do_something
IMPORTING p1 TYPE ...
p2 TYPE ...
EXPORTING p3 TYPE ...
p4 TYPE ...
CHANGING p5 TYPE ...
p6 TYPE ...
RETURNING VALUE(r) TYPE ...
result = class=>do_something(
EXPORTING p1 = ...
p2 = ...
IMPORTING p3 = ...
p4 = ...
CHANGING p5 = ...
p6 = ... ).
30
ABAP Objects
Interfaces in Test Classes
Partially Implemented
INTERFACES intf PARTIALLY IMPLEMENTED.
Only parts of interfaces must be implemented in test classes. Useful in test doubles.
CLASS mock_request DEFINITION FOR TESTING FINAL.
PUBLIC SECTION.
INTERFACES if_http_request PARTIALLY IMPLEMENTED.
ENDCLASS.
31
Database Access
External Interfaces
Documentation
Further News
32
Internal Tables
Assignments
MOVE-CORRESPONDING for Internal Tables
MOVE-CORRESPONDING itab1 TO itab2.
[EXPANDING NESTED TABLES] [KEEPING TARGET LINES].
itab1 = VALUE
( col1 =
col2 =
col3 =
( col1 =
col2 =
col3 =
( col1 =
col2 =
col3 =
#(
'a11'
'a12'
itab2 #(
= VALUE
VALUE
( col1#(= 'a11' col2 = 'a12' )
( col2
= 'x11'
( col1
= 'a21' col2 = 'a22' ) ) )
'b21' col3 = VALUE #( ( col2 = 'x11' col3 = 'x12' )
( col2 = 'x21' col3 = 'x22' )
'b22'
constructor
col2 == 'b12'
'x31' ) col3
= 'x32' ) ) operator
VALUE #( ( col1 = 'b11' ( col2
( col1 = 'b21' col2 = 'b22'CORRESPONDING
) ) )
type( ... )
'c31' col4 = 'x12' )
coming soon!
'c32' ( col2 = 'y21'
= VALUE
#(
( col2
col2 == 'c12'
'y11' ) col3
= TO
'y12'
)
VALUE #(col3
( col1
= 'c11'
MOVE-CORRESPONDING
itab1
itab2.
( col2
col2 == 'c22'
'y21' ) col3
= TO
'y22'
) KEEPING TARGET LINES.
( col1 = 'c21'
)itab1
) ).
MOVE-CORRESPONDING
itab2
( col2 = 'y31' col3
= TO
'y32'
) )EXPANDING NESTED TABLES.
MOVE-CORRESPONDING
itab1
itab2
col4 = 'y22' )MOVE-CORRESPONDING
).
itab1 TO itab2 EXPANDING NESTED TABLES
KEEPING TARGET LINES.
33
Internal Tables
Built-in Functions
Two new Built-in Functions for Internal Tables
... line_index( ... ) ...
... line_exists( ... ) ...
DATA(idx) =
line_index( itab[ ... ] ).
34
Internal Tables
Empty Key
Explicit Declaration of Empty Table Key
... WITH EMPTY KEY ...
35
External Interfaces
Documentation
Further News
36
Database Access
SAP HANA Views
SE11
External Views
ABAP
HANA Studio
ADT
2013 SAP AG. All rights reserved.
37
Database Access
SAP HANA SQLScript Procedures
Calling SQLScript Procedures using Database Procedure Proxies
DATA: in TYPE if_dbproc_proxy=>in,
out TYPE if_dbproc_proxy=>out.
CALL DATABASE PROCEDURE dbproc_proxy EXPORTING in = in
IMPORTING out = out.
INTERFACE if_dbproc_proxy PUBLIC.
TYPES: in TYPE ...,
out TYPE ...
ENDINTERFACE.
ABAP Dictionary
2013 SAP AG. All rights reserved.
out
Mapping
Input
Output
ADT
Input
API
Output
/* SQLScript */
BEGIN
...
END;
Database
38
Database Access
ABAP Managed Database Procedures
Outlook: AMDP
ABAP Managed
Code Pushdown!
ABAP Class
Input
Output
/* SQLScript */
BEGIN
...
END;
Database
39
Database Access
Open SQL
Renovation of Open SQL Compiler Infrastructure
40
Database Access
Native SQL
Bulk Access with ADBC
New
41
Documentation
Further News
42
External Interfaces
ABAP and JSON
JSON Support in sXML-Library
Backported to
7.02!
JSON - JavaScript Object Notation, data format in text form for data exchange.
JSON-XML - SAP-specific representation of JSON data in XML format
43
External Interfaces
ABAP and JSON Readers and Writers
JSON to JSON-XML and Vice Versa
DATA(json) = cl_abap_codepage=>convert_to( `{"TEXT":"JSON"}` ).
DATA(json_reader) = cl_sxml_string_reader=>create( json ).
DATA(xml_writer) = cl_sxml_string_writer=>create( ).
json_reader->next_node( ).
json_reader->skip_node( xml_writer ).
cl_demo_output=>display_xml( xml_writer->get_output( ) ).
DATA(xml) = cl_abap_codepage=>convert_to(
`<object><str name="TEXT">JSON</str></object>` ).
DATA(xml_reader) = cl_sxml_string_reader=>create( xml ).
DATA(json_writer) = cl_sxml_string_writer=>create( type = if_sxml=>co_xt_json ).
xml_reader->next_node( ).
xml_reader->skip_node( json_writer ).
cl_demo_output=>display_json( json_writer->get_output( ) ).
44
External Interfaces
ABAP and JSON Transformation ID
JSON to JSON-XML and Vice Versa
DATA(json) = `{"TEXT":"JSON"}`.
CALL TRANSFORMATION id SOURCE XML json
RESULT XML DATA(xml).
cl_demo_output=>display_xml( xml ).
45
External Interfaces
ABAP and JSON asJSON
ABAP to JSON and Vice Versa
DATA(text) = `JSON`.
DATA(json_writer) = cl_sxml_string_writer=>create( type = if_sxml=>co_xt_json ).
CALL TRANSFORMATION id SOURCE text = text
RESULT XML json_writer.
cl_demo_output=>display_json( json_writer->get_output( ) ).
DATA(json) = `{"TEXT":"JSON"}`.
DATA text TYPE string.
CALL TRANSFORMATION id SOURCE XML json
RESULT text = text.
cl_demo_output=>display( text ).
46
External Interfaces
ABAP Channels - AMC
ABAP Messaging Channels and ABAP Push Channels
A
P
C
AS ABAP Session
Application Server x
A
P
C
AMC
WebSocket Protocol
AS ABAP Session
Application Server y
47
External Interfaces
ABAP Channels - AMC
ABAP Messaging Channels
Enable message based communications between ABAP programs across the boundaries of application servers.
CAST if_amc_message_producer_text(
cl_amc_channel_manager=>create_message_producer(
i_application_id = 'DEMO_AMC'
i_channel_id
= '/demo_text' )
)->send( i_message = ... ).
cl_amc_channel_manager=>create_message_consumer(
i_application_id = 'DEMO_AMC'
i_channel_id
= '/demo_text'
)->start_message_delivery( i_receiver = receiver ).
WAIT FOR MESSAGING CHANNELS
UNTIL receiver->text_message IS NOT INITIAL
UP TO 60 SECONDS.
2013 SAP AG. All rights reserved.
48
External Interfaces
ABAP Channels APC, ABAP side
ABAP Push Channels
Enable bidirectional communications between ABAP programs and the
internet using the WebSocket protocol. APCs can be connected to AMCs.
METHOD if_apc_ws_extension~on_start.
...
IF amc_flag = abap_true.
TRY.
i_context->get_binding_manager(
)->bind_amc_message_consumer(
i_application_id = 'DEMO_AMC'
i_channel_id
= '/demo_text' ).
CATCH cx_apc_error INTO DATA(exc).
MESSAGE exc->get_text( ) TYPE 'X'.
ENDTRY.
ELSE.
"Default behavior
ENDIF.
ENDMETHOD.
METHOD if_apc_ws_extension~on_message.
...
IF amc_flag = abap_true.
CAST if_amc_message_producer_text(
cl_amc_channel_manager=>create_message_producer(
i_application_id = 'DEMO_AMC'
i_channel_id
= '/demo_text' )
)->send( i_message = ... ).
ELSE.
DATA(message_manager) =
i_message->get_context( )->get_message_manager( ).
DATA(message) = message_manager->create_message( ).
message->set_text( ... ).
message_manager->send( message ).
ENDIF.
49
External Interfaces
ABAP Channels APC, Internet side
50
Further News
51
Documentation
ABAP Doc for ADT
Inline Documentation of Source Code based Development Objects
F2
52
Documentation
ABAP Keyword Documentation in ADT
Permanent Input Field, Executable Examples
F1
53
54
Further News
Security Checks
SLIN_SEC
DATA name TYPE string.
DATA customers TYPE TABLE OF scustom WITH EMPTY KEY.
55
Further News
See ABAP Keyword Documentation
Classic
2013 SAP AG. All rights reserved.
ADT
ABAP News 7.40
56
Presentation Summary
You should now be able to:
Name key features of ABAP language for 7.40
Perform development tasks with the new ABAP features
57