on 09-10-2009 8:15 PM
Hi
I have a simple BSP Page , which is calling a function module, which requires four parameters.
I want to send those parameters from URL.
My question is how to send those parameters and set them to the input variables for the function module.
I am newbie to BSP and any help is greatly appreciated.
Thanks
Rajesh
Hi Rajesh,
in your BSP page define page attributes for each of the four variables and ensure you set the "Auto" checkbox selected.
Now call URL like this...
http://sapserver.mydomain.com/sap/bc/bsp/sap/zbspapp/page.htm?var1=value1&var2=value2&var3=value3&var4=value4
...replacing "varx" with the variable names you have defined.
The BSP runtime will populate the page attributes for you as long as the value passed matches the datatype and the "Auto" attribute is set on.
Cheers
Graham Robbo
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks, so the followup question is how to extract the variables from BSP Runtime and assign it to the Function Module I am calling.
I am calling the function module to get the Workload Snapshot and it takes mandatory parameters which are
Start_date
End_date
Start_time
and End_time
Please give me code-snippet of how it will be done, I am completely new to BSP and this would be of extremely good help.
regards
Rajesh
You don't have to "extract the variables from the BSP runtime". The page attributes are effectively class attributes and addressable from anywhere in the BSP page.
I suggest you do a few of the BSP Tutorials to get a feel for how it works.
Meantime here is how to create one of the worlds' simplest BSP pages.
Step 1. Create a new page
Step 2. Create 2 page attributes
"address" of type BAPIADDR3
"username" of type XUBNAME
Step 3. Select the "Auto" checkbox for the attribute "username".
Step 4. Enter the following code in the OnInitialization event handler
* event handler for data retrieval
DATA: lt_return TYPE bapiret2_tab.
CHECK username IS NOT INITIAL.
CALL FUNCTION 'BAPI_USER_GET_DETAIL'
EXPORTING
username = username
IMPORTING
address = address
TABLES
return = lt_return.
Step 5. Enter the following for the Layout
<%@page language="abap" %>
<html>
<body>
<form>
<input type="text" name="username">
<input type="submit">
</form>
<%
if address is not initial.
%>
User name is <%= address-firstname%> <%= address-lastname%>
<%
endif.
%>
</body>
</html>
Now compile and test the BSP. Enter a username in the input field, click the submit button, and it should return the users' name from the User Master Record.
When you do this look at the URL in your browser and you will see that the username is passed as a parameter in the URL string.
Cheers
Graham Robbo
I have made the following code changes as you have mentioned
1. Step 1
Added the Page Attributes which are Auto to the page tasktypedata.xml
StartDate (Associated Type SWNCDATUM)
EndDate (Associate Type SWNCDATUM)
StartTime (Associated Type SWNCUZEIT)
EndTime (Associated Type SWNCUZEIT)
I used the same associated type as in the Function Module Definition
2. In the OnInitlization Event Handler I did the following
DATA:
tasktypedata TYPE SWNCGL_T_AGGTASKTYPE.
CHECK tasktypedata IS NOT INITIAL.
CALL FUNCTION 'SWNC_GET_WORKLOAD_SNAPSHOT'
EXPORTING
tasktypedata = tasktypedata
IMPORTING
READ_START_DATE = startdate
READ_END_DATE = enddate
READ_START_TIME = starttime
READ_END_TIME = endtime
TABLES
return = tasktypedata.
My objective is to pass the StartDate, EndDate, StartTime, EndTime to the Function Module and Display the TaskType Data
The Function Module is SWNC_GET_WORKLOAD_SNAPSHOT
2. I Compiled, Activate, and Test with the following URL Parameters
3. The output is a blank XML Page, I expected some data.
4. My question is does it get the parameters to the function Module, and is it executing the function module.
Or is it problem in the output?
Thanks once again, please help. I am a complete newbie to BSP and this is learning experience so far.
Thanks
Rajesh
You can use the debugger to answer your questions.
Certainly you are not passing the date and time variables in the expected format. If you want to pass them in the formats in your example you will need to define the page attributes as type STRING and then convert them into the type the function module expects.
Cheers
Graham Robbo
Hi,
assunction your f-module requires input1, ..., input4.
You to the pages attributes tab and define 4 variables with the same name and set the auto flag. This instructs the system,
if your url for your bsp-page is like:
you can call it like
http://.....my_page.htm?input1=value1&...&input4=value4
so in the event oninitialization you have the input1 - ... - input4 automatically filled with value1 - .. - value4.
Best regards,
Stefan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Rjain,
Suppose there are two pages in your BSP application. Page1 calls Page2 and in Page2 you are calling a FM.
In Page1:
For calling page2 use the method CL_BSP_RUNTIME->CONSTRUCT_BSP_URL to generate URL of Page2, and concatenate name value pair in this URL so that parameters are passed with URL to next page i.e. Page2 .
In Page2:
Define page attributes with the same name as you are passing in URL in Page1 and check the Auto flag. Now these parameters will be filled with values you are passing in URL in Page1.
You can use these parameters and pass them to the FM in any event handler except OnCreate.
Search the forum for code sample of construct_bsp_url method.
Regards,
Anubhav
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.