BSP checkboxes using HTML and the OnInputProcessing BSP Event
If you have not created a BSP before you might want to have a look at this example of creating a simple BSP application just to get an
understanding of the basic components. The below steps will then take you though the steps required to implement a BSP web page containing multiple
checkboxes and capturing which have been checked by the user.
<%@page language="abap"%>
<%@extension name="htmlb" prefix="htmlb"%>
<%
* Data declarations used in layout section
data: ld_datetext type string,
ld_tabix type sy-tabix,
ld_index type sy-index,
ld_checkid type string,
ld_checkname type string,
ld_count type i,
ld_checkcount(3) type n.
data wa_ekko like line of it_ekko.
%>
<html>
<head>
<link rel="stylesheet" href="../../sap/public/bc/bsp/styles/sapbsp.css">
<title>SAP checkbox bsp </title>
</head>
<body>
<h1>BSP to display checkbox</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_checkcount = ld_checkcount + 1.
ld_count = ld_count + 1.
CONCATENATE 'checkid' ld_checkcount into ld_checkid.
CONCATENATE 'checkname' ld_checkcount into ld_checkname.
%>
<tr>
<td>
<%=wa_ekko-ebeln%>
</td>
<td>
<input align="right" name="<%=ld_checkname%>" type="checkbox"
id="<%=ld_checkid%>">
</td>
</tr>
<% endloop. %>
<tr><td colspan="2">
<input name="OnInputProcessing(submit)" type="submit"
id="submit" value="Go">
</td></tr>
</table>
</body>
</html>
Step 4 - Test code as it stands
* event handler for checking and processing user input and
* for defining navigation
data: gd_check type string,
ld_checkname type string,
ld_checkcount(3) type n,
ld_tabix type i,
wa_ekko like line of it_ekko.
case event_id.
when 'submit'.
clear: ld_checkcount.
* If it_ekko is empty at this point, ensure BSP is set to statefull, or
* alternatively re-select data.
LOOP AT it_ekko INTO wa_ekko.
ld_tabix = sy-tabix.
ld_checkcount = ld_checkcount + 1.
CONCATENATE 'checkname' ld_checkcount into ld_checkname.
navigation->set_parameter( name = ld_checkname ).
gd_check = navigation->get_parameter( name = ld_checkname ).
if not gd_check is INITIAL. "= 'on' or ' '
endif.
endloop.
endcase.
Step 6 - Demonstrate functionality
|
||||||||