!--a11y-->
Event Handler 
For the order page, you need the event handler OnInputProcessing.

For basic information on event handlers, see the section Event Handlers in the Business Server Pages documentation.
If the user chooses Really submit order, and if the order executes successfully, the page corder.htm opens (compare with Modifying the Order Confirmation Page). If the user enters an incorrect password, or if the customer has not yet registered, the current page stays open, so that the customer can correct his or her entries.
OnInputProcessingcontains the following code:
DATA wa TYPE bscustomer. SELECT SINGLE * FROM bscustomer INTO wa
IF sy-subrc = 0. * user already signed-in IF pwd = wa-usrpwd. * password correct s_rc = 1. ELSE. * password incorrect page->messages->add_message( condition = 'passwordincorrect' otr_alias = 'SBOOKSHOP/PASSWORDINCORRECT' severity = page->messages->CO_SEVERITY_ERROR ).
ENDIF. ELSE. * user unknown page->messages->add_message( condition = 'notregistered' otr_alias = 'sbookshop/notregistered' severity = page->messages->CO_SEVERITY_WARNING ). ENDIF.
if event_id = 'doorder'.
if s_rc = 1. navigation->goto_page( 'corder.htm' ). endif.
endif. |
First, the system looks in the customer table BSCUSTOMER to see if the customer has registered.If the customer is registered, that is, if there is an entry for this customer in the table, the value of sy-subrc is set to 0. The system then checks whether the password that the customer entered matches the password in table BSCUSTOMER. If the passwords match, the internal return value s_rc is set to 1. If they do not match, it is set to 2.
If the customer enters an incorrect password, the system displays an error message using the messages object:
page->messages->add_message(
condition =
'passwordincorrect'
otr_alias =
'SBOOKSHOP/PASSWORDINCORRECT'
severity =
page->messages->CO_SEVERITY_ERROR ).
add_message adds an individual message, below the specified condition (condition). The message itself is implemented as an OTR alias text (see the Online Text Repository section in Event Handler). Parameter severity specifies the severity of the error: in this case it is a normal error (CO_SEVERITY_ERROR).

You can find additional information about the use of message objects in the reference documentation in Using Object Messages and Class CL_BSP_MESSAGES.
If an unknown user name is entered, the system displays an additional error message:
page->messages->add_message(
condition = 'notregistered'
otr_alias = 'sbookshop/notregistered'
severity =
page->messages->CO_SEVERITY_WARNING ).
If the value of s_rc is 1, the Order Confirmation Page (corder.htm) is opened. Otherwise, the current page stays open.
The return value s_rc is a Page Attribute that determines the output of the layout.
Now create
the Registration
Page.