ABAP Finding Appropriate Abstractions for Business Application Programming Horst Keller, SAP AG Tobias Wenner, SAP AG
ABAP Finding Appropriate Abstractions for Business Application Programming Business Application Programming ABAP Runtime Environment ABAP Essential Concepts at one Glance ABAP Development ABAP Strong Points Conclusion SAP 2011 / ABAP Introduction and Overview / Horst Keller, Tobias Wenner / SAP AG / Page 2
ABAP Finding Appropriate Abstractions for Business Application Programming Business Application Programming ABAP Runtime Environment ABAP Essential Concepts at one Glance ABAP Development ABAP Strong Points Conclusion SAP 2011 / ABAP Introduction and Overview / Horst Keller, Tobias Wenner / SAP AG / Page 3
Business Application Programming Big Picture Presentation Layer UI App Server 1 App Server 2 Application Layer Application Programs Application Programs Persistence Layer Data in Tables of a Central Relational Database SAP 2011 / ABAP Introduction and Overview / Horst Keller, Tobias Wenner / SAP AG / Page 4
Business Application Programming The ABAP Way Presentation Layer UI Application Layer ABAP Programs ABAP Runtime Environment Persistence Layer Data in Tables of a Central Relational Database SAP 2011 / ABAP Introduction and Overview / Horst Keller, Tobias Wenner / SAP AG / Page 5
ABAP Finding Appropriate Abstractions for Business Application Programming Business Application Programming ABAP Runtime Environment ABAP Essential Concepts at one Glance ABAP Development ABAP Strong Points Conclusion SAP 2011 / ABAP Introduction and Overview / Horst Keller, Tobias Wenner / SAP AG / Page 6
Business Application Programming The ABAP Runtime Environment SAP GUI, HTTP(S) ABAP Program ABAP Runtime Environment Hardware-, operating-system-, and database-independent platform (virtual machine) that provides Interfaces Server Management (Memory, Process, Task Handling) Text Environment Locking and Transaction Services for ABAP programs. Native Database Commands SAP 2011 / ABAP Introduction and Overview / Horst Keller, Tobias Wenner / SAP AG / Page 7
ABAP Runtime Environment Past to Present Classical ABAP - Reporting Classical Lists (Screen/Spool) REPORT abap_intro_classic_report. TABLES flight_plan. ULINE. SELECT * FROM flight_plan. SAP Basis R/3-System Report Program WRITE: flight_plan-carrid,, flight_plan-connid,, flight_plan-cityfrom,, flight_plan-cityto,. ULINE. ENDSELECT. ABAP Allgemeiner Berichts Aufbereitungs Prozessor SAP 2011 / ABAP Introduction and Overview / Horst Keller, Tobias Wenner / SAP AG / Page 8
ABAP Runtime Environment Past to Present Modern ABAP ABAP Objects PROGRAM modern_abap_example. CLASS flight_app. Services Application METHOD get_flights.... ENDMETHOD. METHOD book_flight.... ENDMETHOD. ENDCLASS. Services ABAP Advanced Business Application Programming SAP 2011 / ABAP Introduction and Overview / Horst Keller, Tobias Wenner / SAP AG / Page 9
ABAP Finding Appropriate Abstractions for Business Application Programming Business Application Programming ABAP Runtime Environment ABAP Essential Concepts at one Glance ABAP Development ABAP Strong Points Conclusion SAP 2011 / ABAP Introduction and Overview / Horst Keller, Tobias Wenner / SAP AG / Page 10
ABAP Language ABAP Essential Concepts at one Glance, Part 1 PROGRAM abap_intro_essentials. Exception Class CLASS cx_no_flights DEFINITION INHERITING FROM cx_static_check. ENDCLASS. Class Definition CLASS get_and_display_flights DEFINITION. PUBLIC SECTION. CLASS-METHODS main. PRIVATE SECTION. TYPES carrid_t TYPE int4. CLASS-DATA self TYPE REF TO get_and_display_flights. METHODS: get_flights IMPORTING carrier TYPE carrid_t RETURNING value(flights) TYPE sflight RAISING cx_no_flights, display_flights IMPORTING flights TYPE flight_tab. ENDCLASS. Static Methods Type declaration Static Attributes Instance Methods SAP 2011 / ABAP Introduction and Overview / Horst Keller, Tobias Wenner / SAP AG / Page 11
ABAP Language ABAP Essential Concepts at one Glance, Part 2 Class Implementation CLASS get_and_display_flights IMPLEMENTATION. METHOD main. DATA: carrier TYPE sflight-carrid, my_flights TYPE sflight. CREATE OBJECT self. CALL FUNCTION 'REQUEST_CARRIER' IMPORTING carrier = carrier. TRY. my_flights = self->get_flights( carrier ). CATCH cx_no_flights. MESSAGE text-nof TYPE 'I' DISPLAY LIKE 'E'. RETURN. ENDTRY. self->display_flights( my_flights ). ENDMETHOD. Method Implementation Local Data Object Instantiation Function Call Method Call Exception Handling SAP 2011 / ABAP Introduction and Overview / Horst Keller, Tobias Wenner / SAP AG / Page 12
ABAP Language ABAP Essential Concepts at one Glance, Part 3 METHOD get_flights. SELECT * FROM sflight INTO TABLE flights WHERE carrid = carrier. IF sy-subrc <> 0. RAISE EXCEPTION TYPE cx_no_flights. ENDIF. ENDMETHOD. METHOD display_flights. DATA: display_tab TYPE STANDARD TABLE OF sflight, alv TYPE REF TO cl_salv_table, exc TYPE REF TO cx_salv_msg. TRY. display_tab = flights. cl_salv_table=>factory( IMPORTING r_salv_table = alv CHANGING t_table = display_tab ). alv->display( ). CATCH cx_salv_msg INTO exc. MESSAGE exc TYPE 'I' DISPLAY LIKE 'E'. RETURN. ENDTRY. ENDMETHOD. ENDCLASS. Open SQL Internal Table Exception Raising Global Classes Method Call SAP 2011 / ABAP Introduction and Overview / Horst Keller, Tobias Wenner / SAP AG / Page 13
ABAP Finding Appropriate Abstractions for Business Application Programming Business Application Programming ABAP Runtime Environment ABAP Essential Concepts at one Glance ABAP Development ABAP Strong Points Conclusion SAP 2011 / ABAP Introduction and Overview / Horst Keller, Tobias Wenner / SAP AG / Page 14
ABAP Development ABAP Workbench ABAP Workbench Integrated Tool Environment for all Development Objects Server Side Development Change and Transport System Test Tools SAP 2011 / ABAP Introduction and Overview / Horst Keller, Tobias Wenner / SAP AG / Page 15
ABAP Development Future: ABAP in Eclipse SAP 2011 / ABAP Introduction and Overview / Horst Keller, Tobias Wenner / SAP AG / Page 16
ABAP Development ABAP Debugger SAP 2011 / ABAP Introduction and Overview / Horst Keller, Tobias Wenner / SAP AG / Page 17 Two Process Debugging
ABAP Development ABAP Language - Documentation F1 Comprehensive help for more than 700 ABAP keywords SAP 2011 / ABAP Introduction and Overview / Horst Keller, Tobias Wenner / SAP AG / Page 18
ABAP Finding Appropriate Abstractions for Business Application Programming Business Application Programming ABAP Runtime Environment ABAP Essential Concepts at one Glance ABAP Development ABAP Strong Points Conclusion SAP 2011 / ABAP Introduction and Overview / Horst Keller, Tobias Wenner / SAP AG / Page 19
ABAP Language ABAP Strong Points Built-in Database Access Open SQL SELECT... FROM... INTO... WHERE... GROUP BY... HAVING... ORDER BY... Native SQL EXEC SQL. SELECT... CREATE TABLE... EXECUTE PROCEDURE... DML and DDL Database Platform Dependent OPEN/FETCH/CLOSE CURSOR... INSERT... UPDATE... MODIFY... DELETE... ENDEXEC. ADBC DATA: sql TYPE REF TO cl_sql_statement, stmt TYPE string. stmt = `SELECT... `. DML Database Independent sql->execute_query( stmt ). SAP 2011 / ABAP Introduction and Overview / Horst Keller, Tobias Wenner / SAP AG / Page 20
ABAP Language ABAP Strong Points Handling Tables Tables on Screens DATA itab TYPE TABLE OF... SELECT * FROM dbtab INTO TABLE itab. LOOP AT itab... MODIFY... ENDLOOP. Tables in ABAP: Internal Tables UPDATE dbtab FROM TABLE itab. Database Tables SAP 2011 / ABAP Introduction and Overview / Horst Keller, Tobias Wenner / SAP AG / Page 21
ABAP Language ABAP Strong Points Dictionary Reflecting DB Catalog Screen Painter DBTAB COL1 COL2 COL3... ABAP Dictionary DATA screen_field TYPE dbtab-col3. DATA itab TYPE TABLE OF dbtab. SELECT SINGLE col3 FROM dbtab INTO screen_field WHERE col1 = 4711. SELECT * FROM dbtab INTO TABLE itab. Database Tables SAP 2011 / ABAP Introduction and Overview / Horst Keller, Tobias Wenner / SAP AG / Page 22
ABAP Language ABAP Strong Points Built-in XML-Support REPORT abap_intro_xml_conversion. DATA: BEGIN OF carrier_wa, carrid TYPE scarr-carrid, carrname TYPE scarr-carrname, url TYPE scarr-url, END OF carrier_wa, carrier_tab LIKE TABLE OF carrier_wa, xml_xstring TYPE xstring. SELECT * FROM scarr INTO CORRESPONDING FIELDS OF TABLE carrier_tab. CALL TRANSFORMATION abap_intro_simple_trans SOURCE carriers = carrier_tab RESULT XML xml_xstring OPTIONS xml_header = 'NO'. cl_abap_browser=>show_xml( xml_xstring = xml_xstring ). cl_abap_browser=>show_html( html_xstring = xml_xstring buttons = 'X' check_html = ' ' ). SAP 2011 / ABAP Introduction and Overview / Horst Keller, Tobias Wenner / SAP AG / Page 23 <?sap.transform simple?> <tt:transform xmlns:tt="http://www.sap.com/transformation-templates"> <tt:root name="carriers"/> <tt:template> <html> <body> <h2>carriers:</h2> <table border="2"> <tr> <td><b>id</b></td> <td><b>name</b></td> <td><b>homepage</b></td> </tr> <tt:loop ref=".carriers"> <tr><td> <tt:value ref="$ref.carrid"/> </td> <td> <tt:value ref="$ref.carrname"/> </td> <td> <a><tt:attribute name="href" value-ref="$ref.url" /> <tt:value ref="$ref.url"/></a> </td> </tr> </tt:loop> </table> </body> </html> </tt:template> </tt:transform> Simple Transformation, Standard XSLT is also possible
ABAP Language ABAP Strong Points Proof of Concept THE BEST-RUN BUSINESSES RUN ABAP ABAP-based SAP Applications ABAP is the language in which most of the business applications of the world s largest ERP vendor are developed. SAP 2011 / ABAP Introduction and Overview / Horst Keller, Tobias Wenner / SAP AG / Page 24
ABAP Finding Appropriate Abstractions for Business Application Programming Business Application Programming ABAP Runtime Environment ABAP Essential Concepts at one Glance ABAP Development ABAP Strong Points Conclusion SAP 2011 / ABAP Introduction and Overview / Horst Keller, Tobias Wenner / SAP AG / Page 25
Conclusion ABAP meets the Demands of an Ever-Changing World by an Ongoing Evolution! R/2 ABAP ABAP/4 ABAP Objects Unicode enabled Modern ABAP SAP 2011 / ABAP Introduction and Overview / Horst Keller, Tobias Wenner / SAP AG / Page 26
ABAP Finding Appropriate Abstractions for Business Application Programming THANK YOU FOR YOUR ATTENTION! QUESTIONS SUGGESTIONS DISCUSSION SAP 2011 / ABAP Introduction and Overview / Horst Keller, Tobias Wenner / SAP AG / Page 27
Backup Slides SAP 2008 / ABAP Introduction and Overview / Horst Keller / NW F ABAP / Page 28
ABAP Language ABAP Strong Points The ABAP Type Zoo, Part 1 Types Objects Generic Types Data Types Data Objects data, any Elementary Daty Types Elementary Data Objects simple Fixed Length c d n t Static Data Objects Text Fields Date Fields Numeric Text Fields Time Fields csequence clike decfloat16/34 Decimal FltPt. decfloat f i p x Binary Floating Point Numbers Integers Packed Numbers Byte Fields numeric xsequence Variable Length Dynamic Data Objects SAP 2008 / ABAP Introduction and Overview / Horst Keller / NW F ABAP / Page 29 xstring string Byte Strings Character Strings
ABAP Language ABAP Strong Points The ABAP Type Zoo, Part 2 Types Objects Data Types Data Objects data, any Complex Data Types Complex Data Objects Structured Types Structures Table Types Internal Tables any table Index Tables Standard Tables Sorted Tables Standard Tables Sorted Tables index table [standard] table sorted table Hashed Tables Hashed Tables hashed table Reference Types Reference Variables Data References Object References Data Reference Variables Object Reference Variables Class References Class Reference Variables Object Types Interface References Interface Reference Variables object Classes Objects Interfaces SAP 2008 / ABAP Introduction and Overview / Horst Keller / NW F ABAP / Page 30
ABAP Language ABAP Strong Points Internal Tables from Past to Present Three kinds of internal tables: Standard tables Sorted tables Hashed tables Tables of any Type Tables of References REPORT abap_intro_reference_table. DATA vehicle_tab TYPE TABLE OF REF TO cl_abap_intro_vehicle. DO n TIMES. CREATE OBJECT vehicle. APPEND vehicle TO vehicle_tab. ENDDO. Tables of Structures LOOP AT vehicle_tab INTO vehicle. vehicle->show_speed( ). ENDLOOP. SAP 2008 / ABAP Introduction and Overview / Horst Keller / NW F ABAP / Page 31
ABAP Language ABAP Strong Points Internal Tables with Secondary Keys REPORT demo_secondary_keys. DATA: itab TYPE HASHED TABLE OF example_data=>struc WITH UNIQUE KEY idx WITH NON-UNIQUE SORTED KEY k1 COMPONENTS name postal_code. READ TABLE jtab INTO wa WITH KEY k1 COMPONENTS name =... postal_code =.... Primary unique hashed key Secondary non-unique sorted key Access via secondary key SAP 2008 / ABAP Introduction and Overview / Horst Keller / NW F ABAP / Page 32
ABAP Language ABAP Strong Points Dynamic Programming REPORT abap_intro_dynamic. DATA: type_descr TYPE REF TO cl_abap_typedescr, struct_descr TYPE REF TO cl_abap_structdescr, table_descr TYPE REF TO cl_abap_tabledescr, components TYPE cl_abap_structdescr=>component_table, table_ref TYPE REF TO data. FIELD-SYMBOLS <table> TYPE ANY TABLE. cl_abap_typedescr=>describe_by_name( EXPORTING p_name = dbtab RECEIVING p_descr_ref = type_descr ). RTTS Classes Data Reference Field Symbol components =... struct_descr = cl_abap_structdescr=>create( components ). table_descr = cl_abap_tabledescr=>create( struct_descr ). CREATE DATA table_ref TYPE HANDLE table_descr. ASSIGN table_ref->* TO <table>. TRY. SELECT (cols) FROM (dbtab) INTO CORRESPONDING FIELDS OF TABLE <table> WHERE (where). CATCH cx_sy_sql_error INTO error.... ENDTRY. RTTI RTTC Data Object Instantiation Dynamic Tokens SAP 2008 / ABAP Introduction and Overview / Horst Keller / NW F ABAP / Page 33
ABAP Language ABAP Strong Points Exception Handling CX_ROOT CX_STATIC_CHECK CX_DYNAMIC_CHECK CX_NO_CHECK CLASS cx_... DEFINITION INHERITING FROM cx_..._check.... ENDCLASS. DATA oref TYPE cx_... TRY. method(... ). CATCH cx_... cx_... INTO oref.... CLEANUP.... ENDTRY. METHODS method RAISING cx_... METHOD method. RAISE cx_... ENDMETHOD. SAP 2008 / ABAP Introduction and Overview / Horst Keller / NW F ABAP / Page 34
ABAP Development ABAP Language - Keywords ABAP Not really a Language for Esthets SAP 2008 / ABAP Introduction and Overview / Horst Keller / NW F ABAP / Page 35