SAP中所有的项目文本都存在以下两张数据表中:
1. STXH 抬头项目文本 透明表
2. STXL 明细项目文本 透明表
长文本读取方法
首先在STXH和STXL中根据OBJECT NAME, TEXT ID,TEXT OBJECT查找到需要的文本对象,
然后通过READ_TEXT / READ_TEXT_INLINE函数来读取文本内容。
以读取交货单文本为例:
1.获取OBJECT NAME, TEXT ID,TEXT OBJECT
2.获取交货单抬头、行项目长文本
FORM read_text USING u_name TYPE tdobname "OBJECT NAME,通常是订单ID&行项目号
u_tdid TYPE tdid "TEXT ID
u_tdobject TYPE tdobject "TEXT OBJECT
u_split TYPE string
CHANGING c_text TYPE string.
DATA: ls_stxh TYPE stxh,
ls_stxl TYPE stxl,
lt_lines TYPE TABLE OF tline WITH HEADER LINE.
IF u_tdobject = 'VBBK'.
"STXH 抬头项目文本 透明表
SELECT SINGLE * INTO ls_stxh FROM stxh WHERE tdobject = u_tdobject AND tdname = u_name AND tdid = u_tdid AND tdspras = sy-langu.
ELSEIF u_tdobject = 'VBBP'.
"STXL 明细项目文本 透明表
SELECT SINGLE * INTO ls_stxl FROM stxl WHERE tdobject = u_tdobject AND tdname = u_name AND tdid = u_tdid AND tdspras = sy-langu.
ELSE.
"sy-subrc = 0.
ENDIF.
IF sy-subrc = 0.
CALL FUNCTION 'READ_TEXT'
EXPORTING
* CLIENT = SY-MANDT
id = u_tdid
language = '1'
name = u_name
object = u_tdobject
* ARCHIVE_HANDLE = 0
* LOCAL_CAT = ' '
* IMPORTING
* HEADER =
* OLD_LINE_COUNTER =
TABLES
lines = lt_lines[]
* 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
CLEAR c_text.
LOOP AT lt_lines.
CONCATENATE c_text lt_lines-tdline INTO c_text SEPARATED BY u_split. "解决回车事件 space
CLEAR lt_lines.
ENDLOOP.
CONDENSE c_text NO-GAPS.
ENDIF.
ENDIF.
ENDFORM. "READ_TEXT
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/19639.html