cancel
Showing results for 
Search instead for 
Did you mean: 

Validation in Popup

Former Member
0 Kudos

Hi,

I'm creating a 2 Views and 2 windows.

In 1st view when pressing a button I'm showing 2nd view as popup.

I used

1. lc_window_manager to create window.

2.button_kind = if_wd_window=>co_buttons_ok

It is working fine.

I want to validate the data entered in the popup window.

For ex: if the 2nd view as a inputfield of type string.

User should enter only string, if number occurs error should be displayed.

How to validate the data in popup?

I remove the button_kind and tried adding a button UI element in 2nd view.

But on pressing the 2nd view, how can i close the popup and return to the 1st view?

Thankx,

Accepted Solutions (1)

Accepted Solutions (1)

baskaran00
Active Participant
0 Kudos

Hi Suba,

you can try the below code to open or close the popup.

Provided u have to maintain a variable as boolean.

If there is error/noerror u have to update the variable.

data l_error type boolean.

data: l_api type ref to if_wd_view_controller,

l_window_ctlr type ref to if_wd_window_controller,

l_popup type ref to if_wd_window.

l_api = wd_this->wd_get_api( ).

l_window_ctlr = l_api->get_embedding_window_ctlr( ).

if l_window_ctlr is bound.

l_popup = l_window_ctlr->get_window( ).

if ( l_popup is bound and l_error = abap_false ).

l_popup->close( ).

else.

wd_this->open_popup( ).

l_popup->open( ).

endif.

endif.

Hope it will help u.

Thanks

Answers (3)

Answers (3)

Former Member
0 Kudos

Nithya,

I tried ur code, but again it is showing the error msg in View1.

I tired by adding a button in View2 and on pressing the button I'm validating the fields. If there is no error how can i close the View2 and get the View1?

former_member189058
Active Contributor
0 Kudos

Hi Suba,

To close the view:



  l_api TYPE REF TO if_wd_view_controller,
  l_window_ctlr TYPE REF TO if_wd_window_controller,
  l_popup TYPE REF TO if_wd_window.
  l_api = wd_this->wd_get_api( ).
  l_window_ctlr = l_api->get_embedding_window_ctlr( ).

  IF l_window_ctlr IS BOUND.
    l_popup = l_window_ctlr->get_window( ).
    IF l_popup IS BOUND.
        l_popup->close( ).
    endif. 
  endif.

Do this if validations are successfull.

Regards,

Reema.

Former Member
0 Kudos

Reema,

I worked on the code. it works fine.

But it is showing the error msg in the View1, but I need the error msg to be displayed in the view2.

Former Member
0 Kudos

You need to get the current view's view controller instance, and call the corresponding message manager. The following code will help.

data: msg type ref to if_wd_message_manager.
msg = wd_this->wd_get_api( )->get_message_manager( ).
msg->report_t100_message( ).

Regards,

Nithya

former_member189058
Active Contributor
0 Kudos

Hi,

What you can do is: use button kind ok....

in the 2nd view, do this:

in wddoinit



data:
  l_api type ref to if_wd_view_controller,
  l_window_ctlr type ref to if_wd_window_controller,
  l_popup type ref to if_wd_window.

l_api = wd_this->wd_get_api( ).

l_window_ctlr = l_api->get_embedding_window_ctlr( ).

if l_window_ctlr is bound.
  l_popup = l_window_ctlr->get_window( ).
  if l_popup is bound.
  l_popup->subscribe_to_button_event(
                        button = if_wd_window=>co_button_ok
                        button_text = 'Ok' "#EC *
                        action_name = 'OK_CLICKED'
                        action_view = l_api
                        is_default_button = abap_true ).
  endif.
endif.

now in actions, create an action of the name OK_CLICKED.

Under Methods, you will get an event handler by the name ONACTIONOK_CLICKED

In this event handler, you can do all the validations you need to.

If validations fail, show message

else, close the window

Regards,

Reema.