Hi Experts,
I am doing the TRF attachments into UWL and outlook mail but they are getting stored into appliction server so how can I store it into DMS and then call in the WF worklist insted of storing application level. I am very new in this issue never done it on DMS.
I am using below code as of now for the to store into application leve :
DATABEGINOF ls_docid_structure.
INCLUDESTRUCTURE soentryi1.
DATAENDOF ls_docid_structure.
DATA: ls_lpor TYPE sibflporb,
lt_conn TYPETABLEOF bdn_con,
ls_conn TYPE bdn_con,
ls_atta TYPE swr_att_id,
ls_key TYPE soodk,
ls_text TYPE soli,
ls_comment TYPE bcss_dbpc,
lt_hex_cont TYPETABLEOF solix,
ls_hex_cont TYPE solix,
lrf_document TYPEREFTO cl_document_bcs,
lrf_bcs_exception TYPEREFTO cx_root,
ls_att_header TYPE swr_att_header.
DATA: l_att_txt TYPE string,
l_text TYPE string,
l_file_ext TYPE char3,
l_document_id TYPE sofolenti1-doc_id,
l_binfile TYPE xstring.
data: t_atta TYPETABLEOF SWR_ATT_ID.
*TYPES: ls_atta TYPE SWR_ATT_ID.
*TYPES: t_atta TYPE TABLE OF SWR_ATT_ID.
* Field Symbols
FIELD-SYMBOLS <p> TYPEx.
* Constants
CONSTANTS : lc_x TYPE char1 VALUE'X',
lc_bus2089 TYPE bds_clsnam VALUE'BUS2089',
lc_clstype TYPE char2 VALUE'BO',
lc_e TYPE char1 VALUE'E',
lc_t TYPE char1 VALUE'T',
lc_b TYPE char1 VALUE'B'.
CONCATENATE im_pernr im_reinr INTO ls_lpor-instid.
ls_lpor-typeid = lc_bus2089.
ls_lpor-catid = lc_clstype.
CALLFUNCTION'BDS_ALL_CONNECTIONS_GET'
EXPORTING
classname = lc_bus2089
classtype = lc_clstype
objkey = ls_lpor-instid
all = lc_x
no_gos_docs = ''
TABLES
all_connections = lt_conn
EXCEPTIONS
no_objects_found = 1
error_kpro = 2
internal_error = 3
not_authorized = 4
OTHERS = 5.
* IF sy-subrc <> 0.
IF sy-subrc <> 0.
MESSAGE e681(zhr_msg) WITH im_pernr im_reinr RAISING
error_reading_attachment.
ELSEIF lt_conn[] ISINITIAL.
MESSAGE e680(zhr_msg) WITH im_pernr im_reinr RAISING
no_attachment_found.
ENDIF.
*--Process the attachment list
LOOPAT lt_conn INTO ls_conn.
l_document_id = ls_conn-loio_id.
CLEAR ls_docid_structure.
MOVE l_document_id TO ls_docid_structure.
*--Check class of document
* For text of ASC document, use BCS to easily fetch contents
IF ls_conn-docuclass = 'txt'OR ls_conn-docuclass = 'TXT'OR
ls_conn-docuclass = 'asc'OR ls_conn-docuclass = 'ASC'.
CLEAR ls_key.
ls_key-objtp = ls_docid_structure-objtp.
ls_key-objyr = ls_docid_structure-objyr.
ls_key-objno = ls_docid_structure-objno.
TRY.
CALLMETHOD cl_document_bcs=>getu_instance_by_key
EXPORTING
i_sood_key = ls_key
i_no_enqueue = lc_x
RECEIVING
result = lrf_document.
CATCH cx_document_bcs .
CALLMETHOD lrf_bcs_exception->get_text
RECEIVING
result = l_text.
MESSAGE e681(zhr_msg) WITH im_pernr im_reinr RAISING
error_instantiating_attachment.
ENDTRY.
*--Read content
TRY.
CALLMETHOD lrf_document->if_document_bcs~get_body_part_content
EXPORTING
im_part = 1
RECEIVING
re_content = ls_comment.
CATCH cx_document_bcs .
CALLMETHOD lrf_bcs_exception->get_text
RECEIVING
result = l_text.
MESSAGE e681(zhr_msg) WITH im_pernr im_reinr RAISING
error_reading_attachment.
ENDTRY.
CLEAR:l_att_txt,ls_text.
LOOPAT ls_comment-cont_text INTO ls_text.
CONCATENATE l_att_txt ls_text INTO l_att_txt.
ENDLOOP.
l_file_ext = ls_conn-docuclass.
TRANSLATE l_file_ext TOUPPERCASE. "#EC TRANSLANG
ls_att_header-file_type = lc_t.
ls_att_header-file_extension = l_file_ext.
CONCATENATE ls_conn-descript l_file_ext INTO ls_att_header-file_name.
ls_att_header-language = lc_e.
CALLFUNCTION'SAP_WAPI_ATTACHMENT_ADD'
EXPORTING
workitem_id = im_workitemid
att_header = ls_att_header
att_txt = l_att_txt
document_owner = ls_conn-crea_user
do_commit = lc_x
IMPORTING
att_id = ls_atta.
APPEND ls_atta TO t_atta.
CLEAR ls_atta.
ELSE.
*--For other types of document, SO_DOCUMENT_READ_API1 returns contents of the file
* in HEX format
CLEAR lt_hex_cont[].
*--Read the data
CALLFUNCTION'SO_DOCUMENT_READ_API1'
EXPORTING
document_id = l_document_id
TABLES
contents_hex = lt_hex_cont
EXCEPTIONS
document_id_not_exist = 1
operation_no_authorization = 2
x_error = 3
OTHERS = 4.
IF sy-subrc NE0.
MESSAGE e681(zhr_msg) WITH im_pernr im_reinr RAISING error_reading_attachment.
ENDIF.
CLEAR l_binfile.
LOOPAT lt_hex_cont INTO ls_hex_cont.
ASSIGN ls_hex_cont TO<p> CASTING.
CONCATENATE l_binfile <p> INTO l_binfile IN BYTE MODE.
ENDLOOP.
IF im_workitemid ISNOTINITIAL.
l_file_ext = ls_conn-docuclass.
TRANSLATE l_file_ext TOUPPERCASE. "#EC TRANSLANG
ls_att_header-file_type = lc_b.
ls_att_header-file_extension = l_file_ext.
CONCATENATE ls_conn-descript l_file_ext INTO ls_att_header-file_name.
ls_att_header-language = lc_e.
CALLFUNCTION'SAP_WAPI_ATTACHMENT_ADD'
EXPORTING
workitem_id = im_workitemid
att_header = ls_att_header
att_bin = l_binfile
document_owner = ls_conn-crea_user
do_commit = lc_x
IMPORTING
att_id = ls_atta.
APPEND ls_atta TO t_atta.
CLEAR ls_atta.
ENDIF.
ENDIF. "Binary or text
ENDLOOP.
IF t_atta[] ISINITIAL.
MESSAGE e680(zhr_msg) WITH im_pernr im_reinr RAISING
no_attachment_found.
ENDIF.