SAP BSP 入门1

来源:互联网 发布:京东数据分析师笔试题 编辑:程序博客网 时间:2024/05/12 22:40

Components of a BSP program lists:

 

 

1.    Business Server Pages: Define the Web pages that are displayed to the user. Each BSP contain two parts: static part which can use HTML or XML, dynamic part which can use ABAP or Javascripts.
·    Pages with flow logic: Including layout and attributes and also event handler which used to do the control work
·    Page fragments: Including layout, you can include this page in every common place for simple implementation, no URL defined.
·    Views: Used to display data
·    One table: BSPDEFPAG
2.    Application class
Encapsulate the business logic required in the application.
Instance name: application
The Class must be a global class defined in the class builder
3.    MIME(Multipurpose Internet Mail Extension) objects
For example: Audio, Video, Graphics, Stylesheet.
Goto MIME object: SE80
4.    Topic
5.    Navigation structure
Define the sequence of BSPs within an application. The navigation path are maintained in a table as a property of BSP application.
6.    Controller

 

Directives:
·    BSP directive tag definition:
Enclose with <% and %>
·    Page directives tag definition:
<%@page language=’’ABAP’’%>
·    Include directive
<%@ include file = ‘’fragment.htm’’%>
·    Inline Code :
<% data ls type string.%>
·    Output of a variable values
<%= wa-carrid%>
·    Comments
<%– xxxxxx –%>

 

Layouts of a BSPs.

 

BSP structure :

3
Page types:
–F: page with flow logic
–V: View
–P: page fragment

BSP events:
When the request coming,  the process follow the below logic:
1.       OnCreate: This event just execute once for stateful, otherwise once the BSP is called.
2.    OnRequest: Executed each time when the BSP is called, and restore the internal data structure from the request.
3.    OnInputProcessing: Used for process the user inputs and subsequent navigation to the next pages.
4.    OnInitialization: Executed after OnRequest, mainly for data retrieval, such as read data from database, filling internal tables….
5.    Layout:
6.    OnManipulation: Used for manipulating the data stream according to the layout.
7.    OnDestroy: The last to be executed, for deleting the information of the BSP application.

 

Processing user input:

 

Statements: <Form>…….</Form>

Field TypeHTML TagNoteInput/Output type<input type=”text”

 

name=”A”

value=”B”>

The field is filled with the

 

value B.

Password field<input type=”password”

 

name=”A”>

 Checkbox<input type=”checkbox”

 

name=”A”

value=”X”>

The name/value pair A=X

 

is then sent with the HTTP

request to the receiver, if the

checkbox is ticked.

Radio button<input type=”radio”

 

name=”A”

value=”X”>

All of the selection buttons

 

in a group have the same

name (but different values).

Dropdown list<select name=”A”>

 

<option value=”B”>

Disp

</option>

</select>

The user sees the values

 

specified between

<option> and

</option> (in this

example, Disp).

Input area with

 

more than one line

<textarea name=”A”

 

rows=”…”

cols=”…”>

 Send button<input type=”submit”

 

name=”A”

value=”Send”>

The text specified after the

 

value addition appears on

the button as a label.

Static Navigation:

<Form method=……. Action=……>

AttributeDescriptionmethod=″type″This attribute specifies how the system sends the form

 

to the server (that is, which method is used).

GET

The query string is appended to the URL,

separated by a question mark (?). The query

string appears in the address bar in the browser!

The maximum length of the query string is 4 KB.

This is the default method.

POST

The data is sent to the server in the HTTP body,

which means that it does not appear in the address

bar in the browser. The data is not buffered in an

HTTP cache. There is no limit to the length of the

query string.

ACTION=″execution″This attribute specifies the program that the query

 

string executes on the server.

Example:

<a href=http://xxxxx> Text </a>

<a href=”bsp.htm”> Text </a>

<Form action = “bsp.htm” method = “get”>

<input type = “submit” value=”click” name=”BUTTON”>

 

 

Global Objects:

4

 

 

Stateful and Stateless BSP Applications

1. Stateful programming of a BSP application means that the application context is retained after the response and is available when you continue to work with the application.

Advantage:  Easy to program
Disadvantage: Waste resources

2. Stateless programming of a BSP application means that a new application context is created for each new request. In addition when you work with the BSP application, the old context is no longer available.

Advantage: Resource are only required on the SAP Web AS during HTTP request processing, that is save resources
Disadvantage: Data is required over serveral  BSPs needs to be read from the database, that is lower performance

3. Mixed Mode for BSP programming
How to set BSP application as stateful & stateless
1). Setting the flag on the properties tab
2). On runtime with method:
runtime->keep_context = 0     After this, the BSP application is excuted as stateless
runtime->keep_context = 1     After this, the BSP application is excuted as stateful
3). If the BSP is stateful application, and you can define the lifetime of this BSP application, there are options listed below:
Lifetime: Session
The page object of this BSP is not deleted, until the application become stateless or is ended.
navigation->exit ().
Lifetime: Page Chagne
The page object of this BSP is not deleted, until the applicaiton become stateless or is ended or the page change to another
navigation->goto_page() or navigation->next_page()
Lifetime: Request
The page object of this BSP is deleted after each HTTP request

4. Data transfer in stateful BSP application
If you want to transfer data between two BSP application, for example, BSP1 to BSP2, you need do the following steps:
1). Make the BSP1 stateful
2). Transfer the data to application object, for example, you want to transfer table, take the below statement:
In BSP1: application->table = itab1.
3). Goto page BSP2, and excute with the below statement:
In BSP2: itab2 = application->table.
4). Make the BSP1 stateless.

5. Data retain in stateless BSP application
There are two technic for this topic:
1). Hidden–>Storage of data in BSP
<input type=”hidden” name=”counter” value=”5″>
Disadvantages:
a. Stored in character string
b. Hidden field must be elementary or field, no structure and table
c. Part of HTML page, need trigger from user
2). Cookies
With two type, client-side cookie and server-side cookie
Client-side cookies:
How-to use:
ICF use IF_HTTP_ENTITY interface to provide sending/receiving cookies, this interface was implemented by CL_HTTP_REQUEST and CL_HTTP_RESPONSE
How-to delete:
Method: DELETE_COOKIE_AT_CLIENT
Class: CL_HTTP_RESPONSE
Tips: How-to change date to cookies required date format
CL_BSP_UTILITY=>DATE_TO_STRING_HTTP
Server-side cookies:
Class: CL_BSP_SERVER_SIDE_COOKIE
Storage: In DB cluster table SSCOOKIE
Advantages:
a. No limitation to the number of cookies(clinet-side: 300 cookies)
b. No limitation for the volumn(4KB for client-side cookies)
c. Complex data could be stored with appropriate type
Tips:
Show server-side cookies:  BSP_show_server_cookies
Clear server-side cookies: BSP_clean_up_server_cookies
Commonly-used technical:
Combination with the client-side cookies and server-side cookies, In server-side cookies, store sensitive data, in client-side cookies, store identity information.
Global objects and session handling

5

 

 

 

原创粉丝点击