cancel
Showing results for 
Search instead for 
Did you mean: 

Reg clearing the variables in a view in SAP tutorial 3

former_member182465
Active Participant
0 Kudos

Hi Abapers,

I am just learning webdynpro. I have a doubt in tutorial 3. when i click on button 'New Search' in view no_filghts_view i am still able to see my previous values in the view FLIGHTLISTVIEW. i just want to blank those fields CITY and CITY1.

what is the best an efficient way to do that.

I had succesfully refreshed writing the code in the method WDDOBEFOREACTION. Is this method calling set_attribute is efficient or is there any other method to refresh all the fields in the context.

DATA lo_nd_destination_from_1 TYPE REF TO if_wd_context_node.

   DATA lo_el_destination_from_1 TYPE REF TO if_wd_context_element.
   DATA ls_destination_from_1 TYPE wd_this->element_destination_from_1.
   DATA lv_city TYPE wd_this->element_destination_from_1-city.

* navigate from <CONTEXT> to <DESTINATION_FROM_1> via lead selection
   lo_nd_destination_from_1 = wd_context->get_child_node( name = wd_this->wdctx_destination_from_1 ).
 
* get element via lead selection
   lo_el_destination_from_1 = lo_nd_destination_from_1->get_element( ).
 
* set single attribute
   lo_el_destination_from_1->set_attribute(
     name =  `CITY`
     value = lv_city ).

* navigate from <CONTEXT> to <DESTINATION_FROM_1> via lead selection
   lo_nd_destination_from_1 = wd_context->get_child_node( name = wd_this->wdctx_destination_to_1 ).
 
* get element via lead selection
   lo_el_destination_from_1 = lo_nd_destination_from_1->get_element( ).

* set single attribute
   lo_el_destination_from_1->set_attribute(
     name =  `CITY`
     value = lv_city ).

endmethod.

Please reply to those 2 questions.

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Invalidating the node is the best way to Reset the values.

Thanks,

Raju Bonagiri

Answers (3)

Answers (3)

former_member182465
Active Participant
0 Kudos

Thanks Guys....

former_member182465
Active Participant
0 Kudos

Thanks Kiran and Raju for your replies . correct me if i am wrong - if want to clear all elements at once under context use invalidating. If only some of the elements needs clearing then u need  to use set_attribute with blank value.

Former Member
0 Kudos

Hi abilsh ,

for  IF_WD_CONTEXT_ELEMENT there is a method SET_ATTRIBUTE_NULL . for which you can pass the attribute name and Clear the value . i mean using your reference of element    lo_el_destination_from_1->SET_ATTRIBUTE_NULL( name =  `CITY` ).

Thanks ,

Venkat Ratnam Naidu .

former_member184578
Active Contributor
0 Kudos

Hi,

Yes., What you understood is correct. If you want to clear all fields in the node use invalidate method, else you can use set_attribute method by passing empty value or set_attribute_null method to clear individual values.

Hope this helps u.,

Thanks

Kiran.

former_member184578
Active Contributor
0 Kudos

Hi,

Using set_attribute( ) method and passing empty value is one way., else you can use invalidate( ) method of node to clear all fields under that node.,

like

node->invalidate( ).

ex:

DATA lo_nd_destination_from_1 TYPE REF TO if_wd_context_node.

* navigate from <CONTEXT> to <DESTINATION_FROM_1> via lead selection

   lo_nd_destination_from_1 = wd_context->get_child_node( name = wd_this->wdctx_destination_from_1 ).

  lo_nd_destination_from_1->invalidate( ).

Hope this helps u.,

Thanks & Regards,

Kiran.