sapdev logo background
sapdev logo sapdev logo
Comments

Capture BSP radiobutton selection using HTML and the OnInputProcessing BSP Event




If you have not created a BSP before you will need to look the following example of creating a simple BSP application just to get an understanding of the basic components. You can then use the information below to build the BSP that will display a list of radiobuttons to the user and capture which one they have selected.

Properties Tab
No specific requirements

Layout Tab

<%@page language="abap"%>
<%@extension name="htmlb" prefix="htmlb"%>
<%
* Data declarations used in layout section
data: ld_datetext type string,
      ld_tabix type string.
data wa_ekko like line of it_ekko.
%>
<html>
  <head>
    <link rel="stylesheet" href="../../sap/public/bc/bsp/styles/sapbsp.css">
    <title>SAP RadioButton bsp </title>
  </head>
  <body>
    <h1>BSP to demonstrate radiobutton</h1>
    <p>
    <% select *
       up to 10 rows
        from ekko
        into table it_ekko.
    %>
    <form method="post" name="form" id="form" >
    <table>
     <% loop at it_ekko into wa_ekko.
        ld_tabix = sy-tabix.
     %>
     <tr>
      <td>
       <%=wa_ekko-ebeln%>
      </td>
      <td>
       <input align="right" value="<%=ld_tabix%>" name="ekko_radio" type="radio">
      </td>
     </tr>
     <% endloop. %>
     <tr><td colspan="2">
     <input name="OnInputProcessing(submit)" type="submit" id="submit" value="Go">
    </td></tr>
    </table>
  </body>
</html>

Page Attributes Tab
ekko_radio TYPE STRING
it_ekko TYPE TT_EKKO

Type Definitions Tab
TYPES: tt_ekko type STANDARD TABLE OF ekko.

Event Handler Tab
Within the OnInputProcessing add the following code:

data: gd_check type string,
      ld_tabix type i,
      wa_ekko like line of it_ekko.

case event_id.
  when 'submit'.
* ekko_radio will now contain the line number of the selected radio button
endcase.

Test code
This tutorial is really just to show the radiobutton functionality without getting into producing a full blown application so In-order to test it works simply set a break point within the OnInputProcessing ABAP code . This is done using the usual method (needs to be an external break point if you are using a version of SAP that does not do this automatically). Then execute the application, the row number of the selected radiobutton will be contained in the page attribute 'ekko_radio'.



See here for how to implement a HTML Checkbox into your BSP.




comments powered by Disqus