cancel
Showing results for 
Search instead for 
Did you mean: 

table in webdynpro

Former Member
0 Kudos

hi, i have displayed a table in webdynpro in that the first column is a listbox. when i select a value it should display the corresponding details in the other columns.

Accepted Solutions (1)

Accepted Solutions (1)

uday_gubbala2
Active Contributor
0 Kudos

Hi Siva,

Let me try explain you this with an example. Suppose I am displaying the MATNR values within a dropdown as my first table column. Now when I select a MATNR value I want the corresponding information to be fetched from MAKT table & filled in the other columns of the table. I guess that this is your intended requirement.

I have 2 context nodes MAKT & NODE.

MAKT:


Cardinality: 0..n
Selection: 0..1
Initialization Lead Selection: Check box is checked
Singleton: Check box is checked
Supply Function: SUPPLY_DATA ( I am creating a supply function)

Now under the same node I have 2 attributes SPRAS & MAKTX from MAKT

NODE:

Cardinality: 0..n
Selection: 0..1
Initialization Lead Selection: Check box is checked
Singleton: Check box is NOT checked
Supply Function: SUPPLY_DATA ( I am creating a supply function)

Now under the same node I have 2 attributes MATNR (from MARA) & KEY (of type STRING)

Answers (6)

Answers (6)

uday_gubbala2
Active Contributor
0 Kudos

Just try follow the steps which I have written & the coding which I have presented you. Now on execution the first column would have a dropdown with MATNR values in it. The other columns of the table would be just blank as of now. Now when you select a value from the dropdown its onSelect event gets triggered and this in turn would lead to execution of our event handler method ONACTIONON_MATNR_SELECT. This method would fetch the SPRAS & MAKTX values for the corresponding MATNR & populate it in the respective columns.

Regards,

Uday

uday_gubbala2
Active Contributor
0 Kudos

Below is my coding inside the dropdown's event handler ONACTIONON_MATNR_SELECT

METHOD onactionon_matnr_select .
  DATA: lr_element TYPE REF TO if_wd_context_element,
        lv_index_table TYPE i,
        lv_index TYPE i,
        lt_node TYPE wd_this->elements_node,
        wa_node TYPE wd_this->element_node,
        wd_node TYPE REF TO if_wd_context_node,
        wa_makt TYPE wd_this->element_makt.

*** Get row number from which dropdown value was selected
  lr_element = wdevent->get_context_element( 'CONTEXT_ELEMENT' ).
  lv_index_table = lr_element->get_index( ).
  wd_node = wd_context->get_child_node( 'MAKT' ).
  wd_node->set_lead_selection_index( index = lv_index_table ).

*** Get the index of value within dropdown which is selected
  lv_index = wdevent->get_int( name = 'INDEX' ).

*** Fetch all the dropdown values into an internal table
  wd_node = wd_context->path_get_node( 'MAKT.NODE' ).

  CALL METHOD wd_node->get_static_attributes_table
    EXPORTING
      from  = 1
      to    = 2147483647
    IMPORTING
      table = lt_node.
*** Obtain the value selected in the dropdown by the user using the index obtained
  READ TABLE lt_node INTO wa_node INDEX lv_index.
  wd_node->set_attribute( EXPORTING name  = 'MATNR'
                                    value = wa_node-matnr ).

**** Using conversion exit routine for MATNR so that SELECT statement would work properly
  CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
    EXPORTING
      input        = wa_node-matnr
    IMPORTING
      output       = wa_node-matnr
    EXCEPTIONS
      length_error = 1
      OTHERS       = 2.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

*** Obtain language & description fields from MAKT for same value as selected in the dropdown
  SELECT SINGLE spras
                maktx FROM makt INTO wa_makt WHERE matnr = wa_node-matnr.
*** Fill the fetched values into the corresponding textfields of table
  wd_node = wd_context->get_child_node( 'MAKT' ).

  CALL METHOD wd_node->set_static_attributes
    EXPORTING
      index             = lv_index_table
      static_attributes = wa_makt.
ENDMETHOD.

uday_gubbala2
Active Contributor
0 Kudos

I am displaying 3 columns in the table: MATNR, SPRAS & MAKTX. I have created the first column as a DropDownByIndex & have bound its "texts" property to the MATNR (attribute under node NODE) i.e., MAIN.MAKT.NODE.MATNR. I have also created an event handler (ON_MATNR_SELECT) for the action "onSelect" of the dropdown. The other 2 columns SPRAS & MAKTX are being displayed as TextViews and are bound to the corresponding SPRAS & MAKTX attributes which we had created under the node MAKT.

Below is the coding within my supply function method SUPPLY_DATA

METHOD supply_data .
  DATA: lt_data TYPE wd_this->elements_node,
        wa_data TYPE wd_this->element_node,
        lt_matnr TYPE TABLE OF matnr,
        ls_makt TYPE wd_this->element_makt,
        lt_makt TYPE wd_this->elements_makt,
        wd_node TYPE REF TO if_wd_context_node,
        lr_element TYPE REF TO if_wd_context_element.

  SELECT DISTINCT matnr UP TO 20 ROWS FROM mara INTO TABLE lt_matnr.
  SORT lt_matnr.

*** This would create 20 blank rows in the table with only the dropdown filled with MATNR values
  DO 20 TIMES.
    APPEND ls_makt TO lt_makt.
  ENDDO.

  node->bind_table( new_items            =  lt_makt
                    set_initial_elements = abap_true ).

  LOOP AT lt_makt INTO ls_makt.
    LOOP AT lt_matnr INTO wa_data-matnr.
*** Calling conversion exit routine to remove unnecessary paddings
      CALL FUNCTION 'CONVERSION_EXIT_MATN1_OUTPUT'
        EXPORTING
          input  = wa_data-matnr
        IMPORTING
          output = wa_data-matnr.
      wa_data-key = sy-index.
      CONDENSE wa_data-key.
      APPEND wa_data TO lt_data.
      CLEAR wa_data.
    ENDLOOP.

    lr_element = node->get_element( sy-tabix ).
    wd_node = lr_element->get_child_node( 'NODE' ).
    wd_node->bind_table( lt_data ).
  ENDLOOP.
ENDMETHOD.

Former Member
0 Kudos

In on select action method of the drop down list's property write the code to refresh the table based on the selected value.

Former Member
0 Kudos

Hi,

Check Standard application view DROPDOWNBYIDX in side application WDR_TEST_EVENTS.

Regards

Vishnu Gupta

Former Member
0 Kudos

Hi Siva,

Implement the Onselect event of the table or OnAction event of the column where there is a listbox.

Regards,

Runal