You are on page 1of 1

g_varheader-stdstyle

P_FORM->VARHEADER
stxftxt
report zz_test_replace_textsymbol.

* Global symbol
data: y type c length 5 value 'Lucky'.

start-of-selection.
perform start.

* ---
form start.

data: lt_text type tsftext,
ls_text type tline.

* Prepare example text
ls_text-tdline = 'Happy &X& &Y&'.
append ls_text to lt_text.

* Set individual symbol
call function 'SET_TEXTSYMBOL'
exporting
name = '&X&'
value = 'Go'.

* Set textsymbol for resolving globals
call function 'SET_TEXTSYMBOL_PROGRAM'
exporting
PROGRAM = sy-repid
event = 'OPEN_FORM'.

* Replace
data: lv_endline type i.
lv_endline = lines( lt_text ).
call function 'REPLACE_TEXTSYMBOL'
exporting
startline = 1
endline = lv_endline
tables
lines = lt_text.


read table lt_text into ls_text index 1.
write: / ls_text-tdline. " Prints 'Happy Go Lucky' "

endform. "start

You might also like