cancel
Showing results for 
Search instead for 
Did you mean: 

Accessing the parameters of window inbound plug in embedded view.

Former Member
0 Kudos

Hi experts,

I am facing problem with the accessing parameter values of  inbound plug of window in the one of view embedded in the window.

i am setting the parameter values in out bound plug of view present in one component. and receiving the parameter in interface view(window)of another component.Now i want to access this parameter value in one of the view embedded in window .

what is the solution for this?

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

HI Vishal

I think following areticle will help you to find out the answer.

Here I have two views View1 and View 2. There is a componenet controller and another custom controller. In Component Controller I created node 'NODE_EMP1'  and it has the attributes

NAME, CITY and STATE.

And in custom cotroller I created another node same as the node in component controller.

That node is NODE_EMP2.

And there are two views View one which is mapped with Component controller. View_Two which is mapped with Custom controller.

In both views we have to include the window controller, in the  property tab of view.

View_Two mapped with ZEMP_CUST_CONTROLLER context.

Created an Inbound plug in View2.

Now If you want to pass the data through Window parameter see the follwoing.

Here I have created an outbound plug with three parameters.

Next we have to embed these views in Window and link the plugs.

Oubound plug of window is linked with Inbound plug of View2.

Now save Window.

I am triggering the plug in View 1. We are entering the values in View one  and clicking on the button it will trigger the plug. So ONACTIONCLICK method of View one give the follwoing code.

method onactionclick .
        data:
          node_node_emp1                      type ref to
if_wd_context_node,
          elem_node_emp1                      type ref to
if_wd_context_element,
          stru_node_emp1                      type
if_view_one=>element_node_emp1 .
*       navigate from <CONTEXT> to <NODE_EMP1> via lead selection
        node_node_emp1 = wd_context->get_child_node( name =
if_view_one=>wdctx_node_emp1 ).

*       get element via lead selection
        elem_node_emp1 = node_node_emp1->get_element(  ).

*       get all declared attributes
        elem_node_emp1->get_static_attributes(
          importing
            static_attributes = stru_node_emp1 ).

data: l_ref_main_window type ref to ig_main_window .
l_ref_main_window =   wd_this->get_main_window_ctr( ).
  l_ref_main_window->fire_ob_window_plg(
    p_city =                           stru_node_emp1-city         
    p_name =                           stru_node_emp1-name
    p_state =                          stru_node_emp1-state

  ).


endmethod.

And we have to get those values in View two and we should set those values in the node of Custom controller. In Handle method of View two write the following code.

method handleib_view2 .

data: lv_name type string,
      lv_city type string,
      lv_state type string.

wdevent->get_data(
  exporting
    name   = 'P_NAME'
  importing
    value  = lv_name
       ).

wdevent->get_data(
  exporting
    name   = 'P_CITY'
  importing
    value  = lv_city
       ).

wdevent->get_data(
  exporting
    name   = 'P_STATE'
  importing
    value  = lv_state
       ).

  data:
    node_node_emp2                      type ref to if_wd_context_node,
    elem_node_emp2                      type ref to if_wd_context_element,
    stru_node_emp2                      type if_view_two=>element_node_emp2 ,
    item_ecity                          like stru_node_emp2-ecity.
* navigate from <CONTEXT> to <NODE_EMP2> via lead selection
  node_node_emp2 = wd_context->get_child_node( name = if_view_two=>wdctx_node_emp2 ).


node_node_emp2->set_attribute(
*    INDEX  = USE_LEAD_SELECTION
    value  = lv_name
    name   = 'ENAME'
       ).

node_node_emp2->set_attribute(
*    INDEX  = USE_LEAD_SELECTION
     VALUE  = lv_city
     name   = 'ECITY'
       ).

node_node_emp2->set_attribute(
*    INDEX  = USE_LEAD_SELECTION
     VALUE  = lv_state
     name   = 'ESTATE'
       ).
endmethod.

