长文本相关表
STXH 文本文件抬头表
STXL 文本文件行表
TTXID 有效文本IDs
TTXIT 文本 ID 的文本
TTXOB 有效文本目标
TTXOT 短文本在文本目标上
也可以根据程序:RSTXTC3 查看长文本
创建长文本:SE75
查看文本参数:
写入、创建函数:SAVE_TEXT、CREATE_TEXT
删除函数:DELETE_TEXT
读取函数:READ_TEXT
*读取PP模块的CO03生产订单的text 长文本:
CALL FUNCTION 'READ_TEXT'
EXPORTING
client = sy-mandt
id = 'KOPF'
language = sy-langu
name = ls_stxl-tdname
object = 'AUFK'
* ARCHIVE_HANDLE = 0
* LOCAL_CAT = ' '
* IMPORTING
* HEADER =
* OLD_LINE_COUNTER =
TABLES
lines = lt_tline
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.
LOOP AT lt_tline ASSIGNING FIELD-SYMBOL(<fs_tline>).
gs_heard-text = <fs_tline>-tdline.
ENDLOOP.
ENDIF.
SAVE_TEXT注意点:(自建长文本不需要X)
函数读取长文本多条循环会使得效率变低!
解决办法:(这样会使效率大大提升)
*长文本
TYPES:
BEGIN OF ty_stxl_raw, "压缩的文本
clustr TYPE stxl-clustr,
clustd TYPE stxl-clustd,
END OF ty_stxl_raw,
BEGIN OF ty_text, "解压的文本
tdobject TYPE stxl-tdobject,
tdid TYPE stxl-tdid,
tdname TYPE stxl-tdname,
tdline TYPE string,
END OF ty_text,
BEGIN OF ty_stxl, "直接查询stxl的数据格式
tdobject TYPE stxl-tdobject,
tdid TYPE stxl-tdid,
tdname TYPE stxl-tdname,
clustr TYPE stxl-clustr,
clustd TYPE stxl-clustd,
END OF ty_stxl.
DATA:lt_stxl TYPE TABLE OF ty_stxl WITH HEADER LINE,
lt_stxl_raw TYPE TABLE OF ty_stxl_raw WITH HEADER LINE,
ls_stxl_raw TYPE ty_stxl_raw,
lt_tline TYPE STANDARD TABLE OF tline WITH HEADER LINE,
lt_text TYPE TABLE OF ty_text,
ls_text TYPE ty_text.
* 长文本处理
DATA(lt_out) = gt_out.
SORT lt_out BY ebeln ASCENDING.
DELETE ADJACENT DUPLICATES FROM lt_out COMPARING ebeln.
SELECT
stxl~tdobject,
stxl~tdid,
stxl~tdname,
stxl~clustr,
stxl~clustd
FROM stxl
INNER JOIN @lt_out AS l ON l~ebeln EQ stxl~tdname
WHERE stxl~tdobject = 'EKKO'
AND stxl~tdid = 'F01'
AND stxl~tdspras = @sy-langu
INTO CORRESPONDING FIELDS OF TABLE @lt_stxl.
CLEAR:lt_out[]."后续使用不到就清空
"解压文本
LOOP AT lt_stxl.
CLEAR:lt_stxl_raw,lt_stxl_raw[], lt_tline,lt_tline[].
lt_stxl_raw-clustr = lt_stxl-clustr.
lt_stxl_raw-clustd = lt_stxl-clustd.
APPEND lt_stxl_raw.
IMPORT tline = lt_tline FROM INTERNAL TABLE lt_stxl_raw.
LOOP AT lt_tline.
ls_text-tdline = ls_text-tdline && lt_tline-tdline.
ENDLOOP.
ls_text-tdobject = lt_stxl-tdobject.
ls_text-tdid = lt_stxl-tdid.
ls_text-tdname = lt_stxl-tdname.
IF ls_text-tdline NE ''.
INSERT ls_text INTO TABLE lt_text.
ENDIF.
CLEAR ls_text.
ENDLOOP.
SORT lt_text BY tdobject tdid tdname ."排序为二分法做准备
DELETE ADJACENT DUPLICATES FROM lt_text COMPARING tdobject tdid tdname.
"取值销售订单抬头长文本
READ TABLE lt_text INTO ls_text WITH KEY tdobject = 'EKKO' tdid = 'F01' tdname = <fs_out>-ebeln BINARY SEARCH.
IF sy-subrc = 0.
<fs_out>-longtexth = ls_text-tdline.
ENDIF.
相关大顾的链接:
ABAP ‘read text‘ 在循环中取值长文本太慢了,来试试效率更高的方法_寒武青锋的博客-CSDN博客