一、可以对采购申请挂载附件,通过两种方式:
1、使用GOS,直接挂附件,GOS这个名词比较唬人,其实就是在PR界面上使用 创建附件,注释等.这样挂载的附件只能挂到某个PR上,不能对行项目挂附件。
2、使用DMS,可以细到对行项目挂附件。(没用过,目前没空研究)
二、使用第一个方式管理附件的话,有的报表程序可能需要下载PR对应的附件到前台目录(前台指定目录和文件名),或者下载到某个local PC目录,或者写文件到application server路径下。
首先要知道的是这种方式下相关的透明表:
SRGBTBREL 文档链接,字段INSTID_A、INSTID_B
SOOD SAPoffice: 对象定义,字段OBJTP 文档类别代码, OBJYR 对象: 来自 ID 的年份, OBJNO 对象: 来自 ID 的号码, OBJDES 内容的简短描述, FILE EXT PC 应用程序的文件扩展名。
1、如果程序中需要在前台保存附件,可以使用class:
CL_GOS_DOCUMENT_SERVICE,
method:EXPORT_ATTACHMENT
2、下载到某个local PC目录
使用FM:GUI_DOWNLOAD,如果是纯文本的文件,可以使用BAPI_REL_GETRELATIONS获得对象链接,然后SO_OBJECT_READ获得文本对象的内容。如果是二进制文件,如图片,doc文件,pdf文件等,则处理较为复杂,需要BAPI_REL_GETRELATIONS,SO_OBJECT_READ,SO_KPRO_DATA_FROM_OBJCONT_GET,SO_LOIO_PHIO_GET,SDOK_PHIO_LOAD_CONTENT,SCMS_BINARY_TO_XSTRING几个FM。
3、写文件到application server路径,如写到/usr/ttt/目录下以供他用
如2中获得对象内表,然后使用open dataset方式写文件,以下例子:
FORM frm_download_atta USING p_it_zmmjy_th_pr STRUCTURE zmmjy_th_pr
p_g_path ”路径/usr/ttt/
CHANGING p_flag ”PR是否有附件
p_ftype .
DATA: l_objectid TYPE bapiborid,
lt_relat TYPE TABLE OF bapirellk WITH HEADER LINE,
l_objdisp TYPE sood2,
lt_objcont TYPE TABLE OF soli,
lt_context LIKE sdokpropty OCCURS 0 WITH HEADER LINE,
loio_object LIKE sdokobject,
phio_object LIKE sdokobject,
lt_binary_content TYPE TABLE OF sdokcntbin,
xfile TYPE xstring,
xfilename TYPE string.
DATA: xlen TYPE i.
DATA t_banfn LIKE eban-banfn.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = p_it_zmmjy_th_pr-banfn
IMPORTING
output = t_banfn.
l_objectid-objkey = t_banfn.
l_objectid-objtype = 'BUS2105'.
p_flag = 'X'.
CALL FUNCTION 'BAPI_REL_GETRELATIONS'
EXPORTING
objectid = l_objectid
relation = 'ATTA'"附件,除此之外还有NOTE,URL等
TABLES
listofrelations = lt_relat[].
IF LINES( lt_relat ) = 0."没有附件
p_flag = ''.
EXIT.
ENDIF.
* LOOP AT lt_relat.
READ TABLE lt_relat INDEX 1."业务上规定附件只有一个
REFRESH lt_objcont.
CALL FUNCTION 'SO_OBJECT_READ'
EXPORTING
folder_id = lt_relat-objkey_b(17)
object_id = lt_relat-objkey_b+17(17)
IMPORTING
object_hd_display = l_objdisp
TABLES
objcont = lt_objcont
EXCEPTIONS
OTHERS = 15.
MOVE l_objdisp-file_ext TO p_ftype .
TRANSLATE l_objdisp-file_ext TO UPPER CASE.
CALL FUNCTION 'SO_KPRO_DATA_FROM_OBJCONT_GET'
IMPORTING
loio_object = loio_object
TABLES
objcont = lt_objcont
context = lt_context
EXCEPTIONS
missing_kpro_data = 1
OTHERS = 2.
CALL FUNCTION 'SO_LOIO_PHIO_GET'
EXPORTING
loio_object = loio_object
IMPORTING
phio_object = phio_object
EXCEPTIONS
kpro_inconsistency = 1
x_error = 2
OTHERS = 3.
CALL FUNCTION 'SDOK_PHIO_LOAD_CONTENT'
EXPORTING
object_id = phio_object
TABLES
file_content_binary = lt_binary_content
EXCEPTIONS
not_existing = 1
not_authorized = 2
no_content = 3
bad_storage_type = 4
OTHERS = 5.
xlen = l_objdisp-objlen.
CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
EXPORTING
input_length = xlen
IMPORTING
buffer = xfile
TABLES
binary_tab = lt_binary_content
EXCEPTIONS
failed = 1
OTHERS = 2.
DATA sap_path_n TYPE string.
DATA wa LIKE sdokcntbin.
CONCATENATE p_g_path p_it_zmmjy_th_pr-filename '.' p_ftype INTO sap_path_n.
OPEN DATASET sap_path_n FOR OUTPUT IN BINARY MODE.
IF sy-subrc NE 0.
MESSAGE 'OPEN FILE FAILED' TYPE 'E'.
ENDIF.
LOOP AT lt_binary_content INTO wa.
TRANSFER wa-line TO sap_path_n.
ENDLOOP.
CLOSE DATASET sap_path_n.
CLEAR sap_path_n.
* ENDLOOP.
ENDFORM.
三、可以用事务码OAOR管理附件
以PR为例,
三、若DMS管理附件,怎么下载附件,候补