READ TEXT – Code for mass extract

READ TEXT – Code for mass extract

When needed to perform standart text mass retrieve, you can use the following code :


* compressed text data with text name
  TYPES: BEGIN OF ts_stxl,
           tdname TYPE stxl-tdname,
           clustr TYPE stxl-clustr,
           clustd TYPE stxl-clustd,
         END OF ts_stxl.
  DATA:  li_stxl TYPE STANDARD TABLE OF ts_stxl.
  FIELD-SYMBOLS: <stxl> TYPE ts_stxl.

* compressed text data without text name
  TYPES: BEGIN OF ts_stxl_raw,
           clustr TYPE stxl-clustr,
           clustd TYPE stxl-clustd,
         END OF ts_stxl_raw.
  DATA:  li_stxl_raw TYPE STANDARD TABLE OF ts_stxl_raw.
  DATA:  ls_stxl_raw TYPE ts_stxl_raw.

* decompressed text
  DATA:  li_tline TYPE STANDARD TABLE OF tline.
  FIELD-SYMBOLS: <tline> TYPE tline.
  DATA : ls_thead TYPE thead,
          li_thead TYPE TABLE OF thead.
  DATA : ls_text TYPE ts_text.

  IF NOT li_thead[] IS INITIAL.
** select compressed text lines in blocks of 3000 (adjustable)
    SELECT tdname clustr clustd
           INTO TABLE li_stxl
           FROM stxl
           FOR ALL ENTRIES IN li_thead
           WHERE relid    = 'TX'          "standard text
             AND tdobject = 'PMS'
             AND tdname   = li_thead-tdname
             AND tdid     = 'LTXT'
             AND tdspras  = sy-langu.

    LOOP AT li_stxl ASSIGNING <stxl>.
*   decompress text
      CLEAR: li_stxl_raw[], li_tline[].
      ls_stxl_raw-clustr = <stxl>-clustr.
      ls_stxl_raw-clustd = <stxl>-clustd.
      APPEND ls_stxl_raw TO li_stxl_raw.
      IMPORT tline = li_tline FROM INTERNAL TABLE li_stxl_raw.

      LOOP AT li_tline ASSIGNING <tline>.

*      -----------------------------------------------
*      use the text related to object the way you want
*      -----------------------------------------------

      ENDLOOP.

    ENDLOOP.
    FREE li_stxl.
  ENDIF. 

 

Content in debug of LI_TLINE (for one text).

Content in debug

About the author

fjourneau administrator

Hi, I'm Florian Journeau, SAP ABAP R3 Freelance, based in Toulouse, France. You want to know more about me, have a look on my CV : cv.fjourneau.net.

Leave a Reply