Sunteți pe pagina 1din 36

ABAP

Finding Appropriate Abstractions for


Business Application Programming
Horst Keller
NetWeaver Foundation ABAP
A
B
A
P
A
B
A
P
A
B
A
P
A
B
A
P
SAP 2008 / ABAP Introduction and Overview / Horst Keller / NW F ABAP / Page 2
ABAP
Finding Appropriate Abstractions for
Business Application Programming
A
B
A
P
A
B
A
P
A
B
A
P
A
B
A
P
Business Application Programming
ABAP Runtime Environment
ABAP Essential Concepts at one Glance
ABAP Development
ABAP Strong Points
Conclusion
SAP 2008 / ABAP Introduction and Overview / Horst Keller / NW F ABAP / Page 3
ABAP
Finding Appropriate Abstractions for
Business Application Programming
A
B
A
P
A
B
A
P
A
B
A
P
A
B
A
P
Business Application Programming
ABAP Runtime Environment
ABAP Essential Concepts at one Glance
ABAP Development
ABAP Strong Points
Conclusion
SAP 2008 / ABAP Introduction and Overview / Horst Keller / NW F ABAP / Page 4
Business Application Programming
General Figure
Tabular Data in Tables of a
Central Relational Database
UI
Application Programs
System System
Presentation Layer
Application Layer
Persistence Layer
SAP 2008 / ABAP Introduction and Overview / Horst Keller / NW F ABAP / Page 5
Business Application Programming
The ABAP Way
Tabular Data in Tables of a
Central relational Database
UI
ABAP Programs
Presentation Layer
Application Layer
Persistence Layer
remote System
ABAP System
ABAP Runtime Environment
SAP 2008 / ABAP Introduction and Overview / Horst Keller / NW F ABAP / Page 6
ABAP
Finding Appropriate Abstractions for
Business Application Programming
A
B
A
P
A
B
A
P
A
B
A
P
A
B
A
P
Business Application Programming
ABAP Runtime Environment
ABAP Essential Concepts at one Glance
ABAP Development
ABAP Strong Points
Conclusion
SAP 2008 / ABAP Introduction and Overview / Horst Keller / NW F ABAP / Page 7
Business Application Programming
The ABAP Runtime Environment
PROGRAM ...
CLASS ...
METHOD main.
...
ENDMETHOD.
ENDCLASS.
ABAP Program
SAP GUI, HTTP
Native Database Commands
RFC,
HTTP
ABAP Runtime Envrionment
Hardware-, operating-system-, and
database-independent platform
(virtual machine) that provides
Interfaces
Server Management (Memory,
Process, Task Handling)
Text Environment
Locking and LUW Services

for ABAP programs.
SAP 2008 / ABAP Introduction and Overview / Horst Keller / NW F ABAP / Page 8
ABAP Runtime Environment Past to Present
Classical ABAP - Reporting
R/3-System
SAP Basis
Report Program
Classical Lists
(Screen/Spool)
_________________
_________________
_________________
_________________
_________________
_________________
_________________
_________________
_________________
_________________
_________________
_________________
_________________
_________________
_________________
_________________
_________________
_________________
_________________
_________________
_________________
_________________
_________________
_________________
_________________
_________________
_________________
_________________
_________________
_________________
_________________
_________________
_________________
_________________
_________________
_________________
_________________
_________________
_________________
_________________
_________________
_________________
_________________
_________________
_________________
_________________
_________________
_________________
_________________
_________________
_________________
_________________
_________________
_________________
_________________
_________________
REPORT abap_intro_classic_report.
TABLES spfli.
START-OF-SELECTION.
WRITE text-lst.
ULINE.
GET spfli.
WRITE: spfli-carrid, spfli-connid,
spfli-cityfrom, spfli-cityto.
END-OF-SELECTION.
ULINE.
ABAP
Allgemeiner Berichts Aufbereitungs Prozessor
DEMO DEMO DEMO DEMO
SAP 2008 / ABAP Introduction and Overview / Horst Keller / NW F ABAP / Page 9
ABAP
Advanced Business Application Programming
ABAP Runtime Environment Past to Present
Classical ABAP - Transactions
R/3-System
SAP Basis
Dialog Program
Classical Dynpros
PROGRAM abap_intro_classic_transaction.
MODULE user_command_0100 INPUT.
CASE sy-ucomm.
WHEN 'EXECUTE'.
SELECT * FROM sflight
INTO CORRESPONDING FIELDS
OF TABLE conn_tab
WHERE carrid = demo_conn-carrid AND
connid = demo_conn-connid.

