Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

how to fetch details from a table when any input field is given

hi friends,

I have a issue where the user gives any input in the input fields provided and clicked on search it should fetch all the details regarding to the input provided

the fields in my form are

lifnr-vendor id

name1- name of the company

ort01-city

pstlz-postal code

mcod1-search term

any one provide me the code how to fetch details for the input given

here by im sending the code which i used for fetching the details when the vendor id is provided please provide me the code to how to take any field as input and fetch the details regarding to the input

method onactionsearch13 .

data: node_input type ref to if_wd_context_node,
        node_output type ref to if_wd_context_node,
        node type ref to if_wd_context_element,
        itab type table of lfa1,
*        itab2 type table of lfa1,
        vendor type lfa1-lifnr,
        name type lfa1-name1,
        wa_tab type  lfa1.
  node_input = wd_context->get_child_node( name = 'INPUT' ).
  node = node_input->get_element( ).
  node_output = wd_context->get_child_node( name = 'OUTPUT').
  node_input->get_attribute( exporting name = 'lifnr' importing value = vendor ).
  select * from lfa1 into table itab 
    where lifnr = vendor.
    node_output->bind_table( itab ).
    select * from lfa1 into table itab where name1 = 'name'.
    node_output->bind_table( itab2 ).
*    wd_this->fire_output_view_plg( ).
      data:
*        node_input                          TYPE REF TO if_wd_context_node,
        elem_input                          type ref to if_wd_context_element,
        stru_input                          type if_input_view=>element_input ,
        item_name1                          like stru_input-name1.
*     navigate from <CONTEXT> to <INPUT> via lead selection
      node_input = wd_context->get_child_node( name = if_input_view=>wdctx_input ).

*     get element via lead selection
      elem_input = node_input->get_element(  ).
      read table itab into wa_tab index 1.
      move wa_tab to stru_input.
*     get single attribute
        select * from lfa1 into table itab where name1 = 'name'.
      elem_input->set_attribute(
        exporting
          name =  `NAME1`

          value = stru_input-name1 ).
  data:
*    node_input                          TYPE REF TO if_wd_context_node,
*    elem_input                          TYPE REF TO if_wd_context_element,
*    stru_input                          TYPE if_input_view=>element_input ,
    item_ort01                          like stru_input-ort01.
* navigate from <CONTEXT> to <INPUT> via lead selection
  node_input = wd_context->get_child_node( name = if_input_view=>wdctx_input ).

* get element via lead selection
  elem_input = node_input->get_element(  ).
* read table itab into wa_tab index 2.
* get single attribute
  elem_input->set_attribute(
    exporting
      name =  `ORT01`

      value = stru_input-ort01 ) .
        data:

          item_pstlz                          like stru_input-pstlz.
*       navigate from <CONTEXT> to <INPUT> via lead selection
        node_input = wd_context->get_child_node( name = if_input_view=>wdctx_input ).

*       get element via lead selection
        elem_input = node_input->get_element(  ).

*       get single attribute
        elem_input->set_attribute(
          exporting
            name =  `PSTLZ`

            value = stru_input-pstlz ).
data:

          item_mcod1                          like stru_input-pstlz.
*       navigate from <CONTEXT> to <INPUT> via lead selection
        node_input = wd_context->get_child_node( name = if_input_view=>wdctx_input ).

*       get element via lead selection
        elem_input = node_input->get_element(  ).

*       get single attribute
        elem_input->set_attribute(
          exporting
            name =  `MCOD1`

            value = stru_input-mcod1 ).
endmethod.

thanks & Regards

Madhu

Not what you were looking for? View more on this topic or Ask a question