cancel
Showing results for 
Search instead for 
Did you mean: 

Check Box Validations in ABAP WebDynpro

Former Member
0 Kudos

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.

Accepted Solutions (1)

Accepted Solutions (1)

Chaitanya_Priya
Product and Topic Expert
Product and Topic Expert
0 Kudos

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

Former Member
0 Kudos

Thanks Priya.

My Problem has been resolved with out creation of two attrobutes.

Thanks and Regards,

Abhi.

Answers (2)

Answers (2)

Former Member
0 Kudos

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.

Former Member
0 Kudos

Thanks Saurav.

For Good Solution Steps.

Thanks and Regards,

Abhi.

prasenjit_sharma
Active Contributor
0 Kudos

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

Former Member
0 Kudos

Hi Sharma,

Nice to see your reply, i know i need to write event on SAVE button, i am confusing how to compare two check boxes, i have two attrubtes v1 and v2,

if v1 = x and v2 = x then i need raise the exception like " invalid selection"

if not " message saved successfully"

could you please tell me the exact code in ABAP webDynpro.

Thanks and Regards,

Abhiram.

prasenjit_sharma
Active Contributor
0 Kudos

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