有时会在SO10中创建的长文本中加入占位符(text symbol),这些占位符可以通过函数SET_TEXTSYMBOL替换,
举例如下:
1, SO10创建长文本(long text)
输入text name,text id和language后点击创建按钮,
2, 调用代码
在SET_TEXTSYMBOL函数之前,要调用 INIT_TEXTSYMBOL进行初始化,在最后用函数REPLACE_TEXTSYMBOL指定替换的范围,也就是起始行和结束行。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
REPORT ztest_so10_symbol. DATA lv_name TYPE thead-tdname. DATA lv_langu LIKE sy-langu VALUE 'EN'. DATA lt_line TYPE STANDARD TABLE OF tline WITH HEADER LINE. DATA lv_count TYPE i. lv_name = 'ZTEST_TEXT_SYMBOL'. * read your text from SO10 CALL FUNCTION 'READ_TEXT' EXPORTING client = sy-mandt id = 'ST' language = lv_langu name = lv_name object = 'TEXT' TABLES lines = lt_line 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 EQ 0 . * initialize the text symbols CALL FUNCTION 'INIT_TEXTSYMBOL'. * set dynamic text symbol CALL FUNCTION 'SET_TEXTSYMBOL' EXPORTING name = '&l_symbol&' value = 'is a good SAP website' replace = 'X'. DESCRIBE TABLE lt_line LINES lv_count. * replace all text symbol in your long text CALL FUNCTION 'REPLACE_TEXTSYMBOL' EXPORTING endline = lv_count startline = 1 TABLES lines = lt_line. ENDIF. LOOP AT lt_line. WRITE:/ lt_line-tdline. ENDLOOP. |
3, 运行结果
可以看到占位符l_symbol被替换成'is a good SAP website’。
以上。
发表评论