Save it. Create a WD application and Activate. And execute.

Output

If you want to pass the data through parameters of View use the following.

Create an outbound plug in View1 with parameters.

In Window - Outbound plug of view1 should be linked with Inbound plug of View 2.

Give the Following code in the Onaction click method of View1.

method ONACTIONCLICK .
   DATA:
      node_node_emp1                      TYPE REF TO
if_wd_context_node,
      elem_node_emp1                      TYPE REF TO
if_wd_context_element,
      stru_node_emp1                      TYPE
if_view_one=>element_node_emp1 .
*   navigate from <CONTEXT> to <NODE_EMP1> via lead selection
    node_node_emp1 = wd_context->get_child_node( name =
if_view_one=>wdctx_node_emp1 ).

*   get element via lead selection
    elem_node_emp1 = node_node_emp1->get_element(  ).

*   get all declared attributes
    elem_node_emp1->get_static_attributes(
      IMPORTING
        static_attributes = stru_node_emp1 ).


   wd_this->fire_ob_view1_plg(
     p_city =                            stru_node_emp1-city
     p_name =                            stru_node_emp1-name
     p_state =                           stru_node_emp1-state
   ).

endmethod.

In View Two handle method provide the follwoing code.

method handleib_view2 .
  data: name      type string,
        city      type string,
        state     type string.


  name = p_name.
  city = p_city.
  state = p_state.

  data:
    node_node_emp2                      type ref to if_wd_context_node,
    elem_node_emp2                      type ref to
if_wd_context_element,
    stru_node_emp2                      type
if_view_two=>element_node_emp2 ,
    item_ename                          like stru_node_emp2-ename,
  item_estate                         like stru_node_emp2-estate,
  item_ecity                          like stru_node_emp2-ecity.
* navigate from <CONTEXT> to <NODE_EMP2> via lead selection
  node_node_emp2 = wd_context->get_child_node( name =
if_view_two=>wdctx_node_emp2 ).

* get element via lead selection
  elem_node_emp2 = node_node_emp2->get_element(  ).

* get single attribute
  elem_node_emp2->set_attribute(
    exporting
      name =  `ENAME`
      value = name ).


*   navigate from <CONTEXT> to <NODE_EMP2> via lead selection
    node_node_emp2 = wd_context->get_child_node( name =
if_view_two=>wdctx_node_emp2 ).

*   get element via lead selection
    elem_node_emp2 = node_node_emp2->get_element(  ).

*   get single attribute
    elem_node_emp2->set_attribute(
      exporting
        name =  `ESTATE`
        value = state ).

* navigate from <CONTEXT> to <NODE_EMP2> via lead selection
  node_node_emp2 = wd_context->get_child_node( name =
if_view_two=>wdctx_node_emp2 ).

* get element via lead selection
  elem_node_emp2 = node_node_emp2->get_element(  ).

* get single attribute
  elem_node_emp2->set_attribute(
    exporting
      name =  `ECITY`
      value = city ).

endmethod.

  

Regards

Pradeep.

Former Member
0 Kudos

Hi Vishal

you can do this way...

Create an outbound plug in Window with the parameters. And set values into this parameter.

Create an Inbound plug in the view with the same parameters.

Now provide link between these two plugs. In method get the values from the parameters of Inbound plug and set those vales into the context node.

Thanks and Regards

Pradeep

Former Member
0 Kudos

Hi pradeep,

                 My next question is if i create out bound in window when it will fire or how to fire that plug to receive parameter in  the view

Former Member
0 Kudos

Hi Vishal,

Please follow the below link

http://scn.sap.com/thread/775706

Regards,

Sayan

Former Member
0 Kudos

Hi,

You can do it in two ways

First,

Declare some attributes in component controller level and read your parameters coming in your inbound plug of window and set them to attribute in component controller and accept it in view.

Second,

You can create a window outbound plug(standard plug) and navigate to your view with inbound plug and pass your values using plug parameters.

I would prefer the first one.