ABAP and Netweaver Day 1: Hong Kong, China 3 - 7 July 2012
ABAP and Netweaver Day 1: Hong Kong, China 3 - 7 July 2012
ABAP and Netweaver Day 1: Hong Kong, China 3 - 7 July 2012
Day 1
Hong Kong, China
3 7 July 2012
* Materials for this workshop are adapted from available resources from SAP UA
Agenda
Introduction to ABAP and Netweaver
What is ABAP?
What is Netweaver?
The R/3 Repository
Introduction to the ABAP workbench
ABAP Editor
ABAP Dictionary
Menu Painter
Screen Painter
Introduction to basic ABAP programming concepts, internal tables and
logical database
Basic ABAP concepts
Local Data
Internal tables and Open SQL
Logical databases
2012 SAP AG. All rights reserved.
What is ABAP?
What is Netweaver?
What is ABAP?
Features of ABAP
Is platform-independent.
What is ABAP?
Programming an Application
What is ABAP?
Transporting Developments
What is ABAP?
ABAP Program
What is ABAP?
Interaction between Server Layers
10
What is Netweaver?
SAP Netweaver
11
SRM
mySAP
SRM
HR
mySAP
HR
SCM
mySAP
SCM
CRM
mySAP
CRM
PLM
mySAP
PLM
FIN
mySAP
Financials
BI
mySAP
BI
21 Industry Solutions
mySAP Services
mySAP.com
Enterprise
Portal
mySAP Enterprise Portals
ERP
SAP R/3 Enterprise
Exchange
mySAP Exchanges
mySAP Technology
2012 SAP AG. All rights reserved.
12
ABAP Editor
ABAP Dictionary
Menu Painter
Screen Painter
14
15
Exercise 1
16
Menu Painter
17
Screen Painter
18
ABAP Editor
Menu path Tools ABAP workbench Development
ABAP Editor
Transaction code: SE38
Run, view, edit, activate, check ABAP code
Integrated into Object Navigator
19
Exercise 2
ABAP Editor
20
ABAP Dictionary
21
ABAP Dictionary
Accessing the ABAP Dictionary
22
ABAP Dictionary
A table definition in the Dictionary
23
ABAP Dictionary
Basic Dictionary Objects
Tables are made up of rows containing one or more fields.
When a field is defined its data type is determined by reference to a data
element.
A data element stores semantic properties field label and online
documentation.
(F1 help). A data element also references a domain.
A domain contains technical properties - data type/length.
24
ABAP Dictionary
Data Elements & Domains
Customer Table
fields
Data
Elements
Domain
z_phonew
phone_w
phone_f
phone_h
z_phoneh
zphone
type: char
len: 12
25
ABAP Dictionary
SAPs Flight Data Model
26
ABAP Dictionary
Summary
27
Exercise 3
DATA Dictionary
28
Local Data
Logical databases
30
31
Local Data
Data Type
32
Local Data
Elementary Data Types
Since SAP R/3 4.6 ABAP offers two variable length built-in elementary data types
STRING and XSTRING:
DATA: text-string TYPE string
text-string = ABAP programming is FUN!
33
Local Data
Elementary Data Types
write student_id.
34
Local Data
User-defined Data Types
You can create your own data types and apply them to
variables.
types: t_name(25) type c.
data: customer_name type t_name,
vendor_name type t_name,
carridcode type s_carr_id.
2012 SAP AG. All rights reserved.
35
Local Data
Structure
Structures are defined using the keywords begin of and end of.
data: begin of customer,
id(8) type n,
fname(12),
lname(15),
end of customer.
customer-id = 12345678.
customer-fname = Christian.
customer-lname = Wong.
write / customer.
write: / customer-id,
customer-fname,
customer-lname.
36
Local Data
Structure
37
Local Data
Structure
38
Local Data
Input Parameters
39
Control Statements
Do/Enddo
While/Endwhile
40
Control Statements
Logical Expressions
41
Control Statements
Conditions: If / ElseIf
Syntax:
if logical expression #1.
command lines.
[elseif logical expression #2.
command lines.]
[else.
command lines.]
endif.
Examples.
42
Control Statements
Logical Expressions & Operators
43
Control Statements
Evaluating Field Contents: Case/EndCase Vs If/Endif
44
Control Statements
Loops : Do/EndDo
An unconditional loop.
Syntax : do [N times].
Commands.
enddo.
Examples.
45
Control Statements
Loops : While/EndWhile
Examples.
46
Control Statements
Other control commands
Examples.
47
Exercise 4
48
Internal tables (arrays) are data objects that allow you to retain several data
records within the same structure in working memory.
Internal tables have the same general structure as a database table, but are
held in memory, and initially contain no records.
The number of data records stored in an internal table is only restricted by the
capacity limits the computer system.
Internal tables are used to process large data sets in a structured manner:
Temporarily storing data from database tables for future processing;
Structuring and formatting data for output;
Formatting data for the use of other services.
49
50
Basic ways of defining internal tables with and without header lines.
data:
data:
data:
data:
51
52
53
54
55
56
57
2) loop at stud_tab
where studname = Smith.
write / stud_tab-studid.
endloop.
2012 SAP AG. All rights reserved.
58
59
60
loop at cust_info.
write: / cust_info-ID, cust_info-name, cust_info-telephone.
endloop.
2012 SAP AG. All rights reserved.
61
clear tablename.
Clears the header record of the internal table.
refresh tablename.
Removes all the line records in a table (not the header).
describe table tablename lines lin occurs ini kind knd.
Provides information on attributes of the internal table such
as number of lines used.
free tablename.
Deletes the internal table and releases the storage.
62
Exercise 5
Internal Tables
63
Customid
003
001
001
003
Carrid
UA
UA
UA
QA
Connid
400
401
401
001
Fldate
20061230
20061121
20060622
20060804
CUSTOMER TABLE
Id
001
002
003
Name
Smith
Jones
Nguyen
City
Geelong
Prahran
Richmond
Phome
035214252
95294545
95234444
64
65
report lec601.
write: / customers-name.
get bookings.
write at /3 bookings-fldate.
66
Logical databases
A logical database supplies your program with entries from tables. This
means that you only need to program the data processing statements.
67
Logical databases
What is a Logical Database?
Using a logical database is another method for reading data from a
database table.
The R/3 system contains about 150 logical databases covering most
of the business processes.
When you run a program that uses a logical database, the program
behind the logical database runs as well. The logical database displays
an automatic selection screen for the user, issues the SELECT
commands and returns the data to the calling program (your program).
68
Logical databases
Assigning a Logical Database
69
Logical databases
Selection screen of a Logical Database
70
Logical databases
Event Sequencing: Using the GET event
The GET events in an ABAP program are processed in a tree like order to
match the tree like order relationship of the tables in the logical database.
71
Logical databases
Using the GET event
72
Logical databases
Using the GET event
The first data record from database table SPFLI is made available to
your program. If your program has a GET spfli, the event block is
processed.
The first data record from SFLIGHT that corresponds to the key of
the current SPFLI record is made available to your program. If your
program has a GET sflight, the event block is processed.
73
Logical databases
Advantages of Logical Databases
74
Formatting
Formatting Output - Color
75
Formatting
Formatting Output - Color
76
Formatting
Generating Icons, Symbols and Lines
77
Formatting
Setting the list format
78
Formatting
Page and Column Headers
79
Formatting
Header using TOP-OF-PAGE Event
80
Formatting
Formatting Output - Solid Lines
report lec702.
data: square type i,
line_size type i value 40.
uline.
format color col_heading.
write: / sy-vline,
Numbers and their squares,
at line_size sy-vline.
format color off.
uline.
do 10 times.
square = sy-index ** 2.
write: / sy-vline,
sy-index color col_key,
sy-vline,
square,
at line_size sy-vline.
enddo.
uline.
2012 SAP AG. All rights reserved.
81
Exercise 6
82
Thank you
Contact information:
Taizan Chan
t.chan@qut.edu.au