Homelab, Linux, JS & ABAP (~˘▾˘)~
 

[ABAP] Read SO10 Standard Text with Textsymbol replacement

METHOD read_text.

    DATA: lines   TYPE TABLE OF tline,
          header  TYPE THEAD,
          lt_text TYPE soli_tab.

    CALL FUNCTION 'READ_TEXT'
      EXPORTING
        id                      = 'ST'
        language                = sy-langu
        name                    = "Textname"
        object                  = 'TEXT'
      IMPORTING
        header                  = header
      TABLES
        lines                   = lines
      EXCEPTIONS
        id                      = 1
        language                = 2
        name                    = 3
        not_found               = 4
        object                  = 5
        reference_check         = 6
        wrong_access_to_archive = 7
        OTHERS                  = 8.
    IF sy-subrc <> 0.
    ENDIF.

   CALL FUNCTION 'INIT_TEXTSYMBOL'.

   CALL FUNCTION 'SET_TEXTSYMBOL'
      EXPORTING
        name    = '&MATNR&'
        value   = '00000001'
        replace = 'X'.

    CALL FUNCTION 'REPLACE_TEXTSYMBOL'
      EXPORTING
        endline   = lines( lines )
        startline = 1
      TABLES
        lines     = lines.

    CALL FUNCTION 'CONVERT_ITF_TO_STREAM_TEXT'
      EXPORTING
        language    = sy-langu
      TABLES
        itf_text    = lines
        text_stream = lt_text.

  ENDMETHOD.