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.

[ABAP] Read smartform textmodule

Oldschool:

    DATA(ls_languages) = VALUE ssfrlang( langu1 = sy-langu ).
    DATA(lt_text_stream) = VALUE soli_tab( ).

    CALL FUNCTION 'SSFRT_READ_TEXTMODULE'
      EXPORTING
        i_textmodule       = 'Z_SMARTFORM_TEXT'
        i_languages        = ls_languages
      IMPORTING
        o_text             = lt_text
      EXCEPTIONS
        error              = 1
        language_not_found = 2
        OTHERS             = 3.

    IF lt_text IS NOT INITIAL.

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

    ENDIF.

Newschool:

    TRY.
        DATA(lr_form) = NEW cl_ssf_fb_smart_form( ).
        lr_form->load( im_formname = 'ZECOS_GM_ERROR' ).

        DATA(ls_varheader) = lr_form->varheader[ 1 ].
        DATA(lr_node) = CAST cl_ssf_fb_node( ls_varheader-pagetree ).
        DATA(lr_text) = CAST cl_ssf_fb_text_item( lr_node->obj ).

        LOOP AT lr_text->text INTO DATA(ls_text).
          WRITE:/ ls_text-tdline.
        ENDLOOP.

      CATCH cx_ssf_fb.
      CATCH cx_sy_itab_line_not_found.
    ENDTRY.