ENDMODULE.
MODULE user_command_0200 INPUT.
CASE sy-ucomm.
WHEN 'SAVE'.
CALL FUNCTION 'UPDATE_SFLIGHT'
EXPORTING flight_tab = conn_tab.
COMMIT WORK.

ENDMODULE.
DEMO DEMO DEMO DEMO
SAP 2008 / ABAP Introduction and Overview / Horst Keller / NW F ABAP / Page 10
ABAP Runtime Environment Past to Present
Modern ABAP ABAP Objects
NW AS ABAP Non-ABAP
Services
Services
Services
Application
SOA
Service Oriented Architecture
SAP 2008 / ABAP Introduction and Overview / Horst Keller / NW F ABAP / Page 11
NW AS ABAP
ABAP Runtime Environment Past to Present
Modern ABAP NetWeaver Application Server ABAP
BSP Web Dynpro
Open SQL
Dynpro
Native SQL
Data Base Interface
ICF
XSLT/ST ABAP/ABAP Objects
CFW
RFC
Interface
Gateway
Taskhandler Enqueue Dispatcher
SAP OS
Database
OS
ICM
SAP 2008 / ABAP Introduction and Overview / Horst Keller / NW F ABAP / Page 12
ABAP
Finding Appropriate Abstractions for
Business Application Programming
A
B
A
P
A
B
A
P
A
B
A
P
A
B
A
P
Business Application Programming
ABAP Runtime Environment
ABAP Essential Concepts at one Glance
ABAP Development
ABAP Strong Points
Conclusion
SAP 2008 / ABAP Introduction and Overview / Horst Keller / NW F ABAP / Page 13
ABAP Language
ABAP Essential Concepts at one Glance, Part 1
CLASS get_and_display_flights DEFINITION.
PUBLIC SECTION.
CLASS-METHODS main.
PRIVATE SECTION.
TYPES flight_tab TYPE HASHED TABLE OF sflight
WITH UNIQUE KEY carrid connid fldate.
CLASS-DATA self TYPE REF TO get_and_display_flights.
METHODS: get_flights
IMPORTING carrier TYPE sflight-carrid
RETURNING value(flights) TYPE flight_tab
RAISING cx_no_flights,
display_flights
IMPORTING flights TYPE flight_tab.
ENDCLASS.
DEMO DEMO DEMO DEMO
Class Definition
Static Methods
Type declaration
Static Attributes
Instance Methods
PROGRAM abap_intro_essentials.
CLASS cx_no_flights DEFINITION
INHERITING FROM cx_static_check.
ENDCLASS.
Exception Class
SAP 2008 / ABAP Introduction and Overview / Horst Keller / NW F ABAP / Page 14
ABAP Language
ABAP Essential Concepts at one Glance, Part 2
CLASS get_and_display_flights IMPLEMENTATION.
METHOD main.
DATA: carrier TYPE sflight-carrid,
my_flights TYPE flight_tab.
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.
Class Implementation
Method Implementation
Local Data
Object Instantiation
Function Call
Method Call
Exception Handling
DEMO DEMO DEMO DEMO
SAP 2008 / ABAP Introduction and Overview / Horst Keller / NW F ABAP / Page 15
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.
DEMO DEMO DEMO DEMO
Open SQL
Exception Raising
Global Classes
External Method Call
Internal Table
SAP 2008 / ABAP Introduction and Overview / Horst Keller / NW F ABAP / Page 16
ABAP
Finding Appropriate Abstractions for
Business Application Programming
A
B
A
P
A
B
A
P
A
B
A
P
A
B
A
P
Business Application Programming
ABAP Runtime Environment
ABAP Essential Concepts at one Glance
ABAP Development
ABAP Strong Points
Conclusion
SAP 2008 / ABAP Introduction and Overview / Horst Keller / NW F ABAP / Page 17
ABAP Development
ABAP Workbench
ABAP Workbench
Integrated Tool
Environment for all
Development
Objects
Server Side
Development
Change and
Transport System
Test Tools

