本文参考官方的 BSP Tutorials -- A Small BSP Application 进行测试
http://help.sap.com/saphelp_nw04/helpdata/en/1a/c5133a62983c0ae10000000a114084/content.htm
测试环境 :
1. SE80 创建 BSP Application
注 : 双击 BSP Application Name, 本例为 ZBSP02, 可以为整个程序设定 Navigation 信息
1. First Page – Default.htm
l Layout code:
<%@page language="abap" %>
< html >
< body BGCOLOR = "#B5E1D2" >
< h2 > Welcome to our Online Book Catalog! </ h2 >
< p >
This bookshop offers a small selection of interesting books.
< p >
To display all the books written by an author,
enter the name of the author in the field below.
< p >
To display all the authors whose books we offer,
choose < i >to list of authors</ i >.
< p >
To display all books we offer, just choose
< i >books by this author</ i > without entering a name .
< p >
< img height = "130" src = "../PUBLIC/Tutorial/book2.jpg " >
< img height = "130" src = "../PUBLIC/Tutorial/book2.jpg " >
< img height = "130" src = "../PUBLIC/Tutorial/book2.jpg " >
< p >
< form method = "post" >
last name
< input type = text name = "authorlname" value = "" >
first name
< input type = text name = "authorfname" value = "" >
< p >
< input type = submit name = "onInputProcessing(select)"
value = "books by this author" >
< p >
< input type = submit name = "onInputProcessing(authors)"
value = "to list of authors" >
</ form >
</ body >
</ html >
l Event Handler
注 : 红圈处文档为 navigation, 激活时总是报错 , 按照提示信息修正为 _m_navigation 后 , 激活成功 .
另, 其实此处应该为大写的 NAVIGATION, 奇怪的是在这个地方ABAP竟然又区分大小写了. SPAN { font-family: "Yahei Mono"; font-size: 10pt; color: #000000; background: #FFFFFF; }
1. Second Page – Authors.htm
l Layout Code:
<%@page language="abap" %>
< html >
< body BGCOLOR = "#B5E1D2" >
< h2 > List of Authors </ h2 >
< table border = 1 >
< tr >
< td >< b >first name </ b ></ td >
< td >< b >last name </ b ></ td >
</ tr >
<%
data : wa_author type bsauthline.
loop at authors into wa_author.
%>
< tr >
< td > <%= wa_author-authfnam %> </ td >
< td > <%= wa_author-authlnam %> </ td >
</ tr >
<%
endloop .
%>
</ table >
</ body >
</ html >
l Event Handler
l Page Attributes
l Type Definitions
1. Third Page – Results.htm
l Layout Code:
<%@page language="abap" %>
< html >
< body BGCOLOR = "#B5E1D2" >
< h2 > Your Book Search Results </ h2 >
<%
if books is initial .
%>
< h3 > Sorry, we found no matches for <%= authorlname %> ,
<%= authorfname %> . </ h3 >
<%
else .
%>
< h3 > The matches for this search are: </ h3 >
< table border = 1 >
< tr >
< td > ISBN </ td >
< td > Title </ td >
< td > Author </ td >
</ tr >
<%
data : wa_book type BSBOOK.
loop at books into wa_book.
%>
< tr >
< td > <%= wa_book-isbn %> </ td >
< td > <%= wa_book-title %> </ td >
< td > <%= wa_book-authfnam %> <SPACE>
<%= wa_book-authlnam %> </ td >
</ tr >
<%
endloop .
%>
</ table >
<%
endif .
%>
</ body >
</ html >
l Event Handler
l Page Attributes
注 : 1. 页面中要传递的参数 , 要勾上 Auto 标记 , 不然值传不过来 . 2. 后面的表类型就是在数据字典中定义的啦
5. 整体运行效果
注:这个 Trial 版本中 , 本例用到的表都是空的 , 本例的数据是我手工添加的.