Skip to Content

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    Nov 30, 2010 at 10:22 AM

    Hi Madhu,

    You can do the following:

    First check if the input is given in all the input fields. and you can have different select statements based on the passed input values.

    Say you have given input for vendor id and company name but other fields are not given.

    Then you can do the query using only the vendor id and company name in the where condition.

    You can use if else blocks also if you want.

    I am not sure if this way is a good way to do or not. But you will get the required output.

    Hope this helps!

    REgards,

    Srilatha

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi,

      we have done something like this using seltab.

      One inputfield, user can enter anything same like in google like

      name:ab*,dob:1972

      write a conversion method to parse this input to seltab like

      clear ls_seltab.

      ls_seltab-sign = 'I'.

      if lv_value cs '*'.

      li_lng = sy-fdpos.

      ls_seltab-option = 'BT'.

      else.

      ls_seltab-option = 'EQ'.

      ls_seltab-low = lv_value.

      endif.

      use your seltab to retrieve data from the table.

      In anyway.. you can search resources in this direction to build your solution.

  • avatar image
    Former Member
    Nov 30, 2010 at 09:29 PM

    Hi,

    I would change the screen logic to require from the user either:

    a) vendor ID (direct hit by primary key) or

    b) any combination of name, city, zip and search term. ( don't mix a with b )

    Then instead of wriitng select statements for any possible combination, read the input node and pass the attributes to high level function(s) to do the search (LFA1_SINGLE_READ, BAPI_VENDOR_FIND or similar. search for LFA1 or VENDOR functions, you'll find something

    Regards,

    George

    Add comment
    10|10000 characters needed characters exceeded