cancel
Showing results for 
Search instead for 
Did you mean: 

How to handle button event in modalup in webdynpro

Former Member
0 Kudos

Hi Gurus,

      We have two windows(each window have separate view),Now iam calling one window(view1) to

another window(view2) by using CREATE_AND_OPEN_POPUP,whenever the 2nd window(along with 2nd viw\ew) opens

one OK button is coming on that popup,Now how to handle this popup .Any one could u please suggest me the solution

below is the code am using....



DATA LO_WINDOW_MANAGER TYPE REF TO IF_WD_WINDOW_MANAGER.

DATA LO_API_COMPONENT  TYPE REF TO IF_WD_COMPONENT.

DATA LO_WINDOW         TYPE REF TO IF_WD_WINDOW.

DATA LT_BUTTONS        TYPE WDR_POPUP_BUTTON_LIST.

DATA LS_CANC_ACTION    TYPE WDR_POPUP_BUTTON_ACTION.

Data ls_buttons like LINE OF LT_BUTTONS.

Data ls_CANCEL_ACTION type WDR_POPUP_BUTTON_ACTION.

     ls_buttons-BUTTON = '7'.

     ls_buttons-BUTTON = '8'.

append ls_buttons to lt_buttons.

ls_CANCEL_ACTION-ACTION_NAME = 'OK'.

LO_API_COMPONENT           = WD_THIS->WD_GET_API( ).

LO_WINDOW_MANAGER          = LO_API_COMPONENT->GET_WINDOW_MANAGER( ).

* create the cancel icon, but without any action handler

LS_CANC_ACTION-ACTION_NAME = 'OK'.

* Simple example, see docu of method create_and_open_popup for details

LT_BUTTONS                 = LO_WINDOW_MANAGER->GET_BUTTONS_OK(

    default_button       = if_wd_window=>co_button_ok

).

LO_WINDOW                  = LO_WINDOW_MANAGER->CREATE_AND_OPEN_POPUP(

    WINDOW_NAME          = 'INVOICES_WIN'

    title                = 'Bill Initiation Process'

    MESSAGE_TYPE         = IF_WD_WINDOW=>CO_MSG_TYPE_NONE

    MESSAGE_DISPLAY_MODE = IF_WD_WINDOW=>CO_MSG_DISPLAY_MODE_SELECTED

*    is_resizable         = ABAP_TRUE

    BUTTONS              = LT_BUTTONS

    CANCEL_ACTION        = LS_CANC_ACTION

).

Accepted Solutions (1)

Accepted Solutions (1)

former_member222068
Active Participant
0 Kudos

Hi Kranthi,

Use the method: SUBSCRIBE_TO_BUTTON_EVENT( ).

Logic to be implemented below your code:

     Data: lr_view_controller TYPE REF TO if_wd_view_controller.

   lr_view_controller = wd_this->wd_get_api( ).

  CALL METHOD lo_window->subscribe_to_button_event   " register event before opening window

    EXPORTING

      button                 = if_wd_window=>co_button_ok

      action_name       = 'OK'   " You have to create action OK in Actions tab & write req handling

      action_view         = lr_view_controller.

Thanks & Regards,

Sankar Gelivi

Former Member
0 Kudos

thank you  kirankumar,ramakrishnappa,sankar ....

                  

                Iam writing the above code in compoent level.So it is throwing syntax error for the below statement.

                          lr_view_controller = wd_this->wd_get_api( ).

                     It might be throwing becoz we are not maintaing view controller reference.So how we can maintain view conctroller reference in component controller...

                                      Thanks in advance....

Regards,

kranthi

former_member184578
Active Contributor
0 Kudos

Hi,

Go to attributes tab of Component controller and create an attribute, say, gv_view_controller of type ref to if_wd_view_controller.

Then in WDDOINIT method of your view, set the reference, using

wd_comp_controller->gv_view_controller = wd_this->wd_get_api( ).

Then pass wd_this->gv_comp_controller to the subscribe to button event method in Component controller,

Or, If you are calling the component controller method from View, create an importing parameter in the component controller method and pass the view controller reference.

Regards,

Kiran

Former Member
0 Kudos

Hi thanks for each and every one..sorry for late reply,

          How can we rename OK button as "SUBMIT"

thanks & regards,

kranthi

ramakrishnappa
Active Contributor
0 Kudos

Hi Kranthi,