SAP 2008 / ABAP Introduction and Overview / Horst Keller / NW F ABAP / Page 18
ABAP Development
ABAP Debugger
Two Process Debugging
SAP 2008 / ABAP Introduction and Overview / Horst Keller / NW F ABAP / Page 19
ABAP Development
ABAP Language - Keywords
ABAP
Not really a Language for Esthets
SAP 2008 / ABAP Introduction and Overview / Horst Keller / NW F ABAP / Page 20
ABAP Development
ABAP Language - Documentation
Comprehensive help for more than 700 ABAP keywords
F1
SAP 2008 / ABAP Introduction and Overview / Horst Keller / NW F ABAP / Page 21
ABAP
Finding Appropriate Abstractions for
Business Application Programming
A
B
A
P
A
B
A
P
A
B
A
P
A
B
A
P
Business Application Programming
ABAP Runtime Environment
ABAP Essential Concepts at one Glance
ABAP Development
ABAP Strong Points
Conclusion
SAP 2008 / ABAP Introduction and Overview / Horst Keller / NW F ABAP / Page 22
ABAP Language
ABAP Strong Points Built-in Database Access
Open SQL
Native SQL
ADBC
DATA: sql TYPE REF TO cl_sql_statement,
stmt TYPE string.
stmt = `SELECT ... `.
sql->execute_query( stmt ).
EXEC SQL.
SELECT ...
CREATE TABLE ...
EXECUTE PROCEDURE ...
ENDEXEC.
SELECT ...
FROM ...
INTO ...
WHERE ...
GROUP BY ...
HAVING ...
ORDER BY ...
INSERT ...
UPDATE ...
MODIFY ...
DELETE ...
DML
Platform Independent
DML and DDL
Platform Dependent
DML and DDL
Platform Dependent
DCL: Locking etc. is managed by other concepts
SAP 2008 / ABAP Introduction and Overview / Horst Keller / NW F ABAP / Page 23
ABAP Language
ABAP Strong Points Type Declarations and Typing
ABAP Dictionary
FIELD
...
DBTAB
Database Tables
(Web) Dynpro
____
TYPES local_type TYPE HASHED TABLE OF dbtab
WITH UNIQUE KEY ...
DATA screen_field TYPE field.
DATA dbtab_wa TYPE dbtab.
DATA dbtab_tab TYPE local_type.
METHODS meth IMPORTING para1 TYPE field
EXPORTING para2 TYPE local_type.
SAP 2008 / ABAP Introduction and Overview / Horst Keller / NW F ABAP / Page 24
ABAP Language
ABAP Strong Points The ABAP Type Zoo, Part 1
Types
Data Types
Elementary Daty Types
Fixed Length
Variable Length
Objects
Data Objects
Elementary Data Objects
Static Data Objects
Dynamic Data Objects
f
i
x
Binary Floating Point Numbers
Integers
Byte Fields
string
xstring
Character Strings
Byte Strings
data, any
clike
csequence
numeric
simple
xsequence
c
d Date Fields
n Numeric Text Fields
t Time Fields
p Packed Numbers
Text Fields
Generic Types
decfloat16/34 Decimal FltPt. decfloat
SAP 2008 / ABAP Introduction and Overview / Horst Keller / NW F ABAP / Page 25
ABAP Language
ABAP Strong Points The ABAP Type Zoo, Part 2
Types
Data Types
Complex Data Types
Structured Types
Table Types
Object Types
Classes
Interfaces
Objects
Data Objects
Complex Data Objects
Structures
Internal Tables
Reference Types
Data References
Object References
Reference Variables
Data Reference Variables
Object Reference Variables
Interface References Interface Reference Variables
Class References Class Reference Variables
Objects
Index Tables
Standard Tables
Sorted Tables
Hashed Tables
Standard Tables
Sorted Tables
Hashed Tables
data, any
object
any table
[standard] table
sorted table
hashed table
index table
SAP 2008 / ABAP Introduction and Overview / Horst Keller / NW F ABAP / Page 26
ABAP Language
ABAP Strong Points Handling Tables
Database Tables
Tables on Screens ____
DATA itab TYPE ... TABLE OF
WITH ... KEY ...
READ TABLE itab WITH TABLE KEY ...
LOOP AT itab ...
ENDLOOP.
INSERT ... INTO TABLE ...
SELECT ... INTO TABLE ...
...
Tables in ABAP:
Internal Tables
SAP 2008 / ABAP Introduction and Overview / Horst Keller / NW F ABAP / Page 27
ABAP Language
ABAP Strong Points Internal Tables from Past to Present
Tables of Structures
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.
LOOP AT vehicle_tab INTO vehicle.
vehicle->show_speed( ).
ENDLOOP.
DEMO DEMO DEMO DEMO
Three kinds of internal tables:
Standard tables
Sorted tables
Hashed tables
SAP 2008 / ABAP Introduction and Overview / Horst Keller / NW F ABAP / Page 28
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 = ... .
DEMO DEMO DEMO DEMO
L
a
t
e
s
t

