Beruflich Dokumente
Kultur Dokumente
This document describes the how to create and execute the BSP Application.
Step1: SE80 is the transaction where you can build the BSP Application.
Select BSP Application as shown below and provide the name of the BSP Application name and press
enter.
Step2: Provide the description of the BSP Application and click create button.
Step7: Now go to SAP Logon Pad and note down the application server.
Step8: Now go to C:\WINDOWS\system32\drivers\etc\hosts.txt, Open this hosts.txt file and provide the
application server and URL of the BSP Application as below.
Step9: Now you can execute the BSP Application in web browser.
Go to transaction SE80. Select BSP application and input the name of the BSP application that you want
to create.
Click save.
You can observe the pages with flow logic and under that you can find default.htm page in the BSP
application tree.
Change the code in the layout as shown in the image below or copy and paste the code given below in
the layout window.
In the Event Handler tab, under OnInputProcessing tab, write the code as shown below or copy and
paste the code that is given below.
Code under OnInputProcessing.
CASE EVENT_ID.
WHEN 'select'.
NAVIGATION->SET_PARAMETER( 'matnr' ).
SELECT * FROM MARA INTO TABLE I_MARA WHERE MATNR BETWEEN MATNR AND MATNR2.
WHEN 'materials'.
SELECT * FROM MARA INTO TABLE I_MARA.
WHEN OTHERS.
ENDCASE.
Click on the BSP application name and input as shown below.
Save, check and activate the BSP application and then execute the application. The page would be
displayed as shown below.
Enter the material numbers in the textboxes and then click on Get details.
The output would be as follows.
The output is a result of the select query that we fired selecting the specified set of fields.
A Simple BSP application to select a range of Sales Document and display the result on
the next Page
This Document explains about a simple BSP application where we can give a range of Sales Document
Number and then the respective data related to that Sales Document Number is displayed.
The factors that have been considered while doing this BSP Application.
First to create a BSP Application and execute it on the browser we have to include the IP address
of the particular system and browser in the drivers program. We can do this by going to START-
>RUN->DRIVERS->ETC
We can use HTML or HTMLB or any other coding to construct a BSP application. (Here we are
using HTMLB)
We have considered table VBAP
We have use the class CL_HTMLB_MANAGER and CL_HTMLB_EVENT and created their
instances.
Steps to create a BSP Application.
1. Go to Transaction SE80, select BSP Application and give the name of the Application you want to
create. Press ENTER.
2. A pop-up window appears where we have to give a short description and press Create.
7. Activate the page and the application as well. Then we will see a hierarchy of the application and
pages.
8. Now go to the page First.htm of what we have created.
9. This hierarchy of application and pages are from the Repository Browser. On the layout of the
page to include any input fields or buttons or tabular structures we have to go to the Tag Browser,
from where we have to select the tags.
10. After going to the Tag Browser. Go to BSP Extensions -> Transportable -> HTMLB.
11. Once we click open the HTMLB, there are many tags. For our purpose on the first page we need.
Since we need to enter a range of Sales Document Numbers, we need 2 input fields.
One label to indicate the input field.
One Button, which on clicking will get us the required data.
12. So we drag and drop the required TAGS from the Tag Browser. Our Coding with all the Input fields,
buttons and labels will be like this.
13. Here in the above coding the variables w_vbeln1 and w_vbeln2 have to be declared in Page
Attributes and the IDs given to each input field or button is of at most importance because they
uniquely identify each Field or button.
14. Here in the above coding the variables w_vbeln1 and w_vbeln2 have to be declared in Page
Attributes and the IDs given to each input field or button is of at most importance because they
uniquely identify each Field or button.
15. Now, we have to write our main code in the event OnInputProcessing. For that purpose we have
to go to the Event Handler tab and select OnInputProcessing event there.
16. Since we are using the class CL_HTMLB_MANAGER we have to call this class and have to create
an Instance according to it.
We also have to write the Page Navigation logic here because we are Navigating from the first
page to the second page. Create the Second Page and name it as Second.htm.
19. Here on the Second Page also we have to define the page attributes like this.
20. Now we have to write the code in the INITIALIZATION event. Because this event triggers when
ever a new page is called.
21. The code is as follows.
* event handler for data retrieval
data :
w_event type ref to cl_htmlb_event ,
w_eventid type string ,
w_obj type ref to object ,
w_obj1 type ref to object ,
w_vbeln type ref to cl_htmlb_inputfield ,
w_vbelnval type string ,
w_vbeln1 type vbap-vbeln ,
w_vbeln2 type vbap-vbeln .
* Calling Method for w_vbeln
CALL METHOD cl_htmlb_manager=>get_data
EXPORTING
request = runtime->server->request
name = 'inputfield'
id = 'i_vbeln'
receiving
data = w_obj
.
w_vbeln ?= w_obj . " Passing the object vale to w_vbeln
w_vbelnval = w_vbeln->value . " now the value from w_vbeln is passed to
" w_vbelnval
w_vbeln1 = w_vbelnval . " Now value from w_vbelnva is passed to
" w_vbeln1
* Here we have called the class cl_htmlb_manager and an instance get_data has
* * been created.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = w_vbeln1
IMPORTING
OUTPUT = w_vbeln1.
* Function to change external format to the internal format
* Calling Method for w_vbeln
CALL METHOD cl_htmlb_manager=>get_data
EXPORTING
request = runtime->server->request
name = 'inputfield'
id = 'i_vbeln1'
receiving
data = w_obj .
w_vbeln ?= w_obj . " Passing the object vale to w_vbeln
w_vbelnval = w_vbeln->value . " now the value from w_vbeln is passed to
" w_vbelnval
w_vbeln2 = w_vbelnval . " Now value from w_vbelnva is passed to
" w_vbeln2
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = w_vbeln2
IMPORTING
OUTPUT = w_vbeln2 .
select * from vbap into table t_vbap where vbeln between w_vbeln1 and w_vbeln2.
22. Save and activate the application.
Now when we execute the application. The Screen will be like this.
On Clicking the button Get Data. The output would be like this.
Providing F4 help in the BSP Application
Step1: To provide f4 help for the input field, we have to add showHelp and onValueHelp attributes to the
inputField tag. Provide the values to those attributes as shown below.
Step2: The attribute onValueHelp has to assign a function, which is to be defined. In this function,
using the document.open statement, we can open a page as a window to the input field as F4 help.
Step3: Create a page with the name specified in the function getCustomer (). And in the event
onRequest event handler get the data for f4 help.
Step4: To transfer the selected value in the f4 help window to the input field, we need to write a function
which is mentioned in button tag.
Here, we define the function transf containing value of the parameter to be transferred in to input field.
Now, we have to catch this parameter value in the main page by providing this code.
document.getElementById("ip_kunnr").value = fval;
In Layout
The code in customer.htm is
In layout:
Here, we have to use the attribute onClientClick and a function name is to be assigned to this attribute.
In this function, we have to write the code for transfer the selected value in to the input field after pressing
the button.
In onInputProcess:
In onRequest:
Step6:
Go to Transaction SE80->
Select BSP Application & Enter a Name to create a new BSP Application (Eg:yhbsplistbox):
In Layout Code:-
<%@page language="abap"%>
<%@extension name="htmlb" prefix="htmlb"%>
<htmlb:content design="classic+design2002+design2003">
<htmlb:page title = "First Page ">
<htmlb:form>
<htmlb:dropdownListBox id = "myDropdownListDay"
tooltip = "Quick info for myDropdownListBox">
<%
LOOP AT t_mod INTO fs_mod.
%>
<htmlb:listBoxItem key = "<%=fs_mod%>"
value = "<%=fs_mod%>"/>
<%
%>
<%ENDLOOP.%>
</htmlb:dropdownListBox>
</htmlb:form>
</htmlb:page>
</htmlb:content>
In Event-handler on Initilalization.
Page Attributes:-
In Type Definition:
TYPES:
BEGIN OF types_mod,
modul TYPE zemployee-modul,
END OF types_mod,
fs_module type
standard table
of TYPES_MOD.
OUTPUT:
Using controller in BSP Application
Create a BSP Application in SE80 e.g., YH1328_TEST_BSP and provide short description and create it.
Right click on the application and create-> controller and enter name as main.do along with description
and press continue.
3. Populating Controller Class
Enter the name of your controller class i.e. yh1328_controller_main. We also need to create this class in
SE24
In the Properties Tab of the class yh1328_controller_main ensure its super class is
CL_BSP_CONTROLLER2.
5. Redefining Methods of the Class
We need to redefine some methods inherited from the superclass i.e. DO_INIT and DO_REQUEST.
The DO_INIT Method behaves just like initialization event wherein we provide the data
declaration.
Here we can fetch the data form the database table SFLIGHT into internal table t_flight
The attributes have to be set in the Attributes Tab of the Class
Select the method DO_REQUEST and press the Redefine button and open the method in change mode.
In this method we would be calling Layout (View) we create a reference variable referencing the page and
then call the methods CREATE VIEW and pass it the actual view (not yet created). We then call the view.
.
In SE80 right click on the BSP Application and select Create->Page->Page Type-> View
12. Execute the controller: Go to the controller index and double click. Use the test (execute) button to
view the results.
Step1: Create the BSP Application ZBSP_TABLE_EXT and page name First.htm.
Step3: when particular table row is selected then the corresponding detailed information should be
displayed.To achieve this functionality, we have to select selectionMode, onRowSelection, keyColumn
in tableview tag as shown.
Step4: Consider the Tableview event handler too along with Inputfield event handler in the EVENT
HANDLER.
types:
begin of types_range,
sign(1),
option(2),
end of types_range.
Step1: In SE80 (Object Navigator), For HTML tags, Go to TAG BROWSER wherein select the BSP
Extensions as below.
Step2: In TRANSPORTABLE tree structure, select HTMLB where we can find all HTML tags like Label,
Button, and Input Field etc.
Step4: To place the Label and Input field in the web browser, go to Tab browser->BSP Extensions-
>Transportable->Htmlb. Go to Label html tag, drag and drop it into Layout. Similarly same as for input
field.
Step5: User-define data types can be defined in Type Definition tab strip.
Step6: Page Attributes are parameters declared explicitly for one page. We can access the page
attributes from Layout and event handler.
Step7: When the button is pressed, the process to be executed can be written in OnInputProcess event
handler. Copy the some event handler code from Input Field Documentation and do necessary
modifications as shown.
Step8: To display table, we have to use tableview html tag. Provide the id and table name as shown.
The values can be navigated between pages either by using NAVIGATION OBJECT or COOKIES.
Using NAVIGATION OBJECT, we can transfer only the values where as by COOKIES, we can pass
tables too.
Step1: You can find the Objects and their signature for individual events handler by choosing
SIGNATURE button in web application browser.
Step2: In this navigation object, we have methods which are used to determine the characters of
subsequent page and the methods which can be used to pass the values from one page to its
subsequent pages.
We can use NEXT_PAGE method to determine the subsequent page and SET_PARAMETER method to
transfer the values between pages.
Step3: To transfer the values between pages, we have to define the parameters as AUTO PAGE
ATTRIBUTE (in case of OBJECT NAVIGATION) as shown.
Step4: In event handler,
Step5: We can also transfer the values using COOKIES too. Here, we have to set the cookie (using
NAME parameter) and get the cookie in subsequent page.
Step6: We have to get this cookie in subsequent page of OnRequest Event handler as shown below.
Create Server-Side Cookies
Yours is a stateless or stateful application. if its stateful, instead of cookies, you can use application class
to hold the data
It is a stateless application; I want to reduce the waiting time for a customer by preparing cookies for that
particular customer in advance.
Go to SE80
Create a BSP application
Create a page
Save, check, activate it, screen appear like this and click ok button
Create page
</body>
</html>
Click on ok button
Then displaying like this
Then go to client server (our system) where would be stored cookies, go to that path, my system path I
shown here.
STEPS:
Create a BSP application by the name zradiodropdown and create a page named dropdown.bsp.
In the layout tab of the BSP page, write the following code as shown below:
CODE :
<%@page language="abap"%>
<%@page language="abap" forceEncode="html"%>
<%@extension name="htmlb" prefix="htmlb"%>
<%@extension name="bsp" prefix="bsp"%>
<htmlb:content id="content" design="classic+design2002+design2003"
controlRendering="sap"
rtlAutoSwitch = "true">
<htmlb:page title = "BSP Extension: HTMLB / Element: radioButtonGroup &
radioButton">
<htmlb:form>
<htmlb:radioButtonGroup id = "myRadioButtonGroup1" >
<htmlb:radioButton id = "activate" text = "activate = onClick"
onClick="myClick" />
<htmlb:radioButton id = "deactivate" text = "deactivate = onClick"
onClick="myClick" />
</htmlb:radioButtonGroup>
<br>
<br>
<htmlb:dropdownListBox id = "mydropdownListBox1" >
<htmlb:listBoxItem key = "key_vbak" value = "vbak" />
<htmlb:listBoxItem key = "key_vbap" value = "vbap" />
</htmlb:dropdownListBox>
<% if it_vbak is not initial.%>
<htmlb:tableView id="tv_vbak" table="<%= it_vbak%>">
</htmlb:tableView>
<%endif.%>
<% if it_vbap is not initial.%>
<htmlb:tableView id="tv_vbap" table="<%= it_vbap%>">
</htmlb:tableView>
<%endif.%>
</htmlb:form>
</htmlb:page>
</htmlb:content>
In the page attributes tab of the page, create the attributes as shown in the image below.
In the Event handler tab of the BSP page, write the following code as shown below.
CODE:
Save, check, activate and execute the application. Click the execute icon to execute the application.
CLICK ON OK BUTTON.
Click on the activate button and select a drop down list box element. i.e VBAK
The below screen is the output of the VBAK table.
Click on the activate button and select the drop down list box. i.e. VBAP
Go to transaction SE80. Select BSP application and input the name of the BSP application that you want
to create. Press Enter or click on the display icon.
Enter the name and short description of the application and click on the save icon.
Enter the name of the page that you want to create. In this case it is the treepage.htm that I am creating.
Enter the name, description of the page, select the Page with Flow Logic radio button and click on
continue. Create three pages in the same way and name them as per your requirement or convenience.
We proceed with providing the layout, attributes and the Event handling of the respective pages.
Go to treepage.htm, delete the existing code and write the following code in the layout tab of the page.
Code in the layout Tab.
<%@page language="abap"%>
<%@page language="abap" forceEncode="html"%>
<%@extension name="htmlb" prefix="htmlb" %>
<%@extension name="bsp" prefix="bsp" %>
<htmlb:content id = "content"
design = "classic+design2002+design2003"
controlRendering = "sap"
rtlAutoSwitch = "true">
<htmlb:page title="BSP Extension: HTMLB / Element: Tree" >
<htmlb:form>
<h2><htmlb:label for="p_matnr" text="MATERIAL NUMBER" />
<htmlb:inputField id="p_matnr_low" value="<%= matnr_low %>" />
<htmlb:label for="p_matnr" text="TO" />
<htmlb:inputField id="p_matnr_high" value="<%= matnr_high %>" /></h2>
<htmlb:tree id = "materialtree"
title = "materialtree"
tooltip = "material information"
toggle = "X" >
<htmlb:treeNode id = "material"
text = "material"
isOpen = "true"
tooltip = "material">
<htmlb:treeNode id = "mara"
text = "mara"
onNodeClick = "mara"/>
<htmlb:treeNode id = "mard"
text = "mard"
onNodeClick = "mard"/>
</htmlb:treeNode>
</htmlb:tree>
<br>
<br>
<htmlb:tree id = "sapinformation"
title = "sap information"
tooltip = "sap information"
toggle = "X" >
<htmlb:treeNode id = "sdn.sap"
link = "https://www.sdn.sap.com"
text = "sdn.sap.com"
isOpen = "true" />
<htmlb:treeNode id = "saptech"
link = "http://www.saptechnical.com"
text = "sap technical"
isOpen = "true" />
</htmlb:tree>
<br>
<br>
<% if it_mara is not initial.%>
<htmlb:tableView id="tv_mara" table="<%= it_mara %>">
<htmlb:tableViewColumn columnName="MATNR"></htmlb:tableViewColumn>
<htmlb:tableViewColumn columnName="ERSDA"></htmlb:tableViewColumn>
<htmlb:tableViewColumn columnName="ERNAM"></htmlb:tableViewColumn>
<htmlb:tableViewColumn columnName="LAEDA"></htmlb:tableViewColumn>
<htmlb:tableViewColumn columnName="AENAM"></htmlb:tableViewColumn>
</htmlb:tableView>
<% endif.%>
<% if it_mard is not initial.%>
<htmlb:tableView id="tv_mard" table="<%= it_mard %>">
<htmlb:tableViewColumn columnName="MATNR"></htmlb:tableViewColumn>
<htmlb:tableViewColumn columnName="WERKS"></htmlb:tableViewColumn>
<htmlb:tableViewColumn columnName="LGORT"></htmlb:tableViewColumn>
<htmlb:tableViewColumn columnName="PSTAT"></htmlb:tableViewColumn>
<htmlb:tableViewColumn columnName="LVORM"></htmlb:tableViewColumn>
</htmlb:tableView>
<% endif.%>
</htmlb:form>
</htmlb:page>
</htmlb:content>
In the Event Handler tab of treepage.htm, under OnInputProcessing event, write the following code.
Code:
* event handler for checking and processing user input and
* for defining navigation
DATA: event TYPE REF TO CL_HTMLB_EVENT.
event = CL_HTMLB_MANAGER=>get_event( runtime->server->request ).
DATA: MATNO_low TYPE REF TO CL_HTMLB_INPUTFIELD.
MATNO_low ?= CL_HTMLB_MANAGER=>GET_DATA(
REQUEST = RUNTIME->SERVER->REQUEST
NAME = 'inputField'
ID = 'p_MATNR_low' ).
DATA: MATNO_high TYPE REF TO CL_HTMLB_INPUTFIELD.
MATNO_high ?= CL_HTMLB_MANAGER=>GET_DATA(
REQUEST = RUNTIME->SERVER->REQUEST
NAME = 'inputField'
ID = 'p_MATNR_high' ).
DATA: tree_event TYPE REF TO CL_HTMLB_EVENT_TREE.
tree_event ?= event.
node = tree_event->node.
if matno_low is not initial and matno_high is not initial.
matnr_low = matno_low->value.
matnr_high = matno_high->value.
case node.
when 'mara'.
select * from mara into table it_mara where matnr between matnr_low and
matnr_high.
WHEN 'mard'.
select * from mard into table it_mard where matnr between matnr_low and
matnr_high.
endcase.
endif.
Save, Check and activate the treepage.htm. Save, check and activate the application.
Enter the login details in the window to continue executing the application.
The screen looks as shown below. Input the values as shown below and click on the treenode named
mara.
The output looks as follows.
Now click on the treenode mard for the storage location data of the materials.
Now we are done with displaying the table contents using tree on the BSP Application pages.
BSP Application using MVC Architecture - Displaying
Business Partner data using a BAPI
By Raghava Vakada, Mouri Tech Solutions
Requirement: To display business partner data using the BAPI bapi_bupa_search_2 on a BSP
application view.
STEPS:
Go to transaction SE24 and enter the name of the class as shown below.
In the pop up window that appears, enter the description and then click on the save button.
In the class, go to the properties tab and then specify the superclass for the new model class so that all
the methods and attributes will be inherited to the model class.
Add attributes to the new model class. Please create table types for those attributes in the tables tab of
the BAPI. Here, you can see that I have used the table types to refer to the attributes of our class.
Add a method to the new model class to get the business partner details
CREATING VIEWS.
1) Create view: In transaction SE80, Right-click on the BSP application name and navigate to
CreatePage.
As shown below, enter the name and description of the view that you want to create. Select the radio
button View, and then click on the Continue button.
Give the page attributes of the view. The attribute of the view is an object reference of the model class
that we created previously.
Modify layout code for the search view (input.htm) as shown below.
Code :
Code :
<%@page language="abap"%>
<%@extension name="htmlb" prefix="htmlb"%>
<htmlb:content design="design2003">
<htmlb:page title = "Input page ">
<htmlb:form>
<P><CENTER>
<BR><BR>
<BR><BR>
<htmlb:label for="//BUPAOBJ/ADDRESSDATA.CITY1" />
<htmlb:inputField value="//BUPAOBJ/ADDRESSDATA.CITY1" />
<htmlb:label for="//BUPAOBJ/CENTRALDATA.PARTNER" />
<htmlb:inputField value="//BUPAOBJ/CENTRALDATA.PARTNER" />
<htmlb:label for="//BUPAOBJ/CENTRALDATA.MC_NAME1" />
<htmlb:inputField value="//BUPAOBJ/CENTRALDATA.MC_NAME1" />
<htmlb:label for="//BUPAOBJ/CENTRALDATA.SEARCHTERM1" />
<htmlb:inputField value="//BUPAOBJ/CENTRALDATA.SEARCHTERM1" />
<htmlb:button text = "GET BUPA" onClick = "myclick1" />
</htmlb:form>
</htmlb:page>
</htmlb:content>
Modify layout code for the search view (output.htm) as shown below.
Code :
<%@page language="abap"%>
<%@extension name="htmlb" prefix="htmlb"%>
<htmlb:content design="design2003">
<htmlb:page title = "Output page ">
<htmlb:form>
<P><CENTER>
<BR><BR>
<BR><BR>
<htmlb:tableView id="SEARCHRESULTS" table="//BUPAOBJ/SEARCHRESULT"
visibleRowCount="10" width="10">
<htmlb:tableViewColumns>
<htmlb:tableViewColumn columnName="PARTNER"/>
<htmlb:tableViewColumn columnName="ADDRESSGUID"/>
<htmlb:tableViewColumn columnName="ADDRESSTYPE"/>
<htmlb:tableViewColumn columnName="COMPANY_PARTNER"/>
<htmlb:tableViewColumn columnName="PSTAT"/>
</htmlb:tableViewColumns>
</htmlb:tableView>
<P><CENTER>
<BR><BR>
<htmlb:tableView id="BAPIRET2"
table="//BUPAOBJ/RETURN"
visibleRowCount="10" width="10">
<htmlb:tableViewColumns>
<htmlb:tableViewColumn columnName="TYPE"/>
<htmlb:tableViewColumn columnName="MESSAGE"/>
<htmlb:tableViewColumn columnName="PARAMETER"/>
<htmlb:tableViewColumn columnName="SYSTEM"/>
</htmlb:tableViewColumns>
</htmlb:tableView>
</htmlb:form>
</htmlb:page>
</htmlb:content>
create a controller for the application as shown below. Right click on the application name Create
Controller.
Input the description of the controller and click on the continue button.
Double click on the controller class to enter into it. Give the attributes of the class as shown.
_ Redefining The Controller Class Methods
to use our model and views in controller class zcontroller_bupa.do, we have to redefine some of the
methods inherited from base class cl_bsp_controller2 using the class builders redefine function.
The redefinition steps automatically add commented coding (shown in bold in the do_init example below:
method do_init .
* call method super->do_init.
* .
endmethod.
If you uncomment those lines, you would execute the method implementation of the parent class. this is
helpful when you want to carry out the parent logic and some additional custom logic. we dont want to
reuse functionality of the parent class in the example, however, so be sure to delete the commented code
before adding the new code.
After that double click on the method do_init to implement it (write the code in the method).
CODE:
method DO_INIT.
BUPAOBJ ?= me->create_model(
class_name = 'ZBUPA_MODEL'
model_id = 'BUPAOBJ' ).
endmethod.
Follows the same procedure for the do_request, do_handle_event.
CODE:
method DO_REQUEST.
*CALL METHOD SUPER->DO_REQUEST
* .
* Define a variable for the view we are about to create
data view type ref to if_bsp_page.
* Dispatch the input so that the event handler can process
* events like when the agent clicks on the Search button
me->dispatch_input( ).
* The attribute me->view_name can be set by the event handler
* to change navigation to the flights display
if me->view_name is initial.
me->view_name = 'input.htm'.
endif.
* Create the response view
view = me->create_view( view_name = me->view_name ).
if view is bound.
* Add a reference to the model instance to the view,
* so that the view can access the model
view->set_attribute( name = 'BUPAOBJ' value = me->BUPAOBJ ).
me->call_view( view ).
endif.
endmethod.
CODE:
method DO_HANDLE_EVENT.
* Check that the event has been triggered by the search button
if htmlb_event is bound and
htmlb_event->server_event = 'myclick1'.
* Execute the search implemented in the query model
me->BUPAOBJ->GETBUPA( ).
* Flights have been found, new target is the hit list display
if not me->BUPAOBJ->SEARCHRESULT[] is initial.
me->view_name = 'output.htm'.
elseif not me->BUPAOBJ->RETURN[] is initial.
me->view_name = 'output.htm'.
endif.
endif.
endmethod.
Save, check and activate the application.
Input the user name and password for the authentication and click on ok button.
Go to transaction SE80. Select BSP application and input the name of the BSP application that
you want to create. Press Enter or click on the display icon.
Save and activate the application.
select the Page with Flow Logic radio button and click on continue.
We proceed with providing the layout, attributes and the Event handling
of the respective pages.
Go to first.htm and put the following code in the layout tab of the page
<%@page language="abap"%>
<%@extension name="htmlb" prefix="htmlb"%>
<htmlb:content design="design2003">
<htmlb:page title = "DATE NAVIGATOR ">
<htmlb:form>
<h2> <htmlb:label for="date" text="DATE" />
<htmlb:inputField id = "mydate"
value = "<%= date%>"
maxlength = "10"
type = "date"/>
</h2>
<htmlb:dateNavigator id = "myDateNavigator"
monthsPerRow = "1"
onNavigate = "myOnNavigate"
onDayClick = "myOnDayClick"
onWeekClick = "myOnWeekClick"
onMonthClick = "myOnMonthClick">
</htmlb:dateNavigator>
</htmlb:form>
</htmlb:page>
</htmlb:content>
In the Page Attributes of first.htm, enter the attributes as shown below.
We need our application to take the date in input field when date is selected from DateNavigator control.
Save, Check and activate the first.htm. Save, check and activate the application
and after that execute it. The below screen would be displayed.
Now we are done with displaying the date in the inputfield using the DateNavigator.
Using Tabstrips in BSP
By Vakada Raghava, Mouri Tech Solutions
Requirement: To display header and item details for sales order using tab strip, tray with OTR text.
Steps to be followed:
Go to transaction SE24 and enter the name of the class as shown below.
In the pop up window that appears, enter the description and then click on the save button.
In the class, go to the properties tab and then specify the superclass for the new model class so that all
the methods and attributes will be inherited to the model class.
Add attributes to the new model class. Here, you can see that I have used the table types to refer to the
attributes of our class.
Add a method to the new model class to get the header and item details
CREATING VIEWS.
1) Create view: In transaction SE80, Right-click on the BSP application name and navigate to
CreatePage.
As shown below, enter the name and description of the view that you want to create. Select the radio
button View, and then click on the Continue button.
Give the page attributes of the view. The attribute of the view is an object reference of the model class
that we created previously.
Modify layout code for the search view (input.htm) as shown below.
Code :
<%@page language="abap"%>
<%@extension name="htmlb" prefix="htmlb"%>
<htmlb:content design="design2003">
<htmlb:page title = "create input fields ">
<htmlb:form>
<%= otr($TMP/MYALIAS) %>
<h2> <htmlb:label for="//SELECT/P_VBELN"/>
<htmlb:inputField value="//SELECT/P_VBELN"/></h2>
<br>
<br>
<otr>TO DISPLAY HEADER AND ITEM DETAILS</otr>
<htmlb:tray id = "traybox"
isCollapsed = "true" >
<htmlb:tabStrip id = "TabStrip"
bodyHeight = "300"
width = "400">
<htmlb:tabStripItem id = "headerdata"
index = "1"
onSelect = "TabStripheader"
title = "header data"
tooltip = "header data" >
<htmlb:tableView id="TV_VBAK" table="//SELECT/I_VBAK">
<htmlb:tableViewColumn columnName="vbeln"></htmlb:tableViewColumn>
<htmlb:tableViewColumn columnName="ERDAT"></htmlb:tableViewColumn>
<htmlb:tableViewColumn columnName="ERZET"></htmlb:tableViewColumn>
<htmlb:tableViewColumn columnName="ERNAM"></htmlb:tableViewColumn>
<htmlb:tableViewColumn columnName="ANGDT"></htmlb:tableViewColumn>
</htmlb:tableView>
</htmlb:tabStripItem>
<htmlb:tabStripItem id = "itemdata"
index = "2"
onSelect = "TabStripItem"
title = "item data"
tooltip = "item data" >
<htmlb:tableView id="TV_VBAP" table="//SELECT/I_VBAP">
<htmlb:tableViewColumn columnName="vbeln"></htmlb:tableViewColumn>
<htmlb:tableViewColumn columnName="posnr"></htmlb:tableViewColumn>
<htmlb:tableViewColumn columnName="matnr"></htmlb:tableViewColumn>
<htmlb:tableViewColumn columnName="matkl"></htmlb:tableViewColumn>
<htmlb:tableViewColumn columnName="arktx"></htmlb:tableViewColumn>
</htmlb:tableView>
</htmlb:tabStripItem>
</htmlb:tabStrip>
</htmlb:tray>
</htmlb:form>
</htmlb:page>
</htmlb:content>
Create a controller for the application as shown below. Right click on the application name Create
Controller.
Input the description of the controller and click on the continue button.
The screen appears as shown below.
Enter the name of the controller class that you want to create as shown in the above screen.
Double click on the controller class to enter into it. Give the attributes of the class as shown.
To use our model and views in controller class zcl_controller_sales1, we have to redefine some of the
methods inherited from base class cl_bsp_controller2 using the class builders redefine function( ). The
redefinition steps automatically add commented coding (shown in bold in the do_init example below):
method do_init .
endmethod.
If you uncomment those lines, you would execute the method implementation of the parent class. This is
helpful when you want to carry out the parent logic and some additional custom logic. we dont want to
reuse functionality of the parent class in the example, however, so be sure to delete the commented code
before adding the new code.
After that double click on the method do_init to implement it (write the code in the method).
CODE:
method DO_INIT.
*CALL METHOD SUPER->DO_INIT
* .
SELECT ?= me->create_model(
class_name = 'ZCL_MODEL_SALES1'
model_id = 'SELECT' ).
endmethod.
CODE:
method DO_REQUEST.
*CALL METHOD SUPER->DO_REQUEST
* .
data view type ref to if_bsp_page.
**data : selection type string.
me->dispatch_input( ).
if me->view_name is initial.
me->view_name = 'inpu.htm'.
endif.
view = me->create_view( view_name = me->view_name ).
if view is bound.
view->set_attribute( name = 'SELECT' value = me->SELECT ).
me->call_view( view ).
endif.
endmethod.
Summary:
In traditional JavaScript coding, if you want to get any information from a database or a file on the server,
or send user information to a server, you will have to make an HTML form and GET or POST data to the
server. The user will have to click the "Submit" button to send/get the information, wait for the server to
respond, and then a new page will load with the results.
Because the server returns a new page each time the user submits input, traditional web applications can
run slowly and tend to be less user-friendly.
With AJAX, your JavaScript communicates directly with the server, through the JavaScript
XMLHttpRequest object
With an HTTP request, a web page can make a request to, and get a response from a web server -
without reloading the page. The user will stay on the same page, and he or she will not notice that scripts
request pages, or send data to a server in the background.
This Tutorial demonstrates how to use AJAX in BSP for getting the data from server without reloading the
entire page and displays the information.
In this BSP application we will create two BSP Pages; one for providing the data in xml format is called
data.xml and another page for calling and displaying the results is called first.htm.
This is a simple page with two elements one is an input field to enter plant and another is text
view to display the name of the plant.
When the user inputs data, a function called "getName( )" is executed. The execution of the
function is triggered by the "onkeyup" event. In other words: Each time the user moves his finger
away from a keyboard key inside the input field, the function getName is called.
If there is some input in the input field the function executes the following:
Creates an XMLHTTP object, and tells the object to execute a function called getValue.
When the state changes to 4 ("complete"), the content of the text view is filled with the response text.
3. Create page with name data.xml which retrieves the data and scrambles the XML.
Activate the application, to test the application right click on page FIRST.htm choose context Test.
Result:
Enter Plant value we will get the Plant name, no need to press/click any.
Simple BSP application to Create, Modify and Delete the
database entries
By Tanveer Zahack, YASH Technologies
This tutorial will give you blow-by-blow description of how to design a simple BSP application that would
fetch entries from database table and create entries, if there exists no entry.
STEP 1: Call transaction SE11; create a database table using predefined types.
STEP 2: Push some entries in the table;
STEP 6: Choose the tab Page Attributes and define the work variables, which you are going to
use in your application. Besides defining work-variables, you have to define an internal table and
a field string.
To define a field-string, use types: ff_progmr. And to define an internal table, use table-type of
ZART_PROGRAMMER table. Open table using SE11, press Ctrl+Shift+F3 (Where-Used-
List), or click the icon , deselect other checkboxes and select Table-Types, purse down the
table-type name for the table ZART_PROGRAMMER.
Or create a new table-type, if there exists no table-type. Call transaction SE11->Data type-
>Create->Table Type->Line Type: ZART_PROGRAMMER->Save and Activate.
fl_flag TYPE INT4
fs_progmr TYPE FF_PROGMR
t_progmr TYPE ZART_TT
w_dob TYPE DATS
w_doj TYPE DATS
w_emno TYPE ZART_PROGRAMMER-EMNO
w_ext_dob TYPE CHAR10
w_ext_doj TYPE CHAR10
w_index TYPE INT4
w_salary TYPE ZART_PROGRAMMER-SALARY
STEP 7: Choose the tab Layout and design a web-page that should contain a table-view and
table-view-columns. Table-View chooses the internal table from which the data has to be fetched
and displays it in formatted manner. Table-View-Column.
To get a table-view, choose Tag-Browser from the left-hand pane; pull down BSP Extensions-
>Transportable->HTMLB. Here you get a lot of htmlb controls, drag Table-View control and
drop it in the layout (For additional details about it, right-click the tag and go through
documentation).
<htmlb:content design="design2003" >
<htmlb:page title="Main Page " >
<htmlb:form>
<%
if t_progmr[] is not initial.
%>
<center>
<table>
<tr>
<td>
<htmlb:tableView id = "Programmer_Data"
table = "<%= t_progmr %>"
visibleRowCount = "5"
selectionMode = "SINGLESELECT"
onRowSelection = "rowSelection" >
<htmlb:tableViewColumn columnName = "EMNO"
title = "Employee Number" />
<htmlb:tableViewColumn columnName = "DOB"
title = "Date of Birth" />
<htmlb:tableViewColumn columnName = "DOJ"
title = "Date of Joining" />
<htmlb:tableViewColumn columnName = "SALARY"
title = "Salary" />
</htmlb:tableView>
</td></tr>
<tr> <td>
<center>
<htmlb:button id = "create"
tooltip = "Create New Entries"
text = "CREATE"
onClick = "OnInputProcessing()" />
</center>
</td></tr>
</table>
</center>
<%
endif.
%>
When you activate this page and choice to view the output, it cant happen since internal table
contains no data.
STEP 8: To populate data in internal table, choose Event Handler tab and select
OnInitialization, this event is triggered no sooner the page gets refreshed or called for the first
time.
OnInitialization:
OnInputProcessing handles the events for checking and processing user input and
for defining navigation.
DATA:
w_event TYPE REF TO cl_htmlb_event,
w_eventid TYPE string,
w_object TYPE REF TO object,
w_fieldid TYPE string,
w_in_field TYPE REF TO cl_htmlb_inputfield,
w_in_value TYPE string,
w_employee TYPE zart_programmer-emno,
w_dofb TYPE char10,
w_dofj TYPE char10,
w_esalary TYPE zart_programmer-salary.
IF w_eventid EQ 'Programmer_Data'.
CASE event_id.
WHEN cl_htmlb_manager=>event_id.
DATA:
event TYPE REF TO if_htmlb_data,
selrow TYPE REF TO cl_htmlb_tableview.
w_index = tv_data->selectedrowindex.
ENDCASE.
To catch the event, we make use of Class cl_htmlb_manager and method get_event.
STEP 10: On the click of create button, we set the fl_flag as 2, that can be used to display create
layout with an insert button on the same page. Further, on click of insert button, values of all
input fields are processed and inserted into database using a simple INSERT query.
<%
elseif fl_flag eq 2.
%>
<center>
<table bgcolor="ivory">
<tr>
<td>
<htmlb:label for = "ip_emno"
labelType = "MEDIUM"
text = "Employee Number" />
</td>
<td>
<htmlb:inputField id = "ip_emno
disabled = "FALSE" />
</td></tr>
<tr>
<td>
<htmlb:label for = "ip_dob"
labelType = "MEDIUM"
text = "Date of Birth" />
</td>
<td>
<htmlb:inputField id = "ip_dob" />
</td></tr>
<tr>
<td>
<htmlb:label for = "ip_doj"
labelType = "MEDIUM"
text = "Date of Joining" />
</td>
<td>
<htmlb:inputField id = "ip_doj" />
</td></tr>
<tr>
<td>
<htmlb:label for = "ip_salary"
labelType = "MEDIUM"
text = "Salary" />
</td>
<td>
<htmlb:inputField id = "ip_salary" />
</td></tr>
<tr><td colspan = "2">
<center>
<htmlb:button id = "insert"
tooltip = "Create a New Record"
text = "INSERT"
onClick = "OnInputProcessing()" />
</center>
</td></tr>
</table>
w_in_field ?= w_object.
w_in_value = w_in_field->value.
w_employee = w_in_value.
CLEAR: w_object,w_in_field,w_in_value.
CLEAR: w_object,w_in_field,w_in_value.
w_in_field ?= w_object.
CLEAR: w_object,w_in_field,w_in_value.
w_in_field ?= w_object.
w_in_value = w_in_field->value.
w_esalary = w_in_value.
fs_progmr-emno = w_employee.
fs_progmr-dob = w_dofb.
fs_progmr-doj = w_dofj.
fs_progmr-salary = w_esalary.
Entries are very well inserted into the database table, we now make innovations to the same page
to modify and delete entries.
w_emno = fs_progmr-emno.
w_dob = fs_progmr-dob.
w_doj = fs_progmr-doj.
w_salary = fs_progmr-salary.
fl_flag = 1.
CALL FUNCTION 'CONVERT_DATE_TO_EXTERNAL'
EXPORTING
date_internal = w_dob
IMPORTING
date_external = w_ext_dob
EXCEPTIONS
date_internal_is_invalid = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF.
<%
else if fl_flag eq 1.
%>
<center>
<table bgcolor="ivory">
<tr>
<td>
<htmlb:label for = "ip_emno"
labelType = "MEDIUM"
text = "Employee Number" />
</td>
<td>
<htmlb:inputField id = "ip_emno"
value = "<%= w_emno %>"
disabled = "TRUE" />
</td></tr>
<tr>
<td>
<htmlb:label for = "ip_dob"
labelType = "MEDIUM"
text = "Date of Birth" />
</td>
<td>
<htmlb:inputField id = "ip_dob"
value = "<%= w_ext_dob %>" />
</td></tr>
<tr>
<td>
<htmlb:label for = "ip_doj"
labelType = "MEDIUM"
text = "Date of Joining" />
</td>
<td>
<htmlb:inputField id = "ip_doj"
value = "<%= w_ext_doj %>" />
</td></tr>
<tr>
<td>
<htmlb:label for = "ip_salary"
labelType = "MEDIUM"
text = "Salary" />
</td>
<td>
<htmlb:inputField id = "ip_salary"
value = "<%= w_salary %>" />
</td></tr>
<tr><td>
<center>
<htmlb:button id = "save"
tooltip = "Modify the Content"
text = "MODIFY"
onClick = "OnInputProcessing()" />
<htmlb:button id = "delete"
tooltip = "Delete Selected Entry"
text = "DELETE"
onClick = "OnInputProcessing()" />
</center>
</td></tr>
</table>
<%
endif.
%>
STEP 14: Now, when MODIFY button is clicked, the values changed should be stored in
database without changing employee id, since thats primary key.
w_in_field ?= w_object.
w_in_value = w_in_field->value.
w_employee = w_in_value.
CLEAR: w_object,w_in_field,w_in_value.
CLEAR: w_object,w_in_field,w_in_value.
w_in_field ?= w_object.
CLEAR: w_object,w_in_field,w_in_value.
STEP 15: Deleting an entry from database is quite simple, since it doesnt require any conditions
except index.
We give the same code as above, except for the query at the bottom.
w_in_field ?= w_object.
w_in_value = w_in_field->value.
w_employee = w_in_value.
CLEAR: w_object,w_in_field,w_in_value.
w_in_field ?= w_object.
CLEAR: w_object,w_in_field,w_in_value.
w_in_field ?= w_object.
w_in_value = w_in_field->value.
w_esalary = w_in_value.
fs_progmr-emno = w_employee.
fs_progmr-dob = w_dofb.
fs_progmr-doj = w_dofj.
fs_progmr-salary = w_esalary.
ENDIF.
Create a BSP application as Zres_app in transaction SE80 and create 3 pages(Page with flow
logic) for the created BSP application as follows
Scenario:
User can fill their details in first.htm and he/she has 3 options Save (or) Submit (or) Display their details
via button event.
First.htm:
<%@page language="abap"%>
function formReset()
var x=document.getElementById("myForm").reset();
</script>
<htmlb:button id="btn_submit"
text = "Submit Ur Details"
onClick = "myDetail" />
<htmlb:button id="btn_save"
text = "Save Ur Details"
onClick = "mysave"
onClientClick="alert('Ur details are updated!')" />
<htmlb:button id="btn_display"
text = "Display Details"
onClick = "myDetails" />
</htmlb:groupBody>
</htmlb:group>
</htmlb:form>
</htmlb:page>
</htmlb:content>
Types:
Page attributes:
Event Handler(OninputProcessing):
***********************
irb ?= cl_htmlb_manager=>get_data( request = runtime->server->request
name = 'radiobuttongroup'
id = 'gro' ).
if irb is not initial.
selection1 = irb->selection.
endif.
************************
**************************
******************
event ?= cl_htmlb_manager=>get_event( runtime->server->request ).
qualify ?= cl_htmlb_manager=>get_data(
request =runtime->server->request
name = 'dropdownListBox'
id = 'ListBox1' ).
if qualify is not initial.
selection2 = qualify->selection.
endif.
i_qualify = me->selection2.
*************
act ?= cl_htmlb_manager=>get_data(
request = runtime->server->request
name = 'textedit'
id = 'ea' ).
i_act = act->text.
************************
if event->id = 'btn_submit'.
iname ?= cl_htmlb_manager=>get_data( request = runtime->server->request
id = 'i_name'
name = 'inputfield' ).
iage ?= cl_htmlb_manager=>get_data( request = runtime->server->request
id = 'i_age'
name = 'inputfield' ).
event = cl_htmlb_manager=>get_event( runtime->server->request ).
if event->name = 'checkBox' and event->event_type = 'click'.
case event->id .
when 'SelfConfidence'.
checkbox ?= cl_htmlb_manager=>get_data(
request = runtime->server->request
name = 'checkbox'
id = 'SelfConfidence' ).
when 'HardWorker'.
checkbox ?= cl_htmlb_manager=>get_data(
request = runtime->server->request
name = 'checkbox'
id = 'HardWorker' ).
when 'CreativitySense'.
checkbox ?= cl_htmlb_manager=>get_data(
request = runtime->server->request
name = 'checkbox'
id = 'CreativitySense' ).
when 'FlexibletoSurroundings'.
checkbox ?= cl_htmlb_manager=>get_data(
request = runtime->server->request
name = 'checkbox'
id = 'FlexibletoSurroundings' ).
endcase.
endif.
i_name = iname->value.
i_age = iage->value.
i_sex = me->selection1.
i_qualify = me->selection2.
* i_check = me->i_check .
navigation->set_parameter( name = 'i_name' value = me->i_name ).
navigation->set_parameter( name = 'i_age' value = me->i_age ).
navigation->set_parameter( name = 'i_sex' value = me->i_sex ).
navigation->set_parameter( name = 'i_address' value = me->i_address ).
navigation->set_parameter( name = 'i_qualify' value = me->i_qualify ).
navigation->set_parameter( name = 'i_act' value = me->i_act ).
navigation->set_parameter( name = 'c_text' value = c_text ).
navigation->goto_page( 'second.htm' ).
endif.
if event->id = 'btn_save'.
if itab is initial.
*loop at itab into wa.
move i_name to wa-name.
wa-age = me->i_age.
wa-sex = me->selection1.
wa-address = me->i_address.
wa-qualify = me->selection2. "i_qualify.
wa-act = me->i_act.
append wa to itab.
modify zres from table itab.
commit work.
*endloop.
endif.
endif.
if event->id = 'btn_display'.
navigation->goto_page( 'third.htm' ).
endif.
Output (first.htm):
Second.htm:
<%@page language="abap"%>
<%@ extension name="htmlb" prefix="htmlb" %>
<htmlb:content design="classic+design2002+design2003">
Page Attributes:
third.htm:
<%@page language="abap"%>
<%@extension name="htmlb" prefix="htmlb"%>
<htmlb:content design="design2003">
<htmlb:page title = " ">
<htmlb:form>
<b><htmlb:label for="lb" text="Your Details" /></b>
<% if itab1 is not initial. %>
<htmlb:tableView id="tv" table="<%= itab1 %>">
<htmlb:tableViewColumn columnName="NAME"
title="NAME"></htmlb:tableViewColumn>
<htmlb:tableViewColumn columnName="AGE" title="AGE"></htmlb:tableViewColumn>
<htmlb:tableViewColumn columnName="ADDRESS"
title="ADDRESS"></htmlb:tableViewColumn>
<htmlb:tableViewColumn columnName="SEX" title="SEX"></htmlb:tableViewColumn>
<htmlb:tableViewColumn columnName="QUALIFY"
title="QUALIFY"></htmlb:tableViewColumn>
<htmlb:tableViewColumn columnName="ACT"
title="ACTIVITY"></htmlb:tableViewColumn>
</htmlb:tableView>
<% endif. %>
</htmlb:form>
</htmlb:page>
</htmlb:content>
Types:
Final Output:
STEP1: have a controller in the BSP application ending with .xml (for eg: export.xml)
STEP2: create a controller class for the controller(zcl_c_xml_export)
STEP3: In the do_request method of the of the controller class, pass the internal table to be converted to
the xml file via a function module ZI057678_TEST_XML; which will return the xml string.
Now, call the write method of the cl_bsp_controller and pass the xml string
STEP3.1: The function module will have the following code:
FUNCTION zi057678_test_xml.
*"----------------------------------------------------------------------
*"*"Local interface:
*" IMPORTING
*" REFERENCE(IT_ITAB) TYPE STANDARD TABLE
*" EXPORTING
*" REFERENCE(EV_OUTPUT) TYPE STRING
*"----------------------------------------------------------------------
<fs> = it_itab.
ENDFUNCTION.
STEP4: Now test the controller to see the pop up of the XML.
Simple BSP Application to validate the date fields in Front end using JAVASCRIPT
Go to Transaction SE80.
Select BSP Application & enter the name to create a New BSP Application (Eg:yh_date):
Enter the page name and the description and select page with Flow Logic option
Now Page is created. Enter the below code.
In Layout Code:-
In Event-handler on Initialization.
w_sd = sy-datum.
w_ed = sy-datum.
In Type Definition:
w_eIN TYPE C
w_sin TYPE C
OUTPUT
Whenever an invalid date is provide this JavaScript will get triggered.
Case 1.
Once you press ok the input field color will change to Red.
This above condition will work for day as well as month values.
Case 2.
Here if the total length of month is less than 4 the following error is triggered.
Once you press ok the input field color will change to Red.
Case 3.
Again, as above once the valid date is provided it revert back to original color.
This is all about the date validations that can be done on front-end using Java scripts.
Scenario: Download the table contents into excel sheet with the button click can be achieved by using
class CL_BSP_UTILITY download.
Step1: Go to SE80 transaction select BSP application and provide the name of application.
Step2: Give the short description of application and assign package to application.
Step5: CODE
Layout code:
<%
if fl_flag = 1.
%>
<htmlb:tableView id = "flight"
table = "<%= t_flight %>"
width = "50%"
onRowSelection = "rowSelection"
design = "standard"
tableLayout = "AUTO"
footerVisible = "false" >
<htmlb:tableViewColumn columnName = "CARRID"
title = "<b>Carrier Id</b>" >
</htmlb:tableViewColumn>
<htmlb:tableViewColumn columnName = "CONNID"
title = "<b>Connection ID</b>" >
</htmlb:tableViewColumn>
<htmlb:tableViewColumn columnName = "FLDATE"
title = "<b>Flight Date</b>" >
</htmlb:tableViewColumn>
<htmlb:tableViewColumn columnName = "PLANETYPE"
title = "<b>Plane Type</b>" >
</htmlb:tableViewColumn>
</htmlb:tableView>
<br><center>
<htmlb:button id = "submit"
text = "Download"
onClick = "test"
width = "20%"/>
<%endif.%>
</center>
</td></tr>
</htmlb:form>
</table>
</htmlb:page>
</htmlb:content>
OnCreate Code:
select carrid connid fldate planetype from sflight into table t_flight
up to 10 rows.
if sy-subrc eq 0.
fl_flag = 1.
endif.
OnInPutProcessing Code:
DATA:
output TYPE string ,
l_xstring TYPE xstring,
app_type TYPE string.
button_event ?= event .
CASE event->event_server_name.
WHEN 'test' .
CONCATENATE
cl_abap_char_utilities=>byte_order_mark_little
l_xstring INTO l_xstring
IN BYTE MODE.
CALL METHOD cl_bsp_utility=>download
EXPORTING
object_s = l_xstring
content_type = app_type
content_disposition ='attachment;filename=FlightDetails.xls
response = _m_response
navigation = navigation.
ENDIF.
ENDCASE.
ENDIF.
Page Attributes:
fl_flag TYPE I
fs_flight1 TYPE TYPE_S_FLIGHT
t_flight TYPE FS_FLIGHT
w_carrid TYPE SFLIGHT-CARRID
w_input TYPE STRING
Types Definition:
types:
begin of type_s_flight,
carrid type sflight-carrid,
connid type sflight-connid,
fldate type sflight-fldate,
planetype type sflight-planetype,
end of type_s_flight,
fs_flight type standard table of type_s_flight.
OUTPUT:
Step6: Layout is as follows with the flight details and user has option to download the table details with
the button click.
Click on download button, Pop up appears asking to open or to save a file.
Just create two pages first and second using page with Flow logic as the page type.
Create the first page as first.html and second page as second.xml as shown below.
In the second.xml page, try to populate the XML file using simple SFLIGHT table information.
I have used the replace statements because XML parsing in Flex failed due to special characters.
Test the second.xml page, XML file will open in a separate browser as below,
Create a Flex application in the Adobe Flex builder. I have created a MXML application named
sapflexbsp inside the project flexwebservice.
Use the following code in the created MXML application.
You will see the list of all the swf and html objects created for the project in the history folder.
Copy the created swf file.
Right click the html file and copy the below source code in the first.htm page of your BSP application as
shown.
Import the Created SWF file in the SAP MIME Repository as shown.
Once you have done all the above steps, execute the first.htm page. It will call the MIME object and
execute complete application.
Following is the result of the complete integration between SAP BSP and ADOBE Flex.
Integrating SAP data (R/3 or BW Data) with the BO-Xcelsius (Business Objects)
using BSP
<%@page language="abap"%>
<% DATA: ITAB TYPE TABLE OF SFLIGHT,
XML_STRING TYPE STRING .
TRY.
CALL TRANSFORMATION ('ID')
SOURCE PARA = ITAB
RESULT XML XML_STRING.
CATCH CX_ST_ERROR.
ENDTRY.
The above code is used to generate the XML data. The internal table returned from the select statement
will be presented to the standard CALL TRANSFORMATION (ID) to generate the XML. The XML format
may be either in UTF-8 or UTF-16 or anything. Based on the setting and server configurations the
versions have to be set. The XML file has to be tested and the generated XML will be saved locally in
order to design the Chart.
Now an Excel file is imported with the XML data saved locally. The data returned from the FM will be
presented in the excel file and the file will be saved locally.
Now the BO-Xcelsius will be opened and imported with excel file which is saved in the previous step. The
data will be feed into the excel sheet of the Xcelsius and the report is designed by using several
components available.
Now the connectivity has to be made by opening the Manage Data Connections - > Add - > Excel XML
Maps. Name the connection and mention the XML data URL. The view represented in BSP application for
the XML file has the URL and will be represented.
The designed Xcelsius file will be saved in XLF format locally which will be then exported as SWF file.
The SWF file will be imported as MIME object into the BSP application.
Another HTML view will be created inside the same BSP application in order to display the MIME object.
Apply the below code in the layout of FLIGHTS.HTML view.
<%@page language="abap"%>
<%@extension name="htmlb" prefix="htmlb"%>
<htmlb:content design="design2003">
<htmlb:page title = "XCelsius-SAP (Excel XMl Maps Connection)">
<htmlb:form>
<object>
<embed src="Excel_XML_MAPS.swf" quality="high"
allowScriptAccess="sameDomain"
type="application/x-shockwave-flash"
pluginspage="http://www.adobe.com/go/getflashplayer">
</embed>
</object>
</htmlb:form>
</htmlb:page>
</htmlb:content>
Now test the FLIGHTS.HTML page. The HTML page first calls the Xcelsius SWF file. The SWF file gets
data from the XML page created as a view in the BSP application. You can easily have a view by
debugging the application on keeping the break point in the appropriate places. For example when a
refresh button is placed in the Xcelsius file and whenever it is clicked, the data gets refreshed and acts
based on the current data.
I think the blog on Excel XML maps connection gave a basic idea of integrating SAP with the BO. Not only
R/3 data can be presented as a report or dashboard, but also the BW data can also be presented by
representing the BW Query or BW objects into the customized FMs and can be operated as the same as
that of operating the R/3 data through the XML file. Below shows the sample application which is
consuming data from BW query.
Part 2: SAP BSP + BO-Xcelsius (web Service Connection)
As we discussed earlier about the SAP and BO integration using BSP and Xcelsius, here I have used
another connection of Xcelsius to integrate with the SAP BSP.
This experiment is intended to describe the integration of SAP with BO-Xcelsius using web service. The
R/3 or BW data will be consumed as web service so that the service will be used with the data
connectivity of Xcelsius. The data gets refreshed every moment based on the user action through the
interface where we are going to use SAP BSP as the tool.
The first step is to create the FM, where the logical operation of the report has to perform. We can either
use R/3 tables, Classes, methods etc or BW Query as the source.
Now the created SWF file has to be presented to the dashboard by having SAP BSP as the web
interface.
Create a BSP Application ZDEMO_WEBSERV with a HTML View-DISPLAY.HTML with the following
code. Import the SWF file into the BSP application in the MIME folder.
Now test the DISPLAY.HTML and interact with Xcelsius file by giving input and output will be based on the
functionality of the web service.
Here the R/3 data is consumed as a FM and used as the source. In the previous part also R/3 data is
used as the source. BW data can also be used as the source data in the previous and for this experiment
also.
In this presentation the third connection of Xcelsius XML data is used to integrate with SAP BSP, so that
the data will be presented in the dashboard.
Create a XML view in the BSP application based on the PWFL model. Embed the below code shown in
the following screens. The code is mainly projected to generate the XML file which is going to act as a
source for the SWF file in a particular format. The CALL TRANSFORMATION ('ID') will generate the XML
file using the data in a format based on the system / server settings. The pre defined format has to be
achieved based on replacing some tags with other values as shown in the below screens.
The below screen is the predefined format with data, variable, row and column tags generated while
testing the XML view. The generated XML has to be parsed to the Xcelsius file. Sometimes the target
might not be achieved if the format of the XML file is not proper.
Open the Xcelsius 2008 and design the canvas using a list box and a column chart. The list box will be
holding the date of the flight and the column chart will represent the maximum and occupied seats of the
particular class on the selected date.
Now the data connectivity has to be assigned to the Xcelsius file. The XML path will be taken from the
properties of the XML view as shown below.
The XML data URL will be the copied URL from the above screen. The URL can also be dynamically
changed by keeping tags on the server name. eq. http://<webserver>.com:<port>/sap(namesapce)
Now the data from the XML has to be mapped to a series of range. Mark check on Enable Load and
click on +. Name the series as Q1 which we used the variable name in the XML file and select the
ranges based on the data. Click on preview XML and compare the XML file generated by Xcelsius
preview and the XML generated while testing XML view from BSP application. The format should be the
same, so that the data can be parsed easily between the BSP and SWF file which is going to be
generated
Scenario: Consuming WSDL file through BSP which involves the proxy development.
Proxy generation
Step1: Go to SE80 transaction, select the package and right click on package create enterprise
service/web service and right click and select on proxy object.
Step2: User has option to select the WSDL sources, select local file click on continue. User has option to
select the WSDL file. (To download the WSDL file used in this scenario, click here)
Step2: Give the short description of application and assign package to application.
<center>
<htmlb:textView text = "Mobile No"
design = "EMPHASIZED" />
<htmlb:inputField id = "mob"
value = "<%= w_mobno %>"
size = "12" />
<br>
<htmlb:textView text = "Mail ID"
design = "EMPHASIZED" />
<htmlb:inputField id = "mail"
value = "<%= w_mail %>" />
<br>
<htmlb:textView text = "Message"
design = "EMPHASIZED" />
<htmlb:inputField id = "msg"
value = "<%= w_msg %>"
size = "12" />
<br>
<br>
<htmlb:button text = "Send SMS"
id = "get"
onClick = "OnInputProcessing" />
<%
if fl_flag eq 1.
%>
<%
if t_ou is not initial.
%>
<center>
<font face=verdana style="font-size:12px" color ="#228B22"> <%= t_ou-
SEND_SMSTO_INDIA_result-FROM_EMAIL_ADDRESS%>
<br><%= t_ou-SEND_SMSTO_INDIA_result-MOBILE_NUMBER%>
<br><%= t_ou-SEND_SMSTO_INDIA_result-PROVIDER%>
<br><%= t_ou-SEND_SMSTO_INDIA_result-STATE%>
<br><%= t_ou-SEND_SMSTO_INDIA_result-STATUS%> </b></h6></center>
<%
endif.
%>
<%
Endif.
%>
</center>
</htmlb:form>
</htmlb:page>
</htmlb:content>
Step6:
OnInPutProcessing Code:
w_input = w_mobno.
clear w_obj.
w_input = w_mail.
clear w_obj.
w_input = w_msg.
clear w_obj.
data:
tv type REF TO ZTCO_SEND_SMSSOAP ,
t_in type ZTSEND_SMSTO_INDIA_SOAP_IN,
t_in1 type REF TO ZTSEND_SMSTO_INDIA_SOAP_IN,
t_inn like standard table of t_in.
TRY.
CREATE OBJECT tv
* EXPORTING
* logical_port_name =
.
CATCH cx_ai_system_fault .
ENDTRY.
t_in-MOBILE_NUMBER = w_mobno.
t_in-FROM_EMAIL_ADDRESS = w_mail.
t_in-MESSAGE = w_msg.*
TRY.
CALL METHOD tv->send_smsto_india
EXPORTING
input = t_in
IMPORTING
output = t_ou
.
CATCH cx_ai_system_fault .
CATCH cx_ai_application_fault .
ENDTRY.
if t_ou is not initial.
fl_flag = 1.
endif.
endcase.
Page attributes:
fl_flag TYPE I
OUPUT:
Give the mobile number, mailid and message and click on button.
Output is as follows with the mobile-no, mailid, service provider, place and status of message (Message is
delivered or not delivered)
This technical document is about how to add a new DATE tab next to the follow-up tab in the HR-IC
standard Web UI component which will display the SLA dates for the HR Service ticket.
Step-1:
We need to enhance the HR-IC component with the following enhancement set.
Step-2:
The click on the Component Structure browser and go the views. Then choose the following view.
Step-3:
Click on the view layout and go to the HeaderPartnerFolUpViewSet.htm. Double click on it which will take
you to the HeaderPartnerFolUpViewSet.htm Page.
Now we need to update the navigational link which has the following tabs: Categories, Actions, Follow-
up. The below code need to be added in the navigational link internal table and activate it to get the
DATE tab reflecting in the HR-IC Client Web UI.
ls_line-id = 'help'.
ls_line-onclick = 'help'.
ls_line-text = 'Dates'.
ls_line-tooltip = 'Dates'.
"ls_line-textdirection = 'Dates'.
insert ls_line into table controller->gt_navlink_tab.
CLEAR: ls_line.
Step-4:
Now test the component and check the Web Client UI where you can find the new DATE tab next to the
follow-up TAB but without a view assigned to it and we need to establish a link for a view to show up in
the newly added TAB.
Step-5:
The next step is to get the SLA Date information like Processing Date and Due Date in the Dates TAB.
Create an event EH_HELP and outbound plug OP_DATES. This event will trigger the action HELP
which will fire an outbound plug OP_DATES which in turn will establish a link for the respective view
specified in the navigational link.
Step-6:
The viewset ViewSet ICCMP_BT_SVT/SLAView has a view View ItemDates.MainWindow which can be
used for displaying in the DATES tab which has information like First Response and Due dates.
Step-7:
Now drag the View ItemDates.MainWindow from the ViewSet ICCMP_BT_SVT/SLAView and its
ViewArea ItemDates to the Viewset ICCMP_BT_SVT/HeaderPartnerFolUpViewSet and its ViewArea
HeaderPartnerFolUpMain as show below.
Save the Repository Changes.
Step-8:
Now we have established a NavigationalLink ToSladates and dragged the Item view to the Partner
Follow-up View set. Few changes in the event handler EV_ONHELP and outbound-plug OP_DATES will
the bring Itemdates view in the DATE tab with the required data like First Response Date and Due Date.
Add the following code in the event handler EH_ONHELP and activate it.
Add the following code in the outbound-plug OP_DATES and activate it.
Step-9:
Now test the service and it will show the respective SLA dates in the DATE tab as below.