Find SO10 Text Use in SAPScripts

    1  DATA: p_so10name TYPE c LENGTH 40.
    2
    3  * p_so10name = SO10 text
    4  p_so10name = 'your_so10_text'.
    5
    6  DATA: lt_stxh TYPE TABLE OF stxh,
    7        ls_stxh TYPE stxh,
    8        lt_lines TYPE TABLE OF tline,
    9        ls_line TYPE tline,
   10        lv_found TYPE abap_bool VALUE abap_false.
   11
   12  " Select SAPscript forms from STXH (object = 'TEXT', text ID = 'ST')
   13  SELECT * FROM stxh INTO TABLE lt_stxh
   14    WHERE tdobject = 'FORM' AND tdid = 'TXT'.
   15
   16    IF sy-subrc = 0.
   17          WRITE: / 'Select found:', p_so10name.
   18    ENDIF.
   19
   20  LOOP AT lt_stxh INTO ls_stxh.
   21    CLEAR lt_lines.
   22
   23    " Read SAPscript text lines using READ_TEXT
   24    CALL FUNCTION 'READ_TEXT'
   25      EXPORTING
   26        id       = ls_stxh-tdid
   27        language = ls_stxh-tdspras
   28        name     = ls_stxh-tdname
   29        object   = ls_stxh-tdobject
   30      TABLES
   31        lines    = lt_lines
   32      EXCEPTIONS
   33        not_found = 1
   34        OTHERS    = 2.
   35
   36    IF sy-subrc = 0.
   37  *    WRITE: / 'sy-subrc:', sy-subrc, ls_stxh-tdid, ls_stxh-tdspras,
   38  *                                    ls_stxh-tdname,ls_stxh-tdobject.
   39
   40      LOOP AT lt_lines INTO ls_line.
   41        " Check if SO10 text name appears in the line
   42        IF ls_line-tdline CS p_so10name.
   43          WRITE: / 'SO10 Text:', p_so10name,
   44                    'found in SAPscript form:', ls_stxh-tdname,
   45                    'Language:', ls_stxh-tdspras.
   46          lv_found = abap_true.
   47          EXIT.
   48        ENDIF.
   49      ENDLOOP.
   50    ENDIF.
   51  ENDLOOP.
   52
   53  IF lv_found = abap_false.
   54    WRITE: / 'SO10 Text', p_so10name, 'not found in any SAPscript form'.
   55  ENDIF.
   56

See Also
Unicode Checks

Get help for your ABAP problems
Do you have a ABAP Question?

ABAP Books
ABAP Certification, BAPI, Java, Web Programming, Smart Forms, Sapscripts Reference Books

More ABAP Tips

Main Index
SAP Basis, ABAP Programming and Other IMG Stuff

All the site contents are Copyright © www.erpgreat.com and the content authors. All rights reserved.
All product names are trademarks of their respective companies.  The site www.erpgreat.com is in no way affiliated with SAP AG. 
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk. 
 The content on this site may not be reproduced or redistributed without the express written permission of 
www.erpgreat.com or the content authors.