生产订单,销售订单都有长文本信息,并没有存进相应的表里而是要通过函数进行读取和写入。其id号和name等信息保存到stxl和stxh表中。以下英文部分摘自:https://wiki.sdn.sap.com/wiki/display/Snippets/How+to+save+and+retreive+Text+objects。
ext objects are the container for containing long texts in Sap Systems.
Basically Long texts cannot be kept in a db Table column because of limitation of 255 characters.
For storing & retrieving text objects, following function modules exist in sap.
1) Read_Text - To retrieve Long Text from Text Objects.
2) Save_Text-- To save Long Text into Text Objects.
Now have a look on below code snippet to know how to use them:- FORM get_comments
USING p_Devobjid TYPE y0bs_Dev-objid.
DATA: e_header TYPE thead.
DATA: i_tline TYPE STANDARD TABLE OF tline.
e_header-tdobject = 'ZCHD_OBJ'.
e_header-tdid = 'Y0B1'.
e_header-tdspras = sy-langu.
e_header-tdlinesize = 72.
CONCATENATE p_Devobjid e_header-tdid INTO e_header-tdname.
CALL FUNCTION 'READ_TEXT'
EXPORTING
client = sy-mandt
id = e_header-tdid
language = e_header-tdspras
name = e_header-tdname
object = 'ZCHD_OBJ'
TABLES
lines = i_tline
EXCEPTIONS
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
wrong_access_to_archive = 7
OTHERS = 8.
Along with the text object id and its language, Text Name is also need to be passed.
Basically this Text Name is uniquely identifies dev comments against each dev objects.
For e.g. - Two Dev object id 1 and 2 have their unique dev comments ,But having same Text Object ZCHD_OBJ and same Text ID -Y0B1.
That's why to uniquely identifies the dev comments for dev obj 1 and 2, Text names are dynamically created .For e.g. in above code snippet objid & Text id combine together to identify comments for Dev comments for each Object.
Now let's see how these long texts can be retrieved through save_text function module.
FORM save_comments.
DATA: e_header TYPE thead,
i_header TYPE STANDARD TABLE OF thead,
w_tline TYPE tline,
i_tline TYPE STANDARD TABLE OF tline WITH HEADER LINE.
e_header-tdobject = 'ZCHD_OBJ'.
e_header-tdid = 'Y0B1'.
e_header-tdspras = sy-langu.
e_header-tdlinesize = 72.
CONCATENATE y0bs_Dev-objid e_header-tdid INTO e_header-tdname.
APPEND 'DevComments for Obj 1" to i_tline-tdline.
CALL FUNCTION 'SAVE_TEXT'
EXPORTING
client = sy-mandt
header = e_header
savemode_direct = 'X'
TABLES
lines = i_tline
EXCEPTIONS
id = 1
language = 2
name = 3
object = 4
OTHERS = 5.
IF sy-subrc <> 0.
ENDIF.
ENDFORM.
其中的name字段并不是生产订单号,而是有‘100000’一个前缀。如果是自己创建一个控件文本框相关字段信息就是Z字打头了。只要是文本控件的都可以用以上函数来读取,和保存。