You can set the button text as below

  CALL METHOD lo_window->subscribe_to_button_event 

    EXPORTING

      button                 = if_wd_window=>co_button_ok

      button_text   = 'Submit'

      action_name       = 'OK' 

      action_view         = lr_view_controller.

Hope this helps you.

Regards,

Rama

former_member205842
Participant
0 Kudos

Hi Ram,

             I have a req that i want to read event_id of on action button in portal my post_exit to write logic ...please help how to read event id of button. i assign event id and everything but am not getting how to read event id and write logic in my post_exit method.

Regards

Syed

ramakrishnappa
Active Contributor
0 Kudos

Hi Syed,

Please elaborate your requirement little more.

Do you want to read button and then get action name associated with that button?

Are you creating post_exit for WDDOMODIFYVIEW( )?

Regards,

Rama

former_member205842
Participant
0 Kudos

Hi Ram,

             Thanks for replying early.. my req is i have created button( CORPORATE ) on cnr_view when i click on that i want to display my custom WD Application..in my CNR_VIEW methods i have a method as BUTTON_PRESSED which is standard method, when user click on any button like CORPORATE it trigger to BUTTON_PRESSED method..here am writing my own logic in post_exit of BUTTON_PRESSED method there i have to read event id of which button is pressed by the user.

Regards

Syed

ramakrishnappa
Active Contributor
0 Kudos

Hi Syed,

The method BUTTON_PRESSED( ) is called from on action BUTTON_PRESSED and event reference is passed to parameter io_event

Now, you can get the event id as below


data           lv_action_id type string.

  lv_action_id = io_event->get_string( 'ACTION_ID' ).

Hope this helps you.

If you still need further assistance on the same please create a new question, as this discussion is of different topic.

Regards,

Rama

former_member205842
Participant
0 Kudos

HI Ram,

              I already used this code

data           lv_action_id type string.

  lv_action_id = io_event->get_string( 'ACTION_ID' ).



but am getting error that io_event is unknown and i have to pass ACTION_ID is my button id name or button name.


I don't want to pass event id directly ...i have to read when user perform some action on particular button then only i have to trigger my logic.

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi kiran n ramakrishna,

          Apart from "OK"(am using this as SUBMIT) button i need to add one more button like cancel(for reject purpose).How we can add this extra button and we need to do some rejection functionality in this button ...

              Can anyone could lz suggest me the solution..thanks in advance...

Regards,

kranthi

ramakrishnappa
Active Contributor
0 Kudos

kranthi kumar wrote:

          Apart from "OK"(am using this as SUBMIT) button i need to add one more button like cancel(for reject purpose).How we can add this extra button and we need to do some rejection functionality in this button ...

              Can anyone could lz suggest me the solution..thanks in advance...

You can make use of buttons IF_WD_WINDOW=>CO_BUTTONS_OKCANCEL,

Please find the answer in the below link.

ramakrishnappa
Active Contributor
0 Kudos

Hi Kranthi,

Please refer the below document, which clearly explains of handling of button's action on popup window

Hope this helps you.

Regards,

Rama

former_member184578
Active Contributor
0 Kudos

Hi,

Use SUBSCRIBE_TO_BUTTON_EVENT method of window before opening window.

Use Create_window method.

Code Snippet:


DATA lr_window_manager TYPE REF TO if_wd_window_manager.

  DATA lr_api_component  TYPE REF TO if_wd_component.

  DATA lr_window         TYPE REF TO if_wd_window.

  data lr_view_controller TYPE REF TO if_wd_view_controller.

  lr_api_component  = wd_comp_controller->wd_get_api( ).

  lr_window_manager = lr_api_component->get_window_manager( ).

  lr_window         = lr_window_manager->create_window(

                     window_name            = 'INVOICES_WIN'

                     message_display_mode   = if_wd_window=>co_msg_display_mode_selected

                     button_kind            = if_wd_window=>co_buttons_ok

                     message_type           = if_wd_window=>co_msg_type_none

                     default_button         = if_wd_window=>co_button_ok

                     ).

   lr_view_controller = wd_this->wd_get_api( ).

  CALL METHOD lo_window->subscribe_to_button_event   " register event before opening window

    EXPORTING

      button            = if_wd_window=>co_button_ok

      action_name       = 'OK'   " You have to create action OK in Actions tab & write req handling

      action_view       = lr_view_controller.

  lo_window->open( ).

Hope this helps u,

Regards,

Kiran