Skip to Content
0
May 06, 2021 at 09:37 AM

FM TEXT_SYMBOL_REPLACE refuses to replace &EKKO-AEDAT&

1027 Views Last edit May 06, 2021 at 09:40 AM 2 rev

Hi, I've a simple requirement to replace some text symbols in a standard text with actual data. The std text is like this:

My Code is in a BAdI implementation class, is like this:

    DATA: lv_textsym TYPE string,
          ekko       TYPE ekko.

    CALL FUNCTION 'ME_EKKO_SINGLE_READ'
      EXPORTING
        pi_ebeln         = CONV ebeln( is_nast-objky )                " Purchasing Document Number
      IMPORTING
        po_ekko          = ekko                 " Purchasing Document Header
      EXCEPTIONS
        no_records_found = 1
        OTHERS           = 2.

    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
        WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      RETURN.
    ENDIF.

    CHECK sy-subrc EQ 0.
    SELECT SINGLE name1 FROM  adrc AS a
                        INNER JOIN t001 AS t
                                ON t~adrnr = a~addrnumber
                               AND t~bukrs  = @ekko-bukrs
           INTO @DATA(x_t001_name1).

    CALL FUNCTION 'INIT_TEXTSYMBOL'.

    LOOP AT lt_tlines INTO DATA(ls_line).
      FIND ALL OCCURRENCES OF '&' IN ls_line-tdline RESULTS DATA(lt_result).
      LOOP AT lt_result INTO DATA(ls_result).
        CHECK sy-tabix MOD 2 = 1.
        CALL FUNCTION 'GET_TEXTSYMBOL'
          EXPORTING
            line         = ls_line-tdline
            start_offset = ls_result-offset
          IMPORTING
            name         = lv_textsym.

        IF lv_textsym IS NOT INITIAL.
          ASSIGN (lv_textsym) TO FIELD-SYMBOL(<fs_textsym>).
          lv_textsym := |&{ lv_textsym }&|.

          IF <fs_textsym> IS ASSIGNED.
            CALL FUNCTION 'SET_TEXTSYMBOL'
              EXPORTING
                header       = ls_thead
                name         = lv_textsym
                value        = <fs_textsym>.
          ENDIF.
        ENDIF.
      ENDLOOP.
    ENDLOOP.

    CALL FUNCTION 'TEXT_SYMBOL_REPLACE'
      EXPORTING
        header = ls_thead
      TABLES
        lines  = lt_tlines.

    CALL FUNCTION 'FORMAT_TEXTLINES'
      EXPORTING
        formatwidth = 128
      TABLES
        lines       = lt_tlines
      EXCEPTIONS
        bound_error = 1
        OTHERS      = 2.

    IF sy-subrc <> 0.
*     MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*       WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.

LT_TLINES and LS_THEAD are filled with READ_TEXT as usual.

In debugging, I see the values correctly available:

But after the TEXT_SYMBOL_REPLACE, it comes out blank:

Any ideas, what could be going wrong here?