report ysearch.
************************************************************************
*
* Program   :   Ysearchl
* Authors   :   Chris Harrop  (chris.harrop@bigfoot.com)
* Date      :   March 1999
* Purpose   :   Searches all Y and Z layout sets for a given string
*
************************************************************************
*
* Maintenance History
*
* Date          Nov 2007
* Author      Sheila Titchener  (www.iconet-ltd.co.uk)
* Purpose    Allow for std texts to be searched
*                                           [  Object = TEXT   ID = ST]
*******************************************************************************

tables: stxl.

parameters:
  string(128).
parameters: p_object type tdobject default 'FORM',
            p_id type tdid default 'TXT'.
data: begin of tlinetab occurs 0.
        include structure tline.
data: end of tlinetab,
subrc like sy-subrc.

*SELECT TDNAME FROM STXL INTO (STXL-TDNAME)
*    WHERE TDOBJECT = 'FORM' AND ( TDNAME LIKE 'Y%' OR TDNAME LIKE 'Z%' )
*    AND TDID = 'TXT'.
start-of-selection.

  select tdname from stxl into (stxl-tdname)
      where tdobject = p_object and ( tdname like 'Y%' or tdname like 'Z%' )
      and tdid = p_id.


    perform display_status_text using stxl-tdname.

    refresh tlinetab.
    perform get_text_table
            tables tlinetab
*         USING 'FORM' 'TXT' STXL-TDNAME
            using p_object p_id stxl-tdname
            changing subrc.
    loop at tlinetab.
      if tlinetab-tdline cs string.
        write : / stxl-tdname, tlinetab-tdline.
      endif.
    endloop.
  endselect.


* Display a message on the status bar
form display_status_text using value(text) type c.
  call function 'SAPGUI_PROGRESS_INDICATOR'
    exporting
      text = text.
endform.                    "DISPLAY_STATUS_TEXT
*
* Get the long texts for the object
*
form get_text_table tables tlinetab
                    using value(tdobject) like thead-tdobject
                          value(id) like thead-tdid
                          value(tdname) like thead-tdname
                    changing subrc like sy-subrc.

  data: begin of xthead occurs 0.
          include structure thead.
  data: end of xthead.

  data: eintraege like sy-tfill.

  data xtdname like thead-tdname.
  refresh xthead.
  clear xtdname.
  xtdname    = tdname.

  call function 'SELECT_TEXT'
    exporting
      id         = id
      language   = sy-langu
      name       = tdname
      object     = tdobject
    importing
      entries    = eintraege
    tables
      selections = xthead.

  refresh tlinetab.

  call function 'READ_TEXT'
    exporting
      id              = id
      language        = sy-langu
      name            = tdname
      object          = tdobject
    importing
      header          = xthead
    tables
      lines           = tlinetab
    exceptions
      id              = 01
      language        = 02
      name            = 03
      not_found       = 04
      object          = 05
      reference_check = 06.
  subrc = sy-subrc.
endform.                               " FILL_ITEM_TEXT