cancel
Showing results for 
Search instead for 
Did you mean: 

how to modify a view..

Former Member
0 Kudos

hi all,

In my view i am creating a new value and appending it to a table. i need this value to come in my dropdown. So i think i need to modify my view and perform the same actions in WDINIT.

can anyone help me out in this.. please give me some code samples as that will be really helpful since i am new to WD.

thanks in advance,

jithin

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi uday,

CALL METHOD lo_nd_input->invalidate

.

what are the parameters that we need to pass in this method.. i am getting a null reference error

uday_gubbala2
Active Contributor
0 Kudos

Hello Jithin,

INVALIDATE is a method of IF_WD_CONTEXT_NODE. So you should first obtain a reference of the context node that you want to invalidate and then call this method using that reference. Suppose you have a node named SFLIGHT in your context node then you first get the reference of that node in to a reference variable like shown below.

data: lr_node type ref to if_wd_context_node.

lr_node = wd_context->get_child_node( name = 'SFLIGHT' ).

You then call the invalidate method using the above reference to invalidate the data present in the node SFLIGHT.

lr_node->invalidate( ).

Its pretty simple. I hope that you understood what I meant to explain.

Regards,

Uday

Answers (5)

Answers (5)

Former Member
0 Kudos

hi Uday,

thanks, its working fine now..

regards,

jithin

Former Member
0 Kudos

Hi Uday,

i am trying with the method which u suggested..

can u plaese tell me what is modify view used for..?

uday_gubbala2
Active Contributor
0 Kudos

Hi Jithin,

wddomodifyview( ) is a method that allows you to programmatically manipulate the layout of the view. This event can be used to define the UI dynamically. This is the only method that allows you to access the UI element hierarchy. An interface parameter by name VIEW (of type IF_WD_VIEW) is automatically passed on to this method by the system. You can use this parameter to get the reference of any UI element present in the view.

However you should keep it in mind to go for dynamic UI creation/modification only when it isn't possible to achieve the same functionality at design time as it does put a lot of load on the system. For more information regarding dynamic UI creation/modification you can refer to the excellent blog series by Thomas Szuecs.

[Blog 1|] , [Blog 2|] , [Blog 3|]

Regards,

Uday

Former Member
0 Kudos

hi,

say i have a feild matnr binded to the dropdown.i have values 1000,1001,1002 coming under the dropdown.

i have an option to create new matnr(in the same view), where i create a new material say 1003.

this 1003 which i create is not coming in the drop down...

But if i close the application and execute it once again then this value comes.So i thought i neeed to modify my view.

hope my requirement is clear now..so plz share your ideas..

uday_gubbala2
Active Contributor
0 Kudos

Hi Jithin,

I guess that you are creating a new material using an option which you have in your view but you aren't updating the same in the internal table that you are using for binding to your context node. So the system does only display the data that it has in the context. When you restart the application the system does fetch even your new MATNR value from the database and bind it to the context node. Its why you can get to see it in that case.

You can try proceed as follows to get the desired results. Fill the context node in which you have your MATNR values using a supply function. When you create a new MATNR value in your view just invalidate the contents of the context node by using the INVALIDATE method of IF_WD_CONTEXT_NODE. The system would then automatically trigger the supply function and you would now even have your newly created MATNR value fetched & displayed as per your requirement. Hope that it helps.

Regards,

Uday

Former Member
0 Kudos

Hi Jitin,

You already have drop down in your view? if you have then no need to modify youe view.Get the entered value and then append this value to context node which you already binded to drop down.

Former Member
0 Kudos

Hi,

when ever you bind the Text of the DropdownByIndex UI element then you can see the values in the dropdown. Check out the WDR_TEST_UI_EVENTS adn WDR_TEST_UI_ELEMENTS.

Create a context node in the view with the similar structure of the table and populate the table using a Select statement and bind this table to the Context node. as a result you can see the values of the table in the context node. Now, to the TEXT property of the DropdownbyIndex UI element bind it to the context node. Now you can see the values in the drop down. If you want to modify the view write the code in the WDDOMODIFYVIEW where using the View instance you can change the context node with the new values and you can see the same in the drop down.

To have your new values to be added to the table then use the <<MODIFY TABLE from Workarea>> and now bind thie to the context node to have the new values being appended

Please check out this link for appending values to the table -

Regards

Lekha

Former Member
0 Kudos

hi lekha

i am able to append the values to the table.i am using DDLB by key.

when i create a new value and save it,it is adding in the table.But it is not coming the dropdown.

If i close the application and excecute it again the the value comes. So i think i need to modify the view after saving my value.

is that fine?

please tell me how to use the moify view method..

uday_gubbala2
Active Contributor
0 Kudos

Hi Jithin,

Am not sure as you shouldnt have to refresh the view for getting this new value displayed in the dropdown. I have tried adding a new value, "Create new" in a DropDownByKey and it does turn up without my having to refresh anything. Below is the coding that I have put in to the WDDOINIT method. I have bound the selectedKey property of my dropdown to the context attribute PRICE. (type S_PRICE) This attribute is under the context node 'D'. (This node has a cardinality of 1..1 & selection of 0..1 & the lead selection is initialized)

METHOD wddoinit .
  DATA: lv TYPE REF TO if_wd_context_node,
        info TYPE REF TO if_wd_context_node_info,
        wa TYPE wdr_context_attr_value,
        it TYPE TABLE OF wdr_context_attr_value.
 
  DATA: lt_price TYPE if_main=>elements_d,
        wa_price TYPE if_main=>element_d.
 
  SELECT distinct price FROM sflight INTO TABLE lt_price. " Just for an example am selecting DISTINCT price values from the table
 
  LOOP AT lt_price INTO wa_price.
    wa-value = wa_price-price.
    wa-text = wa_price-price.
    APPEND wa TO it.
  ENDLOOP.
 
  lv = wd_context->get_child_node( name = 'D' ).
  info = lv->get_node_info( ).
  info->set_attribute_value_set( name      = 'PRICE'
                                 value_set = it ).
ENDMETHOD.