cancel
Showing results for 
Search instead for 
Did you mean: 

BSP Page validation through ABAP in EventHandler

Former Member
0 Kudos
229

Hello Experts,

I am new in BSP Application.Kindly help me.

I have created a page through HTML code, now I have to validate input fields through ABAP code instead of JAVASCRIPT.

Can I do it in EventHandler.

If yes then please let me know with some examples.

Regards,

Ankur.

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi

You can validate it with the standard class CL_BSP_MESSAGES.

Please check with the following link [BSP application to display messages with standard class |http://wiki.sdn.sap.com/wiki/x/ZQAFC]

Hope this helps you.

Thanks,

Rajani

former_member459142
Participant
0 Kudos

Hi

please tag answered the post if problem has been solved.

Thanks

former_member459142
Participant
0 Kudos

Hi Ankur,

Use HTMLB

In Layout


<td width="25%"><htmlb:inputField id = "vname"  disabled = "False" value = "<%= v_visitor %>"/>* <font color="red" size="2"><b><%= page->messages->assert_message( 'vname' ) %></b></font></td>

In On InputProcessing


CLASS CL_HTMLB_MANAGER DEFINITION LOAD.

IF event_id = CL_HTMLB_MANAGER=>EVENT_ID.

  DATA: event TYPE REF TO CL_HTMLB_EVENT.
  event = CL_HTMLB_MANAGER=>get_event( runtime->server->request ).
  IF event->name = 'button' AND event->event_type = 'click'.
    DATA: button_event TYPE REF TO CL_HTMLB_EVENT_BUTTON.
    button_event ?= event.
  ENDIF.


v_visitor = request->get_form_field( 'vname' ).

case event->id.
  when '<YOUR EVENT>'.

  if v_visitor = ''.

      page->messages->add_message(
      condition = 'vname'
      message   = 'Visitor Name can not be blank'
      severity  = page->messages->CO_SEVERITY_ERROR ).
endif.
endcase.

try this

thanks,

Prashant

former_member233090
Active Contributor
0 Kudos

Hi ,

can u pls tell me what type of validations you want to ......

validations can be given with javascript look at this example.

http://wiki.sdn.sap.com/wiki/display/BSP/SampleBSPApplicationtoDisplayMessage(Validation)instatusbar

without javascript validations can be given but what type of validations u want .. do u want a pop up or what exactly do u want to display

Bhavana

Former Member
0 Kudos

Hi bhavana,

Thanks for ur response.

Validations like, I have suppose 5 check boxes in my page which is designed by HTML code.

Now I have to put a validation that atleast 1 check box should be checked while submitting a form using SUBMIT button.

Likewise some input fields should be mandatory while submitting a form.

Another validation is, suppose some fileds are depend on Check box.

i.e. if a particular check box is checked then that fields will get enabled for input else not.

Regards,

Ankur.

former_member184111
Active Contributor
0 Kudos

Hi Ankur,

All validations mentioned by you can be achieved using simple javascript code including enabling the fields only if at least one CB is selected.

Try this URL..

http://tinyurl.com/lq59fe

Why do you want to do it on server side?

Regards,

Anubhav

former_member233090
Active Contributor
0 Kudos

Hi anukur,

Ok, Let me show you one example which i have done ok,may be that may help you out.

layout page is

on input processing

  • event handler for checking and processing user input and

  • for defining navigation

DATA:

w_event TYPE REF TO cl_htmlb_event,

w_obj TYPE REF TO object,

w_carrid TYPE REF TO cl_htmlb_inputfield,

r_carrid TYPE RANGE OF sflight-carrid,

r_id LIKE LINE OF r_carrid.

CALL METHOD cl_htmlb_manager=>get_event

EXPORTING

request = runtime->server->request

RECEIVING

event = w_event.

CASE w_event->id.

WHEN 'get'.

CALL METHOD cl_htmlb_manager=>get_data

EXPORTING

request = runtime->server->request

name = 'inputfield'

id = 'carrid'

RECEIVING

data = w_obj.

w_carrid ?= w_obj.

w_scarrid = w_carrid->value.

w_input = w_scarrid.

CLEAR: w_obj.

IF w_scarrid IS INITIAL.

page->messages->add_message(

condition = 'w_id1'

message = 'Enter carrid value'

severity = page->messages->co_severity_error ).

ENDIF.

IF w_scarrid CA '0123456789~!@#$%^&*()_-+='.

page->messages->add_message(

condition = 'w_id2'

message = 'Enter a valid carrid'

severity = page->messages->co_severity_error ).

exit.

ENDIF.

IF w_scarrid IS NOT INITIAL.

TRANSLATE w_scarrid TO UPPER CASE.

IF w_scarrid IS NOT INITIAL.

r_id-low = w_scarrid.

r_id-sign = 'I'.

r_id-option = 'CP'.

APPEND r_id TO r_carrid.

ENDIF.

SELECT carrid connid fldate price seatsmax seatsocc FROM sflight

INTO TABLE t_flight WHERE

carrid IN r_carrid.

IF sy-subrc = 0.

fl_flag = 1.

EXIT.

ELSE.

page->messages->add_message(

condition = 'w_id'

message = 'No record exist '

severity = page->messages->co_severity_error ).

ENDIF.

ENDIF.

ENDCASE.

Edited by: Bhavana Amar on Mar 19, 2010 8:35 AM

former_member233090
Active Contributor
0 Kudos

And the Layout is

<%= page->messages->assert_message( 'w_id' ) %><br>

<%= page->messages->assert_message( 'w_id1' ) %><br>

<%= page->messages->assert_message( 'w_id2' ) %><br>

Edited by: Bhavana Amar on Mar 19, 2010 8:39 AM