cancel
Showing results for 
Search instead for 
Did you mean: 

how to clear data in table

former_member209118
Participant
0 Kudos

Hi,

I have 3 context nodes.one for sales order number (from VBAK,field vbeln) when I entered sales order number, the data will display in the item table fields (VBAP). I have drop down in item level if I selected drop down value the values will trigger in another table.

when I enter wrong sales order number I want to clear data in both the tables, but when i entered the wrong sales order number the data is cleared in the first table and it still displaying in the second table.

So what i has to do to clear the data in both the tables at the time?

Thanks,

Ashok.

Accepted Solutions (1)

Accepted Solutions (1)

former_member196157
Active Participant
0 Kudos

hiii,

    lo_nd_items = wd_context->get_child_node( name = wd_this->wdctx_so_item ).
     lo_el_context = lo_nd_items->get_element( ).
     lo_nd_items->invalidate( ).

OR

refresh: wd_this->lt_items.
   wd_comp_controller->lr_nd_elent->bind_table( new_items = wd_this->lt_items set_initial_elements = abap_true ).


OR


  lo_nd_it_final = wd_context->get_child_node( name = wd_this->wdctx_it_final ).
   clear lt_it_final[].
   lo_nd_it_final->bind_table( new_items = lt_it_final set_initial_elements = abap_true ).

former_member209118
Participant
0 Kudos

Hi Kedari,

Thanks for your mail. I tried above code but the data in 3rd C.N is not clearing. I created two events to get data in two tables. in 2nd context node I selected VBAP in that when I selected value in POSAR I'm populating values in another table. when I selected sales order number in 1st C.N the data is clearing in 2nd C.N  but not in 3rd C.N.

Thanks,

Ashok.

former_member196157
Active Participant
0 Kudos

hiii,

at what point ur third context is called for that point only u clear the data

former_member222068
Active Participant
0 Kudos

Hi Ashok,

You have to invalidate ( ) both the nodes.

Thanks & Regards,

Sankar Gelivi

former_member209118
Participant
0 Kudos

I created two action.

in action one when i selected sales order number i need to populate the values in another context node which is table. At the same time if there is no data i need to dispaly error message and also clear the old data in the 2nd C.N (table) for that purpose i written following code and its working properly.

DATA lo_nd_so_header TYPE REF TO if_wd_context_node.

         DATA lo_el_so_header TYPE REF TO if_wd_context_element.

         DATA ls_so_header TYPE wd_this->Element_so_header.

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

         lo_nd_so_header = wd_context->get_child_node( name = wd_this->wdctx_so_header ).

*

*       get element via lead selection

         lo_el_so_header = lo_nd_so_header->get_element( ).

*       @TODO handle not set lead selection

         IF lo_el_so_header IS INITIAL.

         ENDIF.

*       get all declared attributes

         lo_el_so_header->get_static_attributes(

           IMPORTING

             static_attributes = ls_so_header ).

   DATA lo_nd_node1 TYPE REF TO if_wd_context_node.

   DATA lo_el_node1 TYPE REF TO if_wd_context_element.

   DATA ls_node1 TYPE wd_this->Element_node1.

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

   lo_nd_node1 = wd_context->get_child_node( name = wd_this->wdctx_node1 ).

* get element via lead selection

   lo_el_node1 = lo_nd_node1->get_element( ).

* @TODO handle not set lead selection

   IF lo_el_node1 IS INITIAL.

   ENDIF.

select SINGLE * from vbak into CORRESPONDING FIELDS OF ls_node1 where vbeln = ls_so_header-vbeln.

* set all declared attributes

   lo_el_node1->set_static_attributes(

      static_attributes = ls_node1 ).

   DATA lo_nd_so_item TYPE REF TO if_wd_context_node.

   DATA lt_so_item TYPE wd_this->Elements_so_item.

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

   lo_nd_so_item = wd_context->get_child_node( name = wd_this->wdctx_so_item ).

select * from vbap INTO CORRESPONDING FIELDS OF TABLE lt_so_item where vbeln = ls_so_header-vbeln.

   lo_nd_so_item->bind_table( new_items = lt_so_item set_initial_elements = abap_true ).

* get message manager

data lo_api_controller     type ref to if_wd_controller.

data lo_message_manager    type ref to if_wd_message_manager.

if lt_so_item is INITIAL.

lo_api_controller ?= wd_This->Wd_Get_Api( ).

CALL METHOD lo_api_controller->GET_MESSAGE_MANAGER

   RECEIVING

     MESSAGE_MANAGER = lo_message_manager

     .

* report message

CALL METHOD lo_message_manager->RAISE_ERROR_MESSAGE

   EXPORTING

     MESSAGE_TEXT  = 'no records found'.

endif.

if i selected drop down value in POSAR attribute (which is in 2nd C.N) i'm populating values in another C.N,but I'm unable to clear the dataif second C.N is empty. I written the following code in second action.


DATA lo_nd_so_item TYPE REF TO if_wd_context_node.

     DATA lo_el_so_item TYPE REF TO if_wd_context_element.

     DATA ls_so_item TYPE wd_this->Element_so_item.

     DATA lv_posar TYPE wd_this->Element_so_item-posar.

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

     lo_nd_so_item = wd_context->get_child_node( name = wd_this->wdctx_so_item ).

*   get element via lead selection

     lo_el_so_item = lo_nd_so_item->get_element( ).

*   alternative access  via index

*   lo_el_so_item = lo_nd_so_item->get_element( index = 1 ).

*   @TODO handle not set lead selection

     IF lo_el_so_item IS INITIAL.

     ENDIF.

*   get single attribute

     lo_el_so_item->get_attribute(

       EXPORTING

         name `POSAR`

       IMPORTING

         value = lv_posar ).

   DATA lo_nd_item_details TYPE REF TO if_wd_context_node.

   DATA lt_item_details TYPE wd_this->Elements_item_details.

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

   lo_nd_item_details = wd_context->get_child_node( name = wd_this->wdctx_item_details ).

** @TODO compute values

** e.g. call a model function

*

SELECT * FROM VBAP INTO CORRESPONDING FIELDS OF TABLE LT_ITEM_DETAILS WHERE POSAR = LV_POSAR.

   lo_nd_item_details->bind_table( new_items = lt_item_details set_initial_elements = abap_true ).


Can you please let me know how to do and where to do and what is code I have to write?

former_member209118
Participant
0 Kudos

Hi sankar,

I tried its not working

Thanks,

Ashok

Former Member
0 Kudos

After each select query check the sy-subrc value, if sy-subrc = 0 means query sucessfully executed and data came otherwise clear the lt data..

former_member209118
Participant
0 Kudos

Hi Chandra,

I have to display header text according to sales order that I selected  in another C.N. For that I created one C.N and attribute which is type string. I know by using READ_TEXT F.M we can achieve that but my question is what parameters do I need to pass there and where can I get those values(like object,id name etc).

can you please provide code that can help me more.

Thanks,

Ashok.

Former Member

Answers (2)

Answers (2)

former_member210804
Active Participant
0 Kudos

Hi ,

Use invalidate( ) method to clear both the nodes . This method refresh the node's data.

Best regards,

Rao    

Former Member
0 Kudos

Hi Ashok,

Validate Sales Order Number and if it is wrong number,get the reference of both table nodes ( which will be of type if_wd_context_node )and call the method invalidate .

Regards,

Ravikiran.k