Académique Documents
Professionnel Documents
Culture Documents
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.
Development
ABAP 7.0 No development
Backport
Agenda
Expressions
ABAP Objects
Internal Tables
Database Access
External Interfaces
Documentation
Further News
Agenda
Expressions
• Inline Declarations
• Constructor Expressions
• Table Expressions
ABAP Objects
Internal Tables
Database Access
External Interfaces
Documentation
Further News
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.
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( ).
Constructor Expressions
... NEW|VALUE|REF|EXACT|CONV|CAST|COND|SWITCH type( ... ) ...
DATA oref TYPE REF TO class. DATA oref TYPE REF TO class.
CREATE OBJECT oref EXPORTING ... oref = NEW #( ... ).
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 ) ) ).
DATA(components) =
CAST cl_abap_structdescr(
cl_abap_typedescr=>describe_by_name( 'T100' )
)->components.
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 …
READ TABLE itab INDEX idx wa = itab[ KEY key INDEX idx ].
USING KEY key INTO wa.
READ TABLE flights WITH TABLE KEY key wa = itab[ KEY key COMPONENTS
COMPONENTS col1 = ... col2 = ... col1 = ... col2 = ... ].
INTO wa.
Performance
considerations!
... VALUE type( itab[ ... ] ) ... READ TABLE ... INTO ...
... REF type( itab[ ... ] ) ... READ TABLE ... REFERENCE INTO ...
8 9
11 12
13 14
10 DATA(num) = itab[ 2 ]-col2[ 1 ][ 2 ]-col1.
15 16
17 18
Agenda
Expressions
ABAP Objects
Internal Tables
Database Access
External Interfaces
Documentation
Further News
Partially Implemented
INTERFACES intf PARTIALLY IMPLEMENTED.
Only parts of interfaces must be implemented in test classes. Useful in test doubles.
Agenda
Expressions
ABAP Objects
Internal Tables
• MOVE-CORRESPONDING
• Built-in Functions
• Empty Key
Database Access
External Interfaces
Documentation
Further News
itab1 = VALUE #(
( col1 = 'a11'
col2 = 'a12'
col3 = itab2 #(
VALUE = VALUE
( col1#(= 'a11' col2 = 'a12' )
( col2 = 'x11'
( col1 = 'a21' col2 = 'a22' ) ) )
( col1 = 'b21' col3 = VALUE #( ( col2 = 'x11' col3 = 'x12' )
col2 = 'b22' ( col2 = 'x21' col3 = 'x22' )
col3 = VALUE #( ( col1 = 'b11' ( col2
col2 == 'b12' … constructor
'x31' ) col3 = 'x32' ) ) operator
( col1 = 'b21' col2 = 'b22'CORRESPONDING
) ) ) type( ... )
( col1 = 'c31' col4 = 'x12' )
col2 = 'c32' ( col2 = 'y21' coming soon!
col3 = VALUE #(col3 = VALUE
( col1 #(
= 'c11' ( col2
col2 == 'c12'
'y11' ) col3
MOVE-CORRESPONDING = TO
itab1 'y12' )
itab2.
( col1 = 'c21' ( col2
col2 == 'c22'
'y21' ) col3
MOVE-CORRESPONDING = TO
)itab1
) ). 'y22' ) KEEPING TARGET LINES.
itab2
( col2 = 'y31' col3
MOVE-CORRESPONDING = TO
itab1 'y32' ) )EXPANDING NESTED TABLES.
itab2
col4 = 'y22' )MOVE-CORRESPONDING
). itab1 TO itab2 EXPANDING NESTED TABLES
KEEPING TARGET LINES.
READ TABLE itab WITH ... TRANSPORTING NO FIELDS. IF line_exists( itab[ ... ] ).
IF sy-subrc = 0. ...
... ENDIF.
ENDIF.
Agenda
Expressions
ABAP Objects
Internal Tables
Database Access
• HANA
• Open SQL
• Native SQL
External Interfaces
Documentation
Further News
ABAP
HANA Studio
ADT
© 2013 SAP AG. All rights reserved. ABAP News 7.40 37
Database Access
SAP HANA SQLScript Procedures
Calling SQLScript Procedures using Database Procedure Proxies
ABAP Class
/* SQLScript */
Input BEGIN
...
Output END;
Database
New
Agenda
Expressions
ABAP Objects
Internal Tables
Database Access
External Interfaces
• JSON
• ABAP Channels
Documentation
Further News
Backported to
7.02!
JSON - JavaScript Object Notation, data format in text form for data exchange.
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( ) ).
DATA(json) = `{"TEXT":"JSON"}`.
CALL TRANSFORMATION id SOURCE XML json
RESULT XML DATA(xml).
cl_demo_output=>display_xml( xml ).
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 ).
A A
WebSocket Protocol
P P
C C
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.
Agenda
Expressions
ABAP Objects
Internal Tables
Database Access
External Interfaces
Documentation
• ABAP Doc
• ABAP Keyword Documentation
Further News
F2
F1
Agenda
Expressions
ABAP Objects
Internal Tables
Database Access
External Interfaces
Documentation
Further News
DATA(cond) = `country = 'DE' AND name = '` && name && `'`.
TRY.
SELECT * FROM scustom
INTO TABLE customers
WHERE (cond).
cl_demo_output=>display( customers ).
CATCH cx_sy_dynamic_osql_syntax.
cl_demo_output=>display( 'Wrong input' ).
ENDTRY.
Classic ADT
© 2013 SAP AG. All rights reserved. ABAP News 7.40 56
Presentation Summary