cancel
Showing results for 
Search instead for 
Did you mean: 

Data Validation in web dynpro

0 Kudos

Hi,

In my view I have a required input field CHECKNAME and a button CONFIGURE.

Only after entering the checkname and when the user clicks the configure button, the rest of the fields on my UI will be filled.

Scenario: User inputs checkname and clicks on configure. All my fields on UI will be populated. Now user deletes the checkname(does not click enter or Configure button) but all my fields stil have values and the user can edit the values. This

should not happen.

How do i handle this?

Accepted Solutions (0)

Answers (5)

Answers (5)

Chaitanya_Priya
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi,

what you can do is on action of configure button write the following code:

Get the value of the input field CHECKNAME .if it is initial set the rest of the fields on UI to null.

lo_el_user_role->get_attribute(

EXPORTING

name = `CHECKNAME`

IMPORTING

value = lc_CHECKNAME).

IF LC_CHECKNAME IS INITIAL.

"set rest of fields on UI to initial

lo_el_user_role->set_attribute(

EXPORTING

name = `CHECKNAME`

value = ' ' ).

ELSE.

"write the code which you want if the data is present in input field.

ENDIF

There may be case where user can remove the data in the input field and click on ENTER even then the rest of fields in UI must be blank.

So put the same code on events OnEnter of the input field.

Regards,

Priya

Former Member
0 Kudos

Hi,

You have to invalidate the node to which your UI fields are mapped.

I think in the WDDOMODIFY method of the view, you can check for the CHECKNAME value.

If it is INITIAL, then invalidate the above said node.

Regards

Shruti

Former Member
0 Kudos

Scenario: User inputs checkname and clicks on configure. All my fields on UI will be populated. Now user deletes the checkname(does not click enter or Configure button) but all my fields stil have values and the user can edit the values. This

should not happen.

1 u create a context attribute say ca_check , of type string ,bind it with ur checkname.

2 bind other fields , which u want to be editable later on to wdy_boolean type context attribute , say ca_edit

3 In the onAction of the Configure button :

a) read the ca_check using get_attribute method

IF it is not null , thn only

b) set the other fields to 'X' using set_attribute method


  DATA lo_nd_cn_check TYPE REF TO if_wd_context_node.
    DATA lo_el_cn_check TYPE REF TO if_wd_context_element.
    DATA ls_cn_check TYPE wd_this->element_cn_check.
    DATA lv_ca_check LIKE ls_cn_check-ca_check.
*   navigate from <CONTEXT> to <CN_CHECK> via lead selection
    lo_nd_cn_check = wd_context->get_child_node( name = wd_this->wdctx_cn_check ).

*   get element via lead selection
    lo_el_cn_check = lo_nd_cn_check->get_element(  ).

*   get single attribute
    lo_el_cn_check->get_attribute(
      EXPORTING
        name =  `CA_CHECK`
      IMPORTING
        value = lv_ca_check ).

IF lv_ca_check IS NOT INITIAL .


// if user has entered value , set ca_edit to 'X'
// using set_attribute method

lo_el_cn_check->set_attribute(
      EXPORTING
        name =  `CA_EDIT`
      IMPORTING
        value = 'X' ).

ENDIF.

Former Member
0 Kudos

Hi Victoria,

I think it is not possible in webdynpro abap to validate any validations or checks , without pressing enter key or clicking any other buttons.

Regards

S.Balasubramanian.

former_member40425
Contributor
0 Kudos

Hi,

You can do one thing in the onAction of Configure button you can disabale(or can set as read only) your Input field so that user will not able to edit values in input field.

In order to achieve this create a context attribute of type wdy_boolean and bind it with the enable property of your input field.

to enable set it as : 'X'

To disable set it : ''

i hope it helps.

Regards,

Rohit

Former Member
0 Kudos

hi,

You can go ahead with the approach of Rohit but you wont be able to change input field once it is disabled as there is no other action.

In that case you have to have one more button so that you can change your input field and in onAction of New button, you can clear the other fields.

To avoid Another button, you could also Use Toggle Button .