cancel
Showing results for 
Search instead for 
Did you mean: 

Warning message (in a popup) before popup is closed?

former_member195355
Participant
0 Kudos

Hiya,

I have a popup screen that looks like this:

The user enters some data, saves it and then closes the popup window - via the cross-box in the top-right corner..

Nice and simple but uh-oh sometime the users forget to press save and close the popup window and so loose all their data.

Is there a way to do some checking when the window is closed?

I'd liek to issue a popup to say are you sure you want to exit without saving.

I'd be interested to hear any ideas you migth have.

Many thanks!

Accepted Solutions (1)

Accepted Solutions (1)

ramakrishnappa
Active Contributor
0 Kudos

Hi Robert,

Yes, you can register the close action of a window to a custom action in your view.

Your requirement can be achieved as below


  • Create an action 'CLOSE' in your view
  • Collect the popup window reference into view attribute wd_this->go_window

     

         i.e. if you set it as view attribute you can access it in any other method if required

  • Set the "OnClose " action of a popup window as below

        wd_this->go_window->set_on_close_action(

            EXPORTING

              view        =   WD_THIS->WD_GET_API( )

              action_name = 'CLOSE'

         ).

  • Now, go to event handler method ONACTIONCLOSE in methods tab and implement your logic to create a popup for confirmation by using method

    lo_window_manager->create_popup_to_confirm(

Upon close action on popup window, the event handler method ONACTIONCLOSE will be called

Hope this helps you.

Regards,

Rama

former_member195355
Participant
0 Kudos

Thansk for the detailed reply Rama,

I'm gettign a little stuck could you help me out, please?

-Create an action 'CLOSE' in your view:

-Collect the popup window reference into view attribute wd_this->go_window

erm, sorry I'm not quite sure how to do this?

could you clarify please?

ramakrishnappa
Active Contributor
0 Kudos

Hi Robert,

GO_WINDOW   TYPE REF TO if_wd_window.

Create the attribute as below

Hope this helps you.

Regards,

Rama

former_member195355
Participant
0 Kudos

Thanks Rama - that's great.

Do you know where I write the following?

  • Set the "OnClose " action of a popup window as below

        wd_this->go_window->set_on_close_action(

            EXPORTING

              view        =   WD_THIS->WD_GET_API( )

              action_name = 'CLOSE'

         ).

Is this placed after the popup is called i.e. after

lo_window    = lo_window_manager->create_window(
window_name       = 'W_RFQ_UPDATE'
title             = lv_title
*                   close_in_any_case = abap_true
message_display_mode   = if_wd_window=>co_msg_display_mode_selected
*                   close_button      = abap_true
button_kind       = if_wd_window=>co_button_none
*                    button_kind       = if_wd_window=>co_buttons_close
message_type      = if_wd_window=>co_msg_type_none
default_button    = if_wd_window=>co_button_none
).

lo_window->open( ).

Or does that code in the actual popup view somehwere?

ramakrishnappa
Active Contributor
0 Kudos

Hi Robert,

Please modify the code as below

wd_this->go_window  = lo_window_manager->create_window(
window_name      = 'W_RFQ_UPDATE'
title            = lv_title
*                  close_in_any_case= abap_false
message_display_mode   = if_wd_window=>co_msg_display_mode_selected
*                  close_button     = abap_true
button_kind      = if_wd_window=>co_button_none
*                   button_kind      = if_wd_window=>co_buttons_close
message_type     = if_wd_window=>co_msg_type_none
default_button   = if_wd_window=>co_button_none
).

        wd_this->go_window->set_on_close_action(

            EXPORTING

              view        =   WD_THIS->WD_GET_API( )

              action_name = 'CLOSE'

         ).

wd_this->go_window->open( ).

Hope this helps you.

Regards,

Rama

former_member195355
Participant
0 Kudos

Sorry Rama,

I think it might be our version of SAP as I still get an error message:

Ah well looks like I'll have to find a different way to do this.

Thanks for your help.

ramakrishnappa
Active Contributor
0 Kudos

Oh Robert...

There is a period missing at line 329 in the logic. but the code in the snap shot given looks fine.

It is a syntax issue, you could be able to fix it easily

If you still face issue, Please provide, full code so that I can correct it for you.

Regards,

Rama

former_member195355
Participant
0 Kudos

Hi Rama,

Yes line 329 is this line, but there shouldn't be a period after that should there?

          view   

=   WD_THIS->WD_GET_API( )

ramakrishnappa
Active Contributor
0 Kudos

Hi Robert,

You can replace WD_THIS->WD_GET_API( ) as below

data lo_view_controller type ref to if_wd_view_controller.

lo_view_controller = wd_this->wd_get_api( ).

     wd_this->go_window->set_on_close_action(

            EXPORTING

              view        =   lo_view_controller

              action_name = 'CLOSE'

         ).

If you still have issue, please check the parameter VIEW type in method SET_ON_CLOSE_ACTION. So, that you will find out what's the type of VIEW parameter.

Hope this helps you.

former_member195355
Participant
0 Kudos

How did you figure that out?

It works great now!

Thank you so much Rama.

You're knowledge of Web Dynpro is awesome!

If you don't mind me asking, how long have you been working with web dynpro and did you go on any training, or are you self taught.

In any case you are a real asset to SCN!

ramakrishnappa
Active Contributor
0 Kudos

Wow... good to hear that..

You are welcome Robert

Regards,

Rama

Answers (1)

Answers (1)

thanga_prakash
Active Contributor
0 Kudos

Hello Robert,

Try to find the screen name and goto SE41 -> Function list -> and find the function code of the cancel or EXIT icon.

In the screen flow logic code as when the function code is XXXX, raise a message.

Regards,

Thanga