N
e
w
s
!
(
R
e
l
e
a
s
e

7
.
1
)
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 29
ABAP Language
ABAP Strong Points String Processing
REPORT abap_intro_regex.
IF matches( val = email
regex = `\w+(\.\w+)*@(\w+\.)+(\w{2,4})`
case = abap_false ).
...
ELSE.
...
ENDIF.
Example 1
Built-in Support for
Regular Expressions
DEMO DEMO DEMO DEMO
REPORT abap_intro_string_expressions.
output( text-sym &&
|: { get_amount( ) + get_tax( )
STYLE = MONETARY
CURRENCY = cur }| &&
| { cur ALIGN = LEFT }| ).
DEMO DEMO DEMO DEMO
Example 2
String Expressions with
String Templates
L
a
t
e
s
t
N
e
w
s
!
(R
e
le
a
s
e
7
.1
)
SAP 2008 / ABAP Introduction and Overview / Horst Keller / NW F ABAP / Page 30
ABAP Language
ABAP Strong Points Language Environment
The language environment of an ABAP-Program comprises
Text pool with language dependend text elements
Text environment with language dependent Locale and System
Code Page
Format settings with country specific number, date, and time
formats
Language Independent Development
output = text-sym.
Text Symbol,
as an Example for
Text Elements
SAP 2008 / ABAP Introduction and Overview / Horst Keller / NW F ABAP / Page 31
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 = ' ' ).
DEMO DEMO DEMO DEMO
<?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
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 ).
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.
DEMO DEMO DEMO DEMO
RTTS
Classes
Data
Reference
Field Symbol
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_NO_CHECK CX_STATIC_CHECK CX_DYNAMIC_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.
R
e
le
a
s
e
7
.1
:
R
e
s
u
m
a
b
le
E
x
c
e
p
tio
n
s
SAP 2008 / ABAP Introduction and Overview / Horst Keller / NW F ABAP / Page 34
ABAP
Finding Appropriate Abstractions for
Business Application Programming
A
B
A
P
A
B
A
P
A
B
A
P
A
B
A
P
Business Application Programming
ABAP Runtime Environment
ABAP Essential Concepts at one Glance
ABAP Development
ABAP Strong Points
Conclusion
SAP 2008 / ABAP Introduction and Overview / Horst Keller / NW F ABAP / Page 35
Conclusion
ABAP meets the Demands of an Ever-Changing World
R/2 ABAP ABAP/4 Modern ABAP ABAP Objects Unicode enabled
by an Ongoing Evolution!
SAP 2008 / ABAP Introduction and Overview / Horst Keller / NW F ABAP / Page 36
ABAP
Finding Appropriate Abstractions for
Business Application Programming
A
B
A
P
A
B
A
P
A
B
A
P
A
B
A
P
THANK YOU FOR YOUR
ATTENTION !
QUESTIONS SUGGESTIONS DISCUSSION

S-ar putea să vă placă și