Beruflich Dokumente
Kultur Dokumente
Day 3
Hong Kong, China
3 7 July 2012
* Materials for this workshop are adapted from available resources from SAP UA
Agenda
ABAP Objects
ABAP Objects
Major tools:
ABAP Editor
Class Builder
Object-oriented approach
Braking
Car_accelerate
Show_speed
Accelerate
Car_braking
Car_show_speed
Car
Car_stop
Car_Gear_change_up
Car_Gear_change_down
Stop
Gear_change up
Gear_change_down
Inheritance
Attributes:
Methods:
Class Car
Attributes: Manufacturer
No. of wheels
No. of seats
Methods:
Create
Show attributes
Used seats
Manufacturer
No. of wheels
Inheritance
Create
Show attribute
Manufacturer
No. of wheels
Vehicle payload
Methods:
Create
Show attributes
Cargo capacity
Private public
Instance static
Declaration of a class
10
Definition of a class
11
Implementation of a class
ENDMETHOD.
ENDCLASS.
12
Instance method:
Class method:
Instance attributes:
<Instance name>-><Attribute>.
Static attributes:
<Class name>=><Attribute>.
13
Constructor
Explicitly or implicitly defined method constructor used for
creating new instances
14
Example constructor
PUBLIC SECTION
METHODS: constructor IMPORTING
im_name type string
im_planetype type string.
15
Web AS
BSP
MVC Architecture
Web AS
What is Web AS?
17
Web AS
What is Web AS?
18
Web AS
What is Web AS?
19
Web AS
What is Web AS?
20
Web AS
How Web AS Works Incoming requests
21
Web AS
How Web AS Works
22
Web AS
How Web AS Works
23
Web AS
Where Web AS fits in to NetWeaver
24
BAPI
Usage of BAPIs in BSPs I
25
BAPI
Usage of BAPIs in BSPs II
Browser
SAP System 2
EXPORTING
BAPI
RFC
BSP
IMPORTING
26
BAPI
Using BAPI Browser I
27
BAPI
Using BAPI Browser II
RFCConnection
Available
BAPIs for
RFCConnection
Call example
28
BAPI
Usage of BAPIs in BSPs III
Example scenario:
29
BSP
Business Server Pages
30
BSP
Maintenance and execution of BSPs
E.g.:http://uccwdisp2.fit.qut.edu.au:1097/sap(bD1lbiZjPTE
wMA==)/bc/bsp/sap/ztzbsp3/default.htm
31
BSP
Example: Call BAPI in BSP Step 1
Temporary variables
data username type c.
data tmp_islocked type BAPISLOCKD.
data tmp_moddat type BAPIMODDAT.
Interface variables
data ISLOCKED type BAPISLOCKD.
data LASTMODIFIED type BAPIMODDAT.
32
BSP
Example: Call BAPI in BSP Step 2
33
BSP
Example: Call BAPI in BSP Step 3
= 'master-adm'
= tmp_moddat.
= list
34
BSP
Example: Call BAPI in BSP Result
Result:
35
= 'master-adm
TABLES
return
= list
IMPORTING
islocked
= tmp_islocked
lastmodified
= tmp_moddat.
%>
36
<tr>
<td bgcolor="Whitesmoke" valign="top"> Master-Adm last modified? </td>
<td bgcolor="Whitesmoke" valign="top"><%= tmp_moddat %></td>
</tr>
<tr>
<td bgcolor="Whitesmoke" valign="top"> Master-Adm locked? </td>
<td bgcolor="Whitesmoke" valign="top"><%= tmp_islocked %></td>
</tr>
</table>
</htmlb:page>
</htmlb:content>
37
BSP
HTMLB
HTML-Business
HTML-Business for Java
HTML-Business for ABAP
38
BSP
Comparison HTML / HTMLB
HTML
<html>
<head>
<title>My BSP</title>
<% data: vari type i. %>
</head>
<body>
<%--This is a comment --%>
<% vari = 5 %>
In assigend
this coding
followingvari:
value
is
to variable
<%= vari %>
<br>
Thats it.
</body>
</html>
HTMLB
<%@page language="abap" %>
<%@extension name="htmlb"
prefix="htmlb" %>
<htmlb:content design="design2003" >
<htmlb:page title=My BSP" >
<% data: vari type i. %>
39
BSP
HTMLB Statements
<%@extension name="htmlb" prefix="htmlb" %>
40
BSP
HTMLB Text fields
Text fields:
41
BSP
HTMLB Forms, Input fields
Forms
Input Fields
Input field:
42
BSP
HTMLB Buttons, Events
Buttons
43
BSP
HTMLB - Eventhandler
44
BSP
HTMLB RadioButtons I
Radiobuttons
<htmlb:radioButtonGroup id = "myID" columnCount = "2" >
<htmlb:radioButton id = "RBGenderFemale" text =
"female" tooltip = "I am female" disabled = "false" />
<htmlb:radioButton id = "RBGenderMale" text = "male"
tooltip = "I am male (and this button is disabled)" disabled =
"true" />
</htmlb:radioButtonGroup>
RadioButtons always belong to a RadioButtonGroup
RadioButtonGroup with attributes
Id: Unique ID
columnCount: Number of columns
currentItem: Defines the active item
2012 SAP AG. All rights reserved.
45
BSP
HTMLB RadioButtons II
46
BSP
HTMLB - Layout
RadioButtons
TabStrips
TableView
47
BSP
Model View Controller
SAP System
SAP System
Model
BSP
Controller
View
2012 SAP AG. All rights reserved.
48
MVC Architecture
Model
Interface to the backend system
Enables data access for the Web Dynpro application
Controller
Controls
View
Responsible
49
BSP
Model View Controller
Model
Consists of a class derived from CL_BSP_MODEL
Processing takes place in background
Controller
Handles Requests and forwards to Model
View
Calls Controller
Only responsible for
the visualization of data
SAP System
Model
Controller
View
50
BSP
Model View Controller - Example
No
direct call
HTTP-Request
SAP System
Controller
example_co.do
DO_REQUEST
Model
ZCL_BSP_MYMVCTEST
Attribute
NAME
View
view_test.htm
Application logic
2012 SAP AG. All rights reserved.
51
BSP
Model View Controller - Example
Call Controller
52
BSP
Model View Controller - Example
53
Exercise 9
54
Web Dynpro
Overview
Web Dynpro
Overview
56
Web Dynpro
Web Dynpro Component
Window
One or more views
Navigation links
View
UI elements
Plugs enable navigation between
views
View Controller
Processing user input
Access context data
Component Controller
Visible for all component controllers
Interface Controller
Visible for all component controllers
Also visible outside the component
Web-Dynpro-Component
Component
Contoller
Context
Events
Methods
Interface
Contoller
Context
Events
Methods
Window
View
Contoller
Events
Methods
View
Context
Plugs
UI Elements Actions
View Container
Source:
http://help.sap.com/saphelp_nw70/helpdata/en/7c/3545415ea6f5
23e10000000a155106/frameset.htm
57
Web Dynpro
Web Dynpro View
View Designer
UI Element Category
Layout
Element 1
Element 2
Element 2a
UI Element Hierarchy
ROOT UI ELEMENT
CONTAINER
Element 1
Element 2
Element 2a
Element 2b
Element 2b
Properties:
Element 2a
Source:
http://help.sap.com/saphelp_nw70/helpdata/en/7c/3545415
ea6f523e10000000a155106/frameset.htm
2012 SAP AG. All rights reserved.
58
Web Dynpro
View Context and Data Binding
View 1
View Layout
View Context
CONTEXT
Input 1
Input 2
Component Controller
Context
CONTEXT
View 2
View Context
CONTEXT
Table SPLFI
Table
SPLFI
Carrid
Connid
Cityfrom
Carrid
Connid
CITYFROM
Table SFLIGHT
View Layout
C1 c2
c3
Table
SPLFI
Carrid
Connid
Cityfrom
59
Web Dynpro
View Controller - Event Handler
60
Web Dynpro
Component Controller
View Controller 2
61
Web Dynpro
Controller Methods
Method
Description
Availability
WDDOEXIT
All controllers
WDDOINIT
All controllers
WDDOBEFOREACTION
View controller
WDDOAFTERACTION
View controller
WDDOBEFORENAVIGA
TION
Component
controller
WDDOPOSTPROCESSI
NG
Component
controller
WDDOMODIFYVIEW
View controller
62
Web Dynpro
User input
Data Container
Data is accessible
only at runtime
my name
Client
Validation
of user input
assigned
Controller Context
WDDOBERFOREACTION
Error message
Event handling
validation Indep.
handlers
standard
handlers
WDDOAFTERACTION
WDDOBEFORENAVIGATION
Navigation and View initialization
View modifying WDDOMODIFYVIEW
WDDOPOSTPROCESSING
Rendering
2012 SAP AG. All rights reserved.
if validation failed
Source:
http://help.sap.com/erp2005_ehp_04/helpdata/EN/d2/8acd409cc4dd50e100
00000a1550b0/frameset.htm
Controller Methods
63
Web Dynpro
Controller Attributes
WD_CONTEXT
Reference to the root node of the context of the
controller
Used to edit the content of a context node in a
controller method
WD_THIS
Reference to the local controller interface
Used to access methods and attributes of the local
controller interfaces
64
Web Dynpro
Web Dynpro Window
View
DISPLAY_DATA
Outbound
Plug
Navigation Link
Inbound
Plug
65
Web Dynpro
Exercise: Flight data application
Web Dynpro Component
Window
View MAIN
View ADD_INFO
Component Controller
Context
Controller Methods
oBAPI_FLIGHT_GETLIST
-- IMPORTING
Airline
-- CHANGING
Flight_List
Additional_Info
o EXECUTE_BAPI_FLIGHT_GETLIST
66
Exercise 10
Web Dynpro
67
Thank you
Contact information:
Taizan Chan
t.chan@qut.edu.au