cancel
Showing results for 
Search instead for 
Did you mean: 

How to refresh ALV Output?

Former Member
0 Kudos

Hi,

I am having selection field sales orderno and submit button, and alv control. when i select any sales orderno and click on submit button , i get relevant data in ALV . But again when i select new salesorderno in input field and click on submit button, it should refreshed ALV Output. But it shows me previous data only. I have output node calle op_node having no. of fields. when i click on submit button ,i filled internal table which i bind out node op_node . This table gets modified when i click on submit , it binds to op_node as well bt data in alv doesnt modified. so how to refresh ALV?

Thanks,

Saurin Shah

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

I sort out myself, using set_data method of ALV interface controller.

Thanks,

Saurin Shah

Former Member
0 Kudos

Hi Saurin,

Try using 'Invalidate' method to refresh the node at the beginning of code in submit button

lo_nd_op_node->invalidate( ).

Regards,

Deepthi

Former Member
0 Kudos

hi,

where to use invalidate method for node op_node. because as u said if i keep in submit action method, after declaring node op_node if i invalidate through this method and then if i bind internal table to this node , it doesnt show me any output. I give u my code...where to write plz let me know...

method ONACTIONSUBMIT .

" get input from input node attribute VBELN.........

DATA LO_ND_INPNODE TYPE REF TO IF_WD_CONTEXT_NODE.

DATA LO_EL_INPNODE TYPE REF TO IF_WD_CONTEXT_ELEMENT.

DATA LS_INPNODE TYPE WD_THIS->ELEMENT_INPNODE.

DATA LV_VBELN LIKE LS_INPNODE-VBELN.

  • navigate from <CONTEXT> to <INPNODE> via lead selection

LO_ND_INPNODE = WD_CONTEXT->GET_CHILD_NODE( NAME = WD_THIS->WDCTX_INPNODE ).

  • get element via lead selection

LO_EL_INPNODE = LO_ND_INPNODE->GET_ELEMENT( ).

  • get single attribute

LO_EL_INPNODE->GET_ATTRIBUTE(

EXPORTING

NAME = `VBELN`

IMPORTING

VALUE = LV_VBELN ).

" Now to get data from vbak and keep into internal table and than bind to node opnode.

DATA LO_ND_OPNODE TYPE REF TO IF_WD_CONTEXT_NODE.

DATA LO_EL_OPNODE TYPE REF TO IF_WD_CONTEXT_ELEMENT.

DATA LS_OPNODE TYPE WD_THIS->ELEMENT_OPNODE.

DATA: LT_OPNODE TYPE WD_THIS->ELEMENTS_OPNODE.

  • navigate from <CONTEXT> to <OPNODE> via lead selection

LO_ND_OPNODE = WD_CONTEXT->GET_CHILD_NODE( NAME = WD_THIS->WDCTX_OPNODE ).

CALL METHOD LO_ND_OPNODE->INVALIDATE

.

Select * from VBAK INTO CORRESPONDING FIELDS OF TABLE LT_OPNODE

WHERE VBELN = LV_VBELN .

CALL METHOD LO_ND_OPNODE->BIND_TABLE

EXPORTING

NEW_ITEMS = LT_OPNODE

  • SET_INITIAL_ELEMENTS = ABAP_TRUE

  • INDEX =

.

endmethod.

Former Member
0 Kudos

Hi,

Hope you can statically bound the DATA node of the ALV but not by using the SET_DATA method.

One more thing, you have to code for BIND TABLE in the HANDLER method for inbound plug in the 2nd view or

Your retreival of data should be in the EXECUTE button, clear the table and bind the table again to node.

You can invalidate the node when you press previous button from 2nd to 1st view.

Donot write the code in the WDDOINIT or in WDDOMODIFYVIEW.

DATA LO_ND_OPNODE TYPE REF TO IF_WD_CONTEXT_NODE.

DATA LO_EL_OPNODE TYPE REF TO IF_WD_CONTEXT_ELEMENT.

DATA LS_OPNODE TYPE WD_THIS->ELEMENT_OPNODE.

DATA: LT_OPNODE TYPE WD_THIS->ELEMENTS_OPNODE.

REFRESH: lt_opnode.

  • navigate from <CONTEXT> to <OPNODE> via lead selection

LO_ND_OPNODE = WD_CONTEXT->GET_CHILD_NODE( NAME = WD_THIS->WDCTX_OPNODE ).

CALL METHOD LO_ND_OPNODE->INVALIDATE "Dont write here

.

Select * from VBAK INTO CORRESPONDING FIELDS OF TABLE LT_OPNODE

WHERE VBELN = LV_VBELN .

CALL METHOD LO_ND_OPNODE->BIND_TABLE

EXPORTING

NEW_ITEMS = LT_OPNODE

  • SET_INITIAL_ELEMENTS = ABAP_TRUE

  • INDEX =

.

Regards,

Lekha.

Former Member
0 Kudos

Hi Lekha,

I have input field ,button and alv output on same view, so i wrote invalidate method in action method...i dont have 2 views...

so where to write..Plz solve my issue...

Thanks

Saurin Shah

Former Member
0 Kudos

Your code for fetching the data, invalidating the node and rebinding the node should be in the OnAction method of your submit button Regards, Radhika.

Former Member
0 Kudos

Hi,

In the OnAction event for the SUBMIT button, you should do the coding.

First refresh the table and get the table data and then bind.

Try checking the INVALIDATE by commenting and uncommecting.....

Regards,

Lekha.

Former Member
0 Kudos

Hi Lekha,

If i dont write Invalidating method , than as per selection, i get output in ALV first time only . But when i change my seleciton criteria, it wont change the contents of ALV Output....

if i uncomment it , it doesnt show me any output even first time. Because first time when i click on submit button , it invalidate the node and then i bind with internal table...

Thanks,

Saurin Shah

Former Member
0 Kudos

Hi,

Are you evertime creating the node or are you storing the node in globally and binding the table to this global node.

Have you refreshed the table content or not. REFRESH statement.

if lo_nd_opnode is not initial
CALL METHOD LO_ND_OPNODE->INVALIDATE .
or
clear lo_nd_opnode
endif.


* navigate from <CONTEXT> to <OPNODE> via lead selection
LO_ND_OPNODE = WD_CONTEXT->GET_CHILD_NODE( NAME = WD_THIS->WDCTX_OPNODE ).

Regards,

Lekha.

Former Member
0 Kudos

Hi Lekha,

I am refering node everytime , when i click on submit as shown below .. and then i bind internal table to node opnode. i checked everytime LO_ND_OPNODE is initial so INVALIDATE never gets called......

DATA LO_ND_OPNODE TYPE REF TO IF_WD_CONTEXT_NODE.

DATA LO_EL_OPNODE TYPE REF TO IF_WD_CONTEXT_ELEMENT.

DATA LS_OPNODE TYPE WD_THIS->ELEMENT_OPNODE.

DATA: LT_OPNODE TYPE WD_THIS->ELEMENTS_OPNODE.

if LO_ND_OPNODE is NOT INITIAL.

CALL METHOD LO_ND_OPNODE->INVALIDATE.

refresh LT_OPNODE.

endif.

  • navigate from <CONTEXT> to <OPNODE> via lead selection

LO_ND_OPNODE = WD_CONTEXT->GET_CHILD_NODE( NAME = WD_THIS->WDCTX_OPNODE ).

Select * from VBAK INTO CORRESPONDING FIELDS OF TABLE LT_OPNODE

WHERE VBELN = LV_VBELN .

CALL METHOD LO_ND_OPNODE->BIND_TABLE

EXPORTING

NEW_ITEMS = LT_OPNODE

  • SET_INITIAL_ELEMENTS = ABAP_TRUE

  • INDEX =

.

Thanks,

Saurin Shah

Former Member
0 Kudos

Hi,

After getting the node reference you keep that check.

In the debugging, check for the ndoe content and also the table content.

As you said that when Invalalidate is used 1st time you are able toget any data.

Check this step in debugging by commenting and uncommenting it.

SET_INITIAL_ELEMENTS as abap_false. "Try checking this as well.

Regards,

Lekha.

Former Member
0 Kudos

Hi,

Is your issue resolved?

Regards,

Lekha.

Former Member
0 Kudos

hi Lekha,

not yet..Will u try for me please , take input field , button and alv on same view and our requirement is when u change input , alv data should get refreshed. take example for sales order no. and get some details from vbak in alv....

Thanks,

Saurin Shah

Former Member
0 Kudos

Hi,

Ok...I shall try it out.

Regards,

Lekha.

Former Member
0 Kudos

Hi, I have written the following code in the onAction Method for fetching the Sales Orders from Material number. It is working fine.

DATA: cn_input          TYPE REF TO if_wd_context_node.
  DATA: l_matnr           TYPE mara-matnr.
  DATA: l_view_controller TYPE REF TO if_wd_view_controller.
  DATA: lt_msgs           TYPE cl_wd_dynamic_tool=>t_check_result_message_tab.
  DATA: lt_alv            TYPE if_v_main=>elements_cn_alv,
        ls_alv            TYPE if_v_main=>element_cn_alv.
  DATA: l_error           TYPE boolean.

* get element via lead selection
  DATA lo_el_context TYPE REF TO if_wd_context_element.
  lo_el_context = wd_context->get_element(  ).

* Get 'CN_ALV' from context node
  DATA: cn_alv TYPE REF TO if_wd_context_node.
  cn_alv = wd_context->get_child_node( 'CN_ALV' ).

* Get 'CN_INPUT' from context node
  cn_input = wd_context->get_child_node( 'CN_INPUT' ).

* Get attribute CA_MATNR
  cn_input->get_attribute( EXPORTING name  = 'CA_MATNR'
                          IMPORTING value = l_matnr    ).

* Get view controller
  l_view_controller = wd_this->wd_get_api( ).

* Check for mandatory attribute
  cl_wd_dynamic_tool=>check_mandatory_attr_on_view(
  EXPORTING view_controller  = l_view_controller
            display_messages = abap_true
  IMPORTING messages         = lt_msgs
  ).

  IF lt_msgs IS INITIAL.

* Validate Material Number.
    DATA: matnr TYPE mara-matnr.

    SELECT SINGLE matnr
      FROM mara
      INTO matnr
     WHERE matnr = l_matnr.

    IF NOT matnr IS INITIAL.
* Get Sales Orders
      SELECT vbeln
             posnr
             zmeng
             arktx
        FROM vbap
        INTO TABLE lt_alv
       WHERE matnr = l_matnr.


      IF NOT lt_alv[] IS INITIAL.
       
* Initialize AL
        initialize_alv( ).
* Bind Data to ALv
        cn_alv->bind_table( lt_alv ).

        CLEAR l_error.
      ELSE.
        l_error = abap_true.
* display Status message
        wd_comp_controller->success_msg( 'No Data Exists' ).
      ENDIF.

    ELSE.
      l_error = abap_true.
* Display Error Message.
      wd_comp_controller->error_msg( 'Material does not Exist' ).

    ENDIF.

    IF l_error = abap_true.
* Clear ALV table
      cn_alv->invalidate( ).
      CLEAR l_error.
    ENDIF.

  ENDIF.
Regards, Radhika.

Former Member
0 Kudos

Also check this tutorial for ALV and check if you have followed all the steps as mentioned. [https://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/3439404a-0801-0010-dda5-8c14514d690d&overridelayout=true] Regards, Radhika.

Former Member
0 Kudos

Hi,

I have not used any refresh or invalidate statement, my ALV is getting refreshed. Here is the code -

If you still find as not resolved, then delete the current alv and create it again and also map the DATA node of ALV again to the

VBAK node of yours. This should work fine.

On Submit button action -

DATA lo_cmp_usage TYPE REF TO if_wd_component_usage.

  lo_cmp_usage =   wd_this->wd_cpuse_alv( ).
  IF lo_cmp_usage->has_active_component( ) IS INITIAL.
    lo_cmp_usage->create_component( ).
  ENDIF.

  DATA lo_interfacecontroller TYPE REF TO iwci_salv_wd_table .
  lo_interfacecontroller =   wd_this->wd_cpifc_alv( ).

  DATA lv_value TYPE REF TO cl_salv_wd_config_table.
  lv_value = lo_interfacecontroller->get_model(
  ).

  DATA lo_nd_node TYPE REF TO if_wd_context_node.

  DATA lo_el_node TYPE REF TO if_wd_context_element.
  DATA ls_node TYPE wd_this->element_node.
  DATA lv_vbeln TYPE wd_this->element_node-vbeln.

* navigate from <CONTEXT> to <NODE> via lead selection
  lo_nd_node = wd_context->get_child_node( name = wd_this->wdctx_node ).

* @TODO handle non existant child
* IF lo_nd_node IS INITIAL.
* ENDIF.

* get element via lead selection
  lo_el_node = lo_nd_node->get_element( ).
* @TODO handle not set lead selection
  IF lo_el_node IS INITIAL.
  ENDIF.

* get single attribute
  lo_el_node->get_attribute(
    EXPORTING
      name =  `VBELN`
    IMPORTING
      value = lv_vbeln ).


  DATA lo_nd_vbak TYPE REF TO if_wd_context_node.

  DATA lt_vbak TYPE wd_this->elements_vbak.

* navigate from <CONTEXT> to <VBAK> via lead selection
  lo_nd_vbak = wd_context->get_child_node( name = wd_this->wdctx_vbak ).


  SELECT * FROM vbak INTO CORRESPONDING FIELDS OF TABLE lt_vbak
  WHERE vbeln = lv_vbeln.

* @TODO handle non existant child
 IF lo_nd_vbak IS not INITIAL.
 lo_nd_vbak->bind_table( lt_vbak ).
 ENDIF.

Regards,

Lekha.

Former Member
0 Kudos

Hi,

Please write the context updation in domodify method and check. Please let me know if you are facing the problem again.

Thanks,

Sanjeev

Former Member
0 Kudos

hi ,

when i click on submit, in action method, i update internal table which i binds to output table node . And that node is extended in DATA node in component usgage.

thanks

saurin shah