sapdev logo background
sapdev logo sapdev logo
Comments

BSP to capture user entry into HTML input fields




The following example builds on the Capture user input BSP and shows you how to then pass the entered value onto another page.

Step 1 - Create new BSP Application
Create the basic BSP to Get user input which simply allows a user to enter data and then press a save button.

Step 2 - Create new page (display.htm)
Right click on BSP object name and select create->page (with flow logic).

Step 3 - Populate 'Attributes' tab Add a new field(longtext) within the attributes tab, ensuring that the 'Auto' option is ticked.


Step 4 - Populate 'Layout' tab
Insert the following HTML code into the display.htm layout section. This code is basically displaying the value stored in the attribute you have created in the previous step.

<%@page language="abap" %>
<%@extension name="htmlb" prefix="htmlb" %>
<html>
 <head>
  <title>Page title</title>
 </head>
 <body>
 <p>The value you entered on the previous screen is: <%= longtext%>
 </p>
 </body>
</html>


Step 4 - Insert OnInputProcessing code (Event Handler)
Now you need to modify the OnInputProcessing abap code within the calling page (index.htm). This is so that it now passes the value into the attribute name you created in step 3. This is done using the 'navigation->set_parameter' statement

  navigation->set_parameter( name  = 'longtext' ).

  case event_id.
    when 'save'.
      navigation->goto_page('display.htm').
  endcase.

Alternate method (just for information)
If you used the alternate method when creating the basic bsp and captured the user input value into a local varible rather than creating attribute with same name then you would need to add the following ABAP code.

data: ld_longtext type string.

" get value from screen so it is accessable in event
  navigation->set_parameter( name  = 'longtext' ).

" Store value in local variable
  ld_longtext = navigation->get_parameter( name = 'longtext' ).

" Pass value in local variable to attribute of new page
  navigation->set_parameter( name  = 'longtext'       "attribute name on next page
                             value = ld_longtext ).   "value in local variable

  case event_id.
    when 'save'.
      navigation->goto_page('display.htm').
  endcase.


Step 5 - 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. Now enter a value and press the save button. This value should then be shown on a second page.




comments powered by Disqus