cancel
Showing results for 
Search instead for 
Did you mean: 

Open window code in Component controller

Former Member
0 Kudos

Hello,

My requirement is to show the pop up window for search help which is reuseble for all view.for that i have created one method in component controller which can be used by all view.

I have created one window "TEST_WINDOW" and embedded a view name as "TEST_VIEW".

By following code window is opened properly but after adding subscribe_to_button_event method i m facing null pointer error.



  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 l_api type ref to if_wd_view_controller.


  lo_api_component  = wd_this->wd_get_api( ).
  lo_window_manager = lo_api_component->get_window_manager( ).

  lo_window   = lo_window_manager->create_window(
                     window_name            = "TEST_WINDOW"
                     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
                     ).

 lo_window->open( ).

 

I have added following code.Code for "ok" button action .Code created 'a_selected_material' action is properly created in TEST_VIEW view but null pointer is getting in this line lo_window->subscribe_to_button_event(



lo_window->subscribe_to_button_event(
               button            = if_wd_window=>co_button_ok
               action_name       = 'a_selected_material'
               action_view       = l_api
               is_default_button = abap_false ).

Please help me out for this issues.

Thanks & ragards

Abhilasha Dahare.

Accepted Solutions (0)

Answers (3)

Answers (3)

former_member222068
Active Participant
0 Kudos

Hi Abi,

Define OVS( to the required attribute ) in the Component controller. Define context mapping to the required views. Now you can use OVS attribute as search help . Hope your problem is solved. Can you let me know if your doubt is not clarified.

Regards,

Sankar

RicardoRomero_1
Active Contributor
0 Kudos

Hi,

What is in l_api ?

I think you need to add a parameter to your method called for example i_view_api TYPE REF TO IF_WD_VIEW_CONTROLLER.

And before to call this method get its value like this:

DATA lo_api_YOUR_VIEW TYPE REF TO if_wd_view_controller.
    lo_api_YOUR_VIEW = wd_this->wd_get_api( ).

Former Member
0 Kudos

1)You need view controllers to subscribe to the event. What u can do is to keep the first part (creating popup window ) in the component controller. This method should return you the lo_window.

Do the Subscrption part in the views. using the lo_window.

2)Another way it to receive view controller from the view and use that view controller for Subscription.

I would go with option 2.

Former Member
0 Kudos

Hi Baskaran

i have done lwith second option.i get the reference of view controller from view ,n a_selected_material method is also created in view.window open properly but when i clicked on ok button i got dump as follow.

Note

■The following error text was processed in the system DB7 : Action &OBJECT_ID& does not exist

■The error occurred on the application server gscapp01t_DB7_12 and in the work process 0 .

■The termination type was: RABAX_STATE

■The ABAP call stack was:

Method: IF_WDR_RR_CONTROLLER~GET_ACTION of program SAPLWDR_RUNTIME_REPOSITORY

Method: GET_ACTION_INTERNAL of program CL_WDR_CONTROLLER=============CP

Former Member
0 Kudos

Hello all,Thanks for your reply.

My problem is solved.I created on context attribute VIEW_ID of type if_wd_view_controller.

i get the reference from view from method wdmodify view.



 DATA: lo_api TYPE REF TO if_wd_view_controller.


  IF first_time = 'X'.
    lo_api = wd_this->wd_get_api( ).

    DATA lo_nd_view_details TYPE REF TO if_wd_context_node.
    DATA lo_el_view_details TYPE REF TO if_wd_context_element.
    DATA ls_view_details TYPE wd_this->element_view_details.
    DATA lv_view_id LIKE ls_view_details-view_id.
    lo_nd_view_details = wd_context->get_child_node( name = wd_this->wdctx_view_details ).
    lo_el_view_details = lo_nd_view_details->get_element(  ).

    lo_el_view_details->set_attribute(
      EXPORTING
        name =  `VIEW_ID`
        value = lo_api ).

  endif.

and pass this context for subscribe_to_button_event method as follow.



  DATA lo_nd_view_details TYPE REF TO if_wd_context_node.
  DATA lo_el_view_details TYPE REF TO if_wd_context_element.
  DATA ls_view_details TYPE wd_this->element_view_details.
  DATA lv_view_id LIKE ls_view_details-view_id.
  lo_nd_view_details = wd_context->get_child_node( name = wd_this->wdctx_view_details ).
  lo_el_view_details = lo_nd_view_details->get_element(  ).

  lo_el_view_details->get_attribute(
    EXPORTING
      name =  `VIEW_ID`
    IMPORTING
      value = lv_view_id ).



* creating ok button
  lo_window->subscribe_to_button_event(
             button = if_wd_window=>co_button_ok
             action_name = 'A_SELECTED_ROW'
             action_view = lv_view_id
             is_default_button = abap_true ).

and for Action &OBJECT_ID& does not exist error i change method name in caps before that i wrote method in small case.

Thanks alot

Abhilasha Dahare

Former Member
0 Kudos

a verry nice idea..thx for this inspiration

kind regards

tobias