在SAP ERP系统中,物料的基本描述可存储40个字符,见下图:
但长文本信息如何从系统中读取呢?
在SAP ABAP开发中,读取物料主数据(Material Master Data)中的基本视图(Basic View)里的长文本信息通常涉及到对长文本(Long Text)的处理。长文本在SAP系统中是以特殊的方式存储的,它们被分割成多个部分,存储在数据库表STXL(Long Text Lines)和STXH(Long Text Headers)中。
在SAP ABAP开发中,要读取物料主数据中基本视图里的长文本信息,你可以使用函数模块 READ_TEXT。以下是一个简单的例子,演示如何使用该函数模块来读取物料主数据的长文本信息:
Report YTEST_XF_READ_TEXT .
DATA: lt_lines TYPE TABLE OF tline,ls_line type tline ,lv_object TYPE tdobject ,lv_id TYPE tdid ,lv_language TYPE tdspras ,lv_name TYPE TDOBNAME,lv_text TYPE tdline.
PARAMETERS: p_matnr TYPE matnr OBLIGATORY.
START-OF-SELECTION." 设置读取长文本的对象类型(Object Type)lv_object = 'MATERIAL'." 设置读取长文本的 IDlv_id = 'GRUN'." 设置语言lv_language = 'EN'." 设置物料号lv_name = p_matnr." 调用函数模块 READ_TEXT 读取长文本信息CALL FUNCTION 'READ_TEXT'EXPORTINGid = lv_idlanguage = lv_languagename = lv_nameobject = lv_objectTABLESlines = lt_linesEXCEPTIONSid = 1language = 2name = 3not_found = 4object = 5reference_check = 6wrong_access_to_archive = 7OTHERS = 8.IF sy-subrc <> 0.WRITE: / 'Error reading text:', sy-msgid, sy-msgty, sy-msgno, sy-msgty.ELSE.LOOP AT lt_lines into ls_line.lv_text = ls_line-tdline.WRITE: / lv_text.ENDLOOP.ENDIF.