cancel
Showing results for 
Search instead for 
Did you mean: 

Insertion of data into the Table

Former Member
0 Kudos

HI All,

I want to insert the data into the table which is inthe same view.

My scenario is

Iam having two input fields (Firstname and lastname)

After entering the inputs and click on the submit button

the data should insert in the table which is in the same view.

if possible please provide some code.

Thanks

Mahalakshmi.K

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Mahalakshmi kothuri ,

On the submit event of the submit button read the values of both the input fields using code wizard. then using the values read ..

using the Function module or coding get the value you need to be populated on the table based on the input fields.

now populate the iternal table containing values to the node thats mapped to the table in the screen using bind table method.

Regards

Sarath

Former Member
0 Kudos

Hi,

Thanks for ur quick response.

I have done what u have told but I am not getting the data into the table.

Can you please provide the code for reading the data of input fields into the table.

Mahalakshmi.K

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Mahalakshmi

Use the following code snippet

method ONACTIONSUBMIT .
  TYPES : BEGIN OF t_table,
          firstname TYPE string,
          lastname TYPE string,
          END OF t_table.
  data : lt_table TYPE TABLE OF t_table,
         wa_table TYPE t_table.
  DATA lo_el_context TYPE REF TO if_wd_context_element.
  DATA ls_context TYPE wd_this->element_context.
  DATA lv_firstname LIKE ls_context-firstname.
  DATA lv_lastname LIKE ls_context-lastname.
*   get element via lead selection
  lo_el_context = wd_context->get_element(  ).
*   get single attribute
  lo_el_context->get_attribute(
    EXPORTING
      name =  `FIRSTNAME`
    IMPORTING
      value = lv_firstname ).
  lo_el_context->get_attribute(
    EXPORTING
      name =  `LASTNAME`
    IMPORTING
      value = lv_lastname ).

  wa_table-firstname = lv_firstname.
  wa_table-lastname = lv_lastname.
  APPEND wa_table to lt_table.

  DATA lo_nd_table TYPE REF TO if_wd_context_node.
  DATA lo_el_table TYPE REF TO if_wd_context_element.
  DATA ls_table TYPE wd_this->element_table.
* navigate from <CONTEXT> to <TABLE> via lead selection
  lo_nd_table = wd_context->get_child_node( name = wd_this->wdctx_table ).
  lo_nd_table->bind_table( lt_table ).
endmethod.

Hope this helps U

Regards

Tamilselvan.K