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.获取交货单抬头、行项目长文本
1 FORM read_text USING u_name TYPE tdobname "OBJECT NAME,通常是订单ID&行项目号 2 u_tdid TYPE tdid "TEXT ID 3 u_tdobject TYPE tdobject "TEXT OBJECT 4 u_split TYPE string 5 CHANGING c_text TYPE string. 6 DATA: ls_stxh TYPE stxh, 7 ls_stxl TYPE stxl, 8 lt_lines TYPE TABLE OF tline WITH HEADER LINE. 9 IF u_tdobject = 'VBBK'. 10 "STXH 抬头项目文本 透明表 11 SELECT SINGLE * INTO ls_stxh FROM stxh WHERE tdobject = u_tdobject AND tdname = u_name AND tdid = u_tdid AND tdspras = sy-langu. 12 ELSEIF u_tdobject = 'VBBP'. 13 "STXL 明细项目文本 透明表 14 SELECT SINGLE * INTO ls_stxl FROM stxl WHERE tdobject = u_tdobject AND tdname = u_name AND tdid = u_tdid AND tdspras = sy-langu. 15 ELSE. 16 "sy-subrc = 0. 17 ENDIF. 18 IF sy-subrc = 0. 19 CALL FUNCTION 'READ_TEXT' 20 EXPORTING 21 * CLIENT = SY-MANDT 22 id = u_tdid 23 language = '1' 24 name = u_name 25 object = u_tdobject 26 * ARCHIVE_HANDLE = 0 27 * LOCAL_CAT = ' ' 28 * IMPORTING 29 * HEADER = 30 * OLD_LINE_COUNTER = 31 TABLES 32 lines = lt_lines[] 33 * EXCEPTIONS 34 * ID = 1 35 * LANGUAGE = 2 36 * NAME = 3 37 * NOT_FOUND = 4 38 * OBJECT = 5 39 * REFERENCE_CHECK = 6 40 * WRONG_ACCESS_TO_ARCHIVE = 7 41 * OTHERS = 8 42 . 43 IF sy-subrc = 0. 44 * Implement suitable error handling here 45 CLEAR c_text. 46 LOOP AT lt_lines. 47 CONCATENATE c_text lt_lines-tdline INTO c_text SEPARATED BY u_split. "解决回车事件 space 48 CLEAR lt_lines. 49 ENDLOOP. 50 CONDENSE c_text NO-GAPS. 51 ENDIF. 52 ENDIF. 53 ENDFORM. "READ_TEXT