Вы находитесь на странице: 1из 9

Create a Simple BSP - Simple BSP to display text and

call section BSP page using HTML

Step 1 - Create new BSP Application


Using SE80 create BSP Application (I.e.
ZTESTBSP).

Step 2 - Create new page (index.htm)


Right click on BSP object name and select
create->page (with flow logic).

Step 3 – Populate ‘Layout’ tab


Insert the following code into index.htm
layout section.
<%@page language="abap"%>
<%@extension name="htmlb" prefix="htmlb"%>
<html>
  <head>
    <link rel="stylesheet" href="../../sap/public/bc/bsp/styles/sapbsp.css">
    <title> start page of bsp </title>
  </head>
  <body>
    <h1>Welcome to the</h1>
    <h2>SAP Web Application Server</h2>
    <p>
    <font size="...">Example text</font>
    <% do 5 times. %>
    <font size="<%=sy-index%>">
    Example text
    </font>
    <% enddo.  %>
    <form action=start.htm>
        <input type="submit" value="push" name="Push">
  </body>
</html>
 

Step 4 – Create new page (Start.htm)


Right click on BSP object name and select
create->page (with flow logic).

Step 5 – Populate ‘Layout’ tab


Insert the following code into start.htm
layout section.
<%@page language="abap"%>
<%@extension name="htmlb" prefix="htmlb"%>
<html>
  <head>
    <link rel="stylesheet" href="../../sap/public/bc/bsp/styles/sapbsp.css">
    <title> page 2 of bsp </title>
  </head>
  <body>
    <h2> list of airlines </h2>
    <table border="1">
      <tr>
        <th> No. </th>
        <th> Airline </th>
        <th> ID </th>
        <th> URL </th>
      </tr>
 
      <% LOOP AT it_flight INTO wa_flight. %>
      <tr>
        <td> <%=SY-TABIX %> </td>
        <td> <%=wa_flight-carrid %> </td>
        <td> <%=wa_flight-connid %> </td>
        <td> <%=wa_flight-fldate %> </td>
      </tr>
      <% ENDLOOP. %>
    </table>
  </body>
</html>
 
Step 6 – Setup ‘Page Attributes’ (Data
declarations)

it_flight
wa_flight

FLIGHTTAB
SFLIGHT

Step 7 – Insert data retrieval code


(Event Handler)
Insert code to populate internal table with
data from flight table. Place in the
OnInitialization event within the ‘Event
Handler’ tab.
SELECT CARRID CONNID FLDATE
UP TO 10 ROWS
FROM sflight
INTO CORRESPONDING FIELDS OF TABLE
it_flight.

Step 8 – Activate and test


Save everything and press the activate
button, if all is ok press the test button
which should open up a browser window
and display your newly created BSP.
Creating a BSP Application class to help store and
pass data betwenn your BSP pages

Adding an application class to your BSP


allows you to store and process data
outside of your individual BSP pages. This
means that data is accessible across all
pages and is not lost whether BSP is
statefull or not. One disadvantage of using
this method of storing data rather than
passing values between each page is that it
might not be possible to link directly into
the second or 3rd page of the application
as processing maybe be required from
page 1 inorder to make data available to
other pages.

An advantage though is that you can pass


data contained within tables between pages
which cannot be done via the navigation-
>set_parameter command (within
OnInputProcessing).

Step 1 - Create basic BSP Application


Using Se80 to create a basic BSP
Application (I.e. ZTESTBSP). Also ensure
that it has been set to sateful within the
'Properties' tab.

Step 2 - Goto properties of BSP


application
Double click on the BSP application name
and then select the properties tab

Step 3 - Define and create application


class
Within the application Class field enter a
name such as Z_CL_TESTBSP and double
click on it. Select yes to the popup asking if
you want to create class and the one
asking if you want to save your BSP.

Step 4 - Application class type


You will be presented with another popup
asking for class type and properties, leave
default selections as below and press save.

Step 5 - All done


Right thats it, your application class is
created, you can now define Attributes and
Methods here and access them within your
BSP application using the 'application'
instance name (not sure what the correct
name of this is but see examples below).

Step 6 - Define Attributes


If you define an attribute (i.e. test) within
your application class you can then access
this attrinute within your BSP application
using the below syntax.

data: ld_test type string.


ld_test = application->test.

Step 7 - Define Method


If you define a method (i.e. GET_DETAILS)
within your application class you can then
access this method within your BSP
application using the below syntax.

CALL METHOD application->GET_DETAILS.

Вам также может понравиться