Skip to Content
author's profile photo Former Member
Former Member

Its a very urgent task, can anyone please suggest!!

Hi Everyone,

I have a proposal for the find and find next in my screen. Need some help for you people.

In the screen i have around 3 grids, so in the standard toolbar if I press this find button it has to loop through the screen, loop through the grids then columns in the grid and find for the specified string.

So how do I achieve this. Any help will be great use to me.

Thanks in advance,

Prabs.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Posted on Sep 25, 2005 at 07:01 AM

    check out FM

    ALV_POPUP_TO_SEARCH2

    just pass the search string to C_STRING parameter .

    Regards

    Raja

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi

      You can use a routine like this:

      PARAMETER: p_search(80) LOWER CASE.

      DATA: length_string TYPE i.

      length_string = STRLEN( p_search ).

      DATA: itab1 LIKE vbrk OCCURS 0,

      itab2 LIKE vbrp OCCURS 0.

      DATA: gt_fieldcat1 TYPE lvc_t_fcat,

      gt_fieldcat2 TYPE lvc_t_fcat.

      DATA: rc_search TYPE sy-subrc,

      record TYPE sy-tabix,

      colunm TYPE alv_s_fcat-fieldname.

      START-OF-SELECTION.

      PERFORM search_in_table USING itab1[]

      gt_fieldcat1

      CHANGING rc_search

      record

      colunm.

      IF rc_search <> 0.

      PERFORM search_in_table USING itab2[]

      gt_fieldcat2

      CHANGING rc_search

      record

      colunm.

      ENDIF.

      FORM search_in_table U

      SING p_table TYPE table

      p_fieldcat TYPE lvc_t_fcat

      CHANGING rc TYPE sy-subrc

      tab_idx TYPE sy-tabix

      field TYPE alv_s_fcat-fieldname.

      DATA: lt_fieldcat TYPE alv_s_fcat.

      FIELD-SYMBOLS: <table> TYPE table,

      <wa_table> TYPE ANY,

      <field_value> TYPE ANY.

      DATA: string TYPE string.

      DATA: tabix TYPE sy-tabix.

      • Init

      rc = 4.

      tab_idx = 0.

      CLEAR field.

      ASSIGN p_table[] TO <table>.

      LOOP AT <table> ASSIGNING <wa_table>.

      tabix = sy-tabix.

      LOOP AT p_fieldcat INTO lt_fieldcat

      WHERE no_out = space.

      ASSIGN COMPONENT lt_fieldcat-fieldname

      OF STRUCTURE <wa_table>

      TO <field_value>.

      • Convert field in a string

      MOVE <field_value> TO string.

      • Check string:

      IF string CS p_search(length_string).

      field = lt_fieldcat-fieldname.

      tab_idx = tabix.

      rc = 0.

      EXIT.

      ENDIF.

      ENDLOOP.

      IF rc = 0. EXIT. ENDIF.

      ENDLOOP.

      ENDFORM. " SEARCH_IN_TABLE

      In your bar create an SEARCH icon, and when the user press it, a popup for searchin is displayed, you could use the FM ALV_POPUP_TO_SEARCH2 (as Raja has written).

      Max

  • author's profile photo Former Member
    Former Member
    Posted on Sep 25, 2005 at 03:44 PM

    In the PAI, when checking the OK code:

    case save_ok.
      when '%SC'.                         " find first time
        perform action_find_100_new.
      when '%SC+'.                        " repeat find
        if wfndstrng is initial.
          perform action_find_100_new.
        else.
          perform action_find_more_100_new.
        endif.
    endcase.
    form action_find_100_new.
      set screen 100.
      perform popup_find.     " display popup window for find
      read table zzdmectl-cols into zselcol
        with key selected = 'X'.
      if sy-subrc = 0.
        zzselcol = zselcol+21(30).
      else.
        clear zzselcol.
      endif.
      if sy-ucomm = 'CON400'.          " continue with find
        clear wfndfnd.                 " init string found
        loop at zzerd_line_item_data_0100. " search for the string
    *     from zztop_line.
          if zzselcol is initial.
            if zzerd_line_item_data_0100   cs wfndstrng.
              wzoutpposn = sy-tabix.
              zzdmectl-top_line = sy-tabix.
              wfndfnd = '1'.                  " string found
              exit.
            endif.
          else.
            perform assign_field.
            write <field> to char_field.
            if char_field cs wfndstrng.
              wzoutpposn = sy-tabix.
              zzdmectl-top_line = sy-tabix.
              wfndfnd = '1'.                  " string found
              exit.
            endif.
          endif.
        endloop.
        if wfndfnd is initial.
          message s000 with wfndstrng .
        endif.
      endif.
    endform.                    " ACTION_FIND_100_NEW
    

    If you seelct a column, the code will only search the seelcted column; otherwise, it will search the table control.

    Form action_find_more_100_new is similar to action_find_100_new, and form popup_find simply calls the screen where you enter the search string.

    Rob

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.