- 标准附件功能显示需要用户是 A类型 对话用户
本文介绍一个Public Class :CL_GOS_DOCUMENT_SERVICE
该类包含了创建附件,注释,URL,个人注释等方法,这些方法中都会涉及到对IS_OBJECT参数,该参数管理SAP中相关单据
以会计凭证为例:
业务对象:BKPF
Object key:bukrs && belnr && gjahr
由于这些方法都会有前台弹窗,可以重新封装里面代码调用,可以单独调用其中function
以创建注释为例,程序需要后台创建时需要跳过这些弹窗,附件无法读取本地地址,做后台上传涉及另外一个问题,不单独阐述
DATA:
objtype TYPE borident-objtype VALUE 'BKPF', "会计凭证
object TYPE borident,
rel_doc TYPE borident.
DATA:
folder_id TYPE sofdk,
document_id TYPE sofmk,
content TYPE soli,
lt_objhead TYPE STANDARD TABLE OF soli,
lt_objcont TYPE STANDARD TABLE OF soli,
l_obj_id TYPE soodk,
l_obj_data TYPE sood1.
object-objkey = |{ bukrs }{ belnr }{ gjahr }|.
object-objtype = objtype.
content-line = '注释文本内容'.
APPEND content TO lt_objcont.
CALL FUNCTION 'SO_FOLDER_ROOT_ID_GET'
EXPORTING
region = 'B'
IMPORTING
folder_id = folder_id
EXCEPTIONS
OTHERS = 1.
l_obj_data-objsns = 'O'.
l_obj_data-objla = sy-langu.
l_obj_data-objdes = 'TEXT_TITLE'. "注释标题
l_obj_data-file_ext = 'TXT'.
CALL FUNCTION 'SO_OBJECT_INSERT'
EXPORTING
folder_id = folder_id
object_type = 'RAW'
object_hd_change = l_obj_data
IMPORTING
object_id = l_obj_id
TABLES
objhead = lt_objhead
objcont = lt_objcont
EXCEPTIONS
active_user_not_exist = 35
folder_not_exist = 6
object_type_not_exist = 17
owner_not_exist = 22
parameter_error = 23
OTHERS = 1000.
IF sy-subrc = 0.
document_id-foltp = folder_id-foltp.
document_id-folyr = folder_id-folyr.
document_id-folno = folder_id-folno.
document_id-doctp = l_obj_id-objtp.
document_id-docyr = l_obj_id-objyr.
document_id-docno = l_obj_id-objno.
rel_doc-objkey = document_id.
rel_doc-objtype = 'MESSAGE'.
CALL FUNCTION 'BINARY_RELATION_CREATE'
EXPORTING
obj_rolea = object
obj_roleb = rel_doc
relationtype = 'NOTE'
EXCEPTIONS
OTHERS = 1.
IF sy-subrc = 0.
COMMIT WORK.
ENDIF.
ENDIF.