Survey
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
Two Approaches to Developing
Web-Services with R/3
Petra Klensch
Dr. Martin Zurmühl
SAP AG
SAP America 2001, HCM Solutions Conference 1
1
General Architecture
2
“Welcome” – a simple Example
3
“Employees” – Example with R/3-Data Access
4
A final Comparison
SAP America 2001, HCM Solutions Conference 2
1
General Architecture
2
“Welcome” – a simple Example
3
“Employees” – Example with R/3-Data Access
4
A final Comparison
SAP America 2001, HCM Solutions Conference 3
General Infrastructure
Web Server
R/3 System
Internet
Browser
SAP America 2001, HCM Solutions Conference 4
What is a Web Server?
Runtime Environment
Support of Internet standards
HTTP(S), HTML, XML, JavaScript, Java ...
Integration platform
Web applications of different providers
(Business processes, News, Documents, …)
Professional infrastructure
high performance, high scalability,
platform independence
Development Environment
Web Server
Server Pages (HTML)
Server-side scripting (Java,
JavaScript, ABAP, etc.)
Database access
SAP America 2001, HCM Solutions Conference 5
Web Server
R/3 System
Internet
Browser
SAP America 2001, HCM Solutions Conference 6
Solution Providers for Runtime Environments
SAP Web Application Server
SAP- standard R/3 application
server
Extended by
Internet Communication Manager
HTTP-enabled
Scalable, reliable, platform
independent
Java Application Server
Commercial Products:
InQMy App Server (SAP)
BEA WebLogic Server
IBM WebSphere App Server etc.
Open standard solutions:
Apache
Tomcat etc.
SAP America 2001, HCM Solutions Conference 7
Development Environment
SAP Web Application Server
Business Server Pages (BSP)
Server-side scripting
(ABAP, optional JavaScript)
Direct R/3 database access
or via RFC
Java Application Server
Java Server Pages (JSP)
Server-side scripting
(Java, optional JavaScript)
R/3 database access via
SAP Java Connector (JCO)
SAP America 2001, HCM Solutions Conference 8
1
General Architecture
2
“Welcome” – a simple Example
3
“Employees” – Example with R/3-Data Access
4
A final Comparison
SAP America 2001, HCM Solutions Conference 9
„Welcome“ – a simple Example
SAP America 2001, HCM Solutions Conference 10
„Welcome“ – a simple Example
SAP America 2001, HCM Solutions Conference 11
Business Server Page Applications
A BSP Application consists of
Business Server Pages
which define the Web UI
MIME objects
(images, style sheets, ...)
Server-side scripting
(ABAP, JavaScript)
Navigation structure
Application class that acts as
container for the business logic
Theme
BSP Application
BSP Page
BSPBSP
Page
<html>
Page
...
BSP Page
<% loop at
itab.... %>
Application Class
SAP AppServer developmentand runtime-objects as well as
infrastructure are directly
available (no RFC)
SAP America 2001, HCM Solutions Conference 12
Attributes
Methods
Events
Business Server Pages
A Business Server Page (BSP) consists of
A layout page (HTML/XML page)
Page properties
URL
Description
Object
scope (Page, Request, Session)
Page directives for Server-side scripting (ABAP, JavaScript)
Event Handlers
Standard:
OnInitialization, OnManipulation, OnInputProcessing
User-defined
Page
attributes
SAP America 2001, HCM Solutions Conference 13
Flow within BSP pages with Input Processing
SecondPage.htm
FirstPage.htm
User Runtime
enters
User enters
That GET
adetermines
URL
data andrequests
clicks a
BSP App
a button
new page
and Page
Initialization
Data retrieval depending
on input parameters
Layout
HTTP
HTTPPOST
GET
BSP
rendering
rendering of
of the
the page
page
Runtime
REDIRECT
Response
Input Processing
event handling
retrieval of user input
navigation to next page
SAP America 2001, HCM Solutions Conference 14
select * from ...
call function ...
<HTML><BODY>
<% loop at it %>
<tr>
<td><%=it-a%></td>
<td><%=it-b%></td>
</tr>
<% endloop. %>
<form>
<input type=submit
value=“OnHugo“>
</form>
evt =
event->get_name().
case evt.
select‘OnHugo‘.
...
„Welcome“ with BSP: First Page
Default.htm
Initialization
<%@ page language="abap" %>
<html>
<body>
This directive is used to
define the page scripting
language. ABAP and
JavaScript are currently
supported.
Layout
<font size=8> Please insert your name ! </font>
<form method="get">
<input type="text" name="myname">
<input type="submit" name="OnInputProcessing(go)" value="GO!!!">
</form>
</body>
</html>
On submitting the form
by clicking this button,
the OnInputProcessing
* set parameter 'myname'
event handler is called
navigation->set_parameter( name = 'myname' ).
* navigate to page 'welcome.htm'
navigation->goto_page( 'welcome.htm' ).
SAP America 2001, HCM Solutions Conference 15
Input Processing
depending on the user’s input (input
fields, pressed buttons, links) the
Input Processing allows database
updates and the dynamic navigation
to the next page
„Welcome“ with BSP: Second Page
Welcome.htm
Initialization
<%@ page language="abap" %>
Layout
<html>
<body>
<font size=8>Welcome <%= myname%> !</font>
</body>
</html>
The Layout part contains
script code mixed with static
formatting directives (e.g.
HTML).
Page attributes are directly
accessible in the Layout
step
SAP America 2001, HCM Solutions Conference 16
Input Processing
„Welcome“ with BSP: First Page
Business Server Page
Initialization
<%@ page language="abap" %>
Layout
<html>
<body>
<font size=8> Please insert your name ! </font>
<form method="get">
<input type="text" name="myname">
<input type="submit" name="OnInputProcessing(go)" value="GO!!!">
</form>
</body>
</html>
* set parameter 'myname'
navigation->set_parameter( name = 'myname' ).
* navigate to page 'welcome.htm'
navigation->goto_page( 'welcome.htm' ).
SAP America 2001, HCM Solutions Conference 17
Input Processing
BSP – Runtime Objects
Application <your Class>
Request IF_HTTP_REQUEST
GET_FORM_FIELD
Response IF_HTTP_RESPONSE
SET_CDATA
SET_COOKIE
SET_HEADER_FIELD
Runtime IF_BSP_RUNTIME
KEEP_CONTEXT
GET_COOKIES
SAP America 2001, HCM Solutions Conference 18
Navigation IF_BSP_NAVIGATION
GOTO_PAGE
NEXT_PAGE
EXIT
SET_PARAMETER
Why Input Processing ?
Order.htm
...
Problem with direct navigation:
User input from page X must be
processed by the Initialisation
of the next page Y
<form ...>
<input
type=text
name=“number“
...>
</form>
But in most cases the next page Y
depends on the input of page X.
(„You´re wrong here!“ code)
PriceInfo.htm
select *
from ...
where number
...
endselect.
It would be much better to process
the input coming from page X
„at the end“ of page X and then to
determine the next page.
<html>
price:...
Error.htm
<html>
SORRY!
The number you
typed in is
not...
</html>
SAP America 2001, HCM Solutions Conference 19
Java Server Pages
Java Server page serves as a view for the web application
Support for scripting and tags
HTML
Embedded Java
Separation of static and dynamic content when using JavaBeans
Supports reuse of components
JavaBeans and Enterprise JavaBeans
Separation of roles
Visual designer - Business logic developer
A servlet will be generated and compiled by the first invocation
SAP America 2001, HCM Solutions Conference 20
JSP: Processing
Translation (or compilation) phase
JSP engine converts a JSP page into a servlet and compiles it
Carried out only once
Request processing phase
JSP engine invokes the dynamically generated servlet to process the
request and generates the response
Carried out by each request
What‘s a Java Servlet?
reusable platform-independent software component
special Java Class
implements the interface javax.servlet.Servlet
receives requests and responses from a client
SAP America 2001, HCM Solutions Conference 21
JSP: Processing
welcome.jsp
GET/welcome.jsp
Generate
Client
welcomeServlet.java
Server with JSP engine
welcomeServlet.class
SAP America 2001, HCM Solutions Conference 22
„Welcome“ with JSP: First Page
Java Server Page
<html>
<body>
<font size=8> Please insert your name ! </font>
<form method="get" action="/examples/Welcome.jsp">
<input type="text" name="myname">
<input type="submit" name="Go" value="GO !!!">
</form>
</body>
</html>
SAP America 2001, HCM Solutions Conference 23
Direct navigation to the
next page as there exists
no event
InputProcessing
„Welcome“ with JSP: Second Page
Java Server Page
<%@ page language="java" %>
<html>
<body>
This directive is used to
define the page scripting
language.
Java and JavaScript are
currently supported.
<font size=8>
Welcome <%=request.getParameter("myname")%> !
</font>
</body>
</html>
The Layout part contains
script code mixed with static
formatting directives
(e.g. HTML).
Several implicit page objects
like the REQUEST are
accessible.
SAP America 2001, HCM Solutions Conference 24
JSP – Runtime Objects
request HttpServletRequest
current request parameters, attributes, headers, cookies
response HttpServletResponse
current response message, methods related to session tracking
session HttpSession
client‘s session data
application ServletContext
application objects, e.g. shared database connections; logging
out JspWriter
methods to add text to the response message body
config ServletConfig
pageContext PageContext
page Object
SAP America 2001, HCM Solutions Conference 25
1
General Architecture
2
“Welcome” – a simple Example
3
“Employees” – Example with R/3-Data Access
4
A final Comparison
SAP America 2001, HCM Solutions Conference 26
„Employees“ – Example with R/3-Data Access
SAP America 2001, HCM Solutions Conference 27
„Employees“ – Example with R/3-Data Access
SAP America 2001, HCM Solutions Conference 28
Web Server
R
F
C
R/3 System
R
F
Internet
C
Browser
J
C
O
SAP America 2001, HCM Solutions Conference 29
„Employees“ with BSP: First Page
Default.htm
Initialization
<%@ page language="abap" %>
Layout
<html>
<body>
<font size=8> Enter an organizational unit ! </font>
<form method="get">
<input type="text" name="orgunit">
<input type="submit" name="OnInputProcessing(go)"
value="Show employees !">
</form>
</body>
</html>
Input Processing
SAP America 2001, HCM Solutions Conference 30
„Employees“ with BSP: First Page
Employees.htm
Initialization
…
data: org_unit type string.
data: orgunit type short_d.
Runtime Object
* get form field 'orgunit'‚navigation‘ is
org_unit =
used to
request->get_form_field(Runtime
'orgunit'
Object
transport
data ).
orgunit = org_unit.
‚navigation‘ is
used to
* check existency of organizational
navigate to theunit
call function 'Z_EXISTENCY_CHECK'
next page
destination 'ORLANDO_DEMO'
exporting
org_unit
= orgunit
exceptions
nothing_found
= 1
system_failure
= 2
communication_failure = 3
others
= 4.
SAP America 2001, HCM Solutions Conference 31
Layout
Input Processing
if not sy-subrc eq 0.
* set parameter 'myname'
Runtime
Object
navigation->set_parameter(
‚request‘ contains name = 'org_unit'
value of the input value = org_unit ).
field ‚orgunit‘.
* navigate
to page 'welcome.htm'
Accessing
navigation->goto_page( 'error.htm' ).
another R/3else.
system
via
* set
parameter
'myname'
Remote
Function
navigation->set_parameter(
Call
name = 'org_unit'
value = org_unit ).
* navigate to page 'welcome.htm'
navigation->goto_page(
'employees.htm' ).
endif.
„Employees“ with BSP: Second Page
Business Server Page
data: orgunit
Initialization
type short_d.
* get form field 'orgunit'
orgunit = org_unit.
* get employees
call function
destination
exporting
org_unit
begin
end
tables
employees
exceptions
others
'Z_GET_EMPLOYEES'
'ORLANDO_DEMO'
= orgunit
= sy-datum
= '99991231'
= employees
Accessing data
within another
R/3-system via
Remote Function
Call
Page attributes
are accessible in
all event handlers
= 0.
Layout
Input Processing
SAP America 2001, HCM Solutions Conference 32
„Employees“ with BSP: Second Page
The data sources
provided by the
initialization step
are directly
accessible in the
Layout step.
Business Server Page
Initialization
<%@ page language="abap" %>
Layout
<html>
<body>
<table border="1">
<tr>
<td> Lastname </td> <td> Firstname </td> <td> Phone </td>
</tr>
<% data: wa like line of employees.
loop at employees into wa. %>
The Layout part
<tr>
contains script
<td> <%= wa-last_name %> </td>
code mixed with
<td> <%= wa-first_name %> </td>
static formatting
<td> <%= wa-extension %> </td>
directives (e.g.
</tr>
HTML).
<% endloop. %>
</table>
</body>
</html>
Input Processing
SAP America 2001, HCM Solutions Conference 33
„Employees“ with BSP: Second Page
Business Server Page
Initialization
<%@ page language=“javascript" %>
Layout
<html>
<body>
<table border="1">
<tr>
<td> Lastname </td> <td> Firstname </td> <td> Phone </td>
</tr>
<% for (i = 0; i < employees.length; i++) { %>
<tr>
<td> <%= employees[i].lastname %> </td>
<td> <%= employees[i].firstname %> </td>
<td> <%= employees[i].phone
%> </td>
</tr>
<% } %
</table>
</body>
</html>
Input Processing
SAP America 2001, HCM Solutions Conference 34
Since data retrieval and
processing are
completely separated
from the presentation
step,
it's easy to support
JavaScript as an
alternative language for
server-side scripting in
the page.
Interaction of ABAP and
the alternative scripting
language is achieved by
data sources.
Stateful BSP Applications
time
Browser
1
Activity!
First
User
adds
First
User
enters
First
User
Server
responses,
a book
to
his
thesession
shop
commits
his and
holds
shopping
basket
order
objects
mySAP Web
AppServer
Browser
3
each user uses one roll area
runtime->keep_context = 1.
SAP America 2001, HCM Solutions Conference 35
Session 3
Third User enters
the shop
Session 2
2
Session 1
Browser
Internet
Second User
HTTP enters
the shop
Stateless BSP Applications
1
2
Browser
1
Activity!
FirstFirst
User
adds
User
enters
First
User
Server
responses,
a book
to his
the
shop
Second
User
commits
his
session
shopping
basket
commits
his
order closed
order
mySAP Web
AppServer
Internet
Browser
2
3
1
HTTP
Third User
Second
Userenters
enters
the shop
Browser
1
Rollarea only used during
server activity
runtime->keep_context = 0.
SAP America 2001, HCM Solutions Conference 36
3
2
time
Web Server
R
F
C
R/3 System
R
F
Internet
C
Browser
J
C
O
SAP America 2001, HCM Solutions Conference 37
Accessing R/3-Data : SAP Java Connector
Enables communication between any SAP system and Java
Supports inbound (Java calls ABAP) as well as outbound
(ABAP calls Java) communication
Hides all difficult parts like codepages, data type conversions,
connection pooling, etc. from the programmer
Consistent and easy-to-learn class design and API
Highly optimized source code leads to high performance
SAP America 2001, HCM Solutions Conference 38
SAP Java Connector: Architecture
Java applications only use
Jco‘s Java API
Pluggable JCo Middleware
Implementations
RFC Middleware uses classical
RFC library 4.6D through Java
Native Interface (JNI) layer
Future middleware
implementation based on
HTTP/SOAP protocol
JAVA Application
JCO Java API
Middleware Interface
SOAP Middleware
RFC Middleware
JNI Layer
HTTP
RFC Library
RFC
HTTP Port
SAP System
SAP America 2001, HCM Solutions Conference 39
RFC
What‘s a Java Bean?
reusable platform-independent software component
realized as special Java Class
has to be serializable
Contains a ‚setter‘- and a ‚getter‘-method for each public attribute
SAP America 2001, HCM Solutions Conference 40
The Programming Model
The JSP uses a
JavaBean for
accessing Data
Java Web Server
R/3 Data is
accessed by the
Bean via JCo
Bean
JSP
J
C
Servlet
Browser
When the JSP
is requested,
the
corresponding
servlet is
executed
SAP America 2001, HCM Solutions Conference 41
O
R/3 System
R
F
C
<
„Employees“ with JSP: First Page
Java Server Page
<html>
<body>
<font size=8> Enter an organizational unit ! </font>
<form method="get" action="/examples/Employees.jsp">
<input type="text" name="orgunit">
<input type="submit" name="showEmployees"
value="Show employees !">
</form>
</body>
</html>
SAP America 2001, HCM Solutions Conference 42
„Employees“ with JSP: Second Page
Java Server Page
<%@ page language="java" import="com.sap.mw.jco.*" session="false" %>
<html>
<head>
<title>Employees</title>
</head>
<body>
<jsp:useBean id="employees" class="presentation.EmployeeList" />
<table border="1">
<tr>
<td> Lastname </td> <td> Firstname </td> <td> Phone </td>
</tr>
…
SAP America 2001, HCM Solutions Conference 43
„Employees“ with JSP: Second Page
Java Server Page
…
<% employees.setOrgUnit(request.getParameter("orgunit"));
JCO.Table employeeList = employees.getEmployeeList();
for (int i = 0; i < employeeList.getNumRows(); i++) {
employeeList.setRow(i); %>
<tr>
<%for (JCO.FieldIterator f = employeeList.fields();
f.hasMoreElements(); ) {
JCO.Field field = f.nextField(); %>
<td> <%=field.getString()%> </td> <%}%>
</tr> <%}%>
</table>
</body>
</html>
SAP America 2001, HCM Solutions Conference 44
1
General Architecture
2
“Welcome” – a simple Example
3
“Employees” – Example with R/3-Data Access
4
A final comparison
SAP America 2001, HCM Solutions Conference 45
Summary
Criteria
Programming-Model
Business Server Pages
Java Server Pages
Dynamic page
generation
Server-side Scripting
Eventhandler
(OnManipulation)
Server-side Scripting
Servlets
Server-side
scripting
ABAP/JavaScript
Java/JavaScript
Client-side
scripting
JavaScript
JavaScript
Accessing R/3
RFC/BAPIs
SAP Java Connector
SAP America 2001, HCM Solutions Conference 46
Summary
Criteria
Programming-Model
Business Server Pages
Java Server Pages
Development
tools
ABAP Development
Workbench (SE80)
JDK 1.3,
Servlet Engine
(e.g.Tomcat),
IDE (e.g.Jbuilder)
Translation
Linked to R/3 translation
process via SE80
Ressource bundles/
Web Content Management
Deployment/
Transport
Standard R/3 deployment
Java Archive Files
Versioning
Versioning via SE80
Perforce
(external Versioning-Tool)
SAP America 2001, HCM Solutions Conference 47
A final Comparison
Programming-Model
Decision
Criteria
Business Server
Pages
Separation of
Business Logic
and
Presentation
Logic (MVCConcept)
Integration in
Workplace 3.0
Reuse
SAP America 2001, HCM Solutions Conference 48
Java Server Pages
Only JSP
JSP with
JavaBeans/
JavaServlets
A final Comparison
Programming-Model
Decision
Criteria
Training Period
Business Server
Pages
Only JSP
JSP with
JavaBeans/
JavaServlets
No ABAP
No Java
No Java
ABAP
Java
Java
ABAP-Objects
SAP America 2001, HCM Solutions Conference 49
Java Server Pages
A final Comparison
Programming-Model
Decision
Criteria
Accessing Data
R/3-BasisRelease
< = 4.6C
> 4.6C
SAP America 2001, HCM Solutions Conference 50
Business Server
Pages
RFC
Java Server Pages
Only JSP
JSP with
JavaBeans/
JavaServlets
SAPJavaConnector
A final Comparison
Programming-Model
Decision
Criteria
Suitability for
Simple
Applications
Complex
Applications
SAP America 2001, HCM Solutions Conference 51
Business Server
Pages
Java Server Pages
Only JSP
JSP with
JavaBeans/
JavaServlets
Links to further Information
SAP Web Application Server
http://roadrunner.wdf.sap-ag.de:1090/default.htm
SAP Java Connector (documentation and download):
Intranet: http://p28798.wdf.sap-ag.de:1080/index.shtml
Internet: SAP Service Marketplace http://service.sap.com
search for „java connector“
InQmy (documentation and download):
Intranet: http://inqmy.wdf.sap-ag.de:1080/web/inqmy.html
Internet: http://www.inqmy.com
SAP America 2001, HCM Solutions Conference 52
SAP America 2001, HCM Solutions Conference 53