Skip to Content
avatar image
Former Member

Check Box Validations in ABAP WebDynpro

Hi All,

I am new to ABAP WebDynpro Coding, i have new requirement, in that one i have two check boxes, if i am selecting those two check boxes after that if i am clicking on SAVE button after that message need to display "Invalid Selection" and it won't save in the back end.

If i am selecting either one, i need to display message like" DATA WAS SAVED SUCCESSFULLY"

If any have any idea about this one, please help me.

Really i appreciate.

Thanks in Advance.

Thanks and Regards,

Abhiram.

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

3 Answers

  • Best Answer
    Nov 04, 2009 at 02:59 AM

    Hi,

    in the event handler of SAVE write the below code.

    Hi,

    You can get the value of the check boxes and then compare..

    lo_el_resume_info->get_attribute(

    EXPORTING

    name = `chkbx1`

    IMPORTING

    value = lv_chkb1 ).

    lo_el_resume_info->get_attribute(

    EXPORTING

    name = `chkb2`

    IMPORTING

    value = lv_chb2 ).

    If lv_chkb1 IS NOT INITIAL AND LV_CHKB2 IS NOT INITIAL.

    CALL METHOD lo_message_manager->report_error_message

    EXPORTING

    message_text = 'INVALID SELECTION'.

    ENDIF.

    IF lv_chkb1 IS NOT INITIAL OR LV_CHKB2 IS NOT INITIAL.

    CALL METHOD lo_message_manager->report_success_message

    EXPORTING

    message_text = 'DATA SAVED SUCCUSFULLY'.

    ENDIF.

    if you want to add any condition of both check boxes are not checked you can write in similar way.

    Regards,

    Priya

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 03, 2009 at 09:23 PM

    Hi,

    At which part of these you are facing problem?

    1. You need to do coding at the Save event handler class

    2. Get the values of the check-boxes and see if they are selected.

    3. display the message as per your requirement.

    Regards

    Prasenjit

    Add comment
    10|10000 characters needed characters exceeded

    • Hi,

      That means you are having trouble retrieving the values of the check-boxes.

      try this.

      lr_node_header = wd_context->get_child_node( 'check box context' ).

      lr_elem_header->get_static_attributes( IMPORTING static_attributes = <local value> ).

      now compare the values of <local value>.

      Hope this helps..

      Regards

      Prasenjit

  • avatar image
    Former Member
    Nov 04, 2009 at 04:08 AM

    hi,

    Follow these steps :

    1. make the onAction of SAVE button.

    2. In OnAction , Read both the attributes binded to checkbox : Att1 , Att2.

    DATA lo_nd_np4_number TYPE REF TO if_wd_context_node.

    DATA lo_el_np4_number TYPE REF TO if_wd_context_element.

    DATA ls_np4_number TYPE wd_this->element_np4_number.

    DATA lv_np4_checkbox LIKE ls_np4_number-np4_checkbox.

    • navigate from <CONTEXT> to <NP4_NUMBER> via lead selection

    lo_nd_np4_number = wd_context->get_child_node( name = wd_this->wdctx_np4_number ).

    • get element via lead selection

    lo_el_np4_number = lo_nd_np4_number->get_element( ).

    • Fetch the Value of Np4 Relevant checkbox *********************************

    lo_el_np4_number->get_attribute(

    EXPORTING

    name = `NP4_CHECKBOX`

    IMPORTING

    value = lv_np4_checkbox ).

    You can genereate the above code by code wizard ( control + F7 ).

    Here NP4_CHECKBOX is my first att binded to checkbox.

    4. Similarly read the second attribute.

    5. NOw check the values of both the attributes .

    • get message manager

    DATA lo_api_controller TYPE REF TO if_wd_controller.

    DATA lo_message_manager TYPE REF TO if_wd_message_manager.

    lo_api_controller ?= wd_this->wd_get_api( ).

    CALL METHOD lo_api_controller->get_message_manager

    RECEIVING

    message_manager = lo_message_manager

    .

    if lv_np4_checkbox = 'X' and lv_np4_checkbox1 = 'X'.<Report message>

    • report message

    CALL METHOD lo_message_manager->report_error_message

    EXPORTING

    message_text = 'Invalid Selcteion'.

    else.

    if if lv_np4_checkbox = 'X' or lv_np4_checkbox1 = 'X'

    CALL METHOD lo_message_manager->report_success

    EXPORTING

    message_text = 'DAta saved succesfully.

    endif.

    endif.

    For messages , Use Code wizard ->Generate Message.

    Add comment
    10|10000 characters needed characters exceeded