一. READ_TEXT函数读取长文本
本文以利润中心长文本读取及维护为例子,事务码:KE52
1.查看长文本参数,输入KE52
事务码
查看图片1
查看图片2
查看图片3
查看代码
CALL FUNCTION 'READ_TEXT'
EXPORTING
client = sy-mandt
id = 'LTXT'
language = 'E'
name = lv_name
object = 'CEPC'
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 <> 0.
* Implement suitable error handling here
ENDIF.
二. SAVE_TEXT函数维护长文本
该函数的使用方法较简单,ps:本人使用中发现该函数调用前需要先使用READ_TEXT
函数读取长文本对象,再进行调用,在SAVE_TEXT
函数调用后需要使用COMMIT_TEXT
进行提交,并执行COMMIT WORK AND WAIT.
否则维护长文本不生效,长文本对象表STXL
,STXH
无值,且使用READ_TEXT也读取不到内容。
查看代码
CALL FUNCTION 'SAVE_TEXT'
EXPORTING
client = sy-mandt
header = text_header
savemode_direct = 'X'
TABLES
lines = lt_line
EXCEPTIONS
id = 1
language = 2
name = 3
object = 4
OTHERS = 5.
CALL FUNCTION 'COMMIT_TEXT'
EXPORTING
object = 'CEPC'
name = lv_name
id = 'LTXT'
language = 'E'
savemode_direct = 'X'.
COMMIT WORK AND WAIT.