Skip to Content
0
Former Member
Jan 11, 2012 at 12:43 PM

BSP - WORKFLOW attachment problem for HTML in 4.7

18 Views

Hi Folks,

I am facing an issue in 4.7 while trying to upload a file from BSP and attach the same through workitem. This pass through the next approver and when the work item in the UWL is reached the next approver. The new approver when trying to open the document (HTML) in the UWL attachment. it is not opening in the desired format. however, the .pdf, .xls are working fine.

I am trying to use SOFM business object to attach the documents to the workitems.

Thiis is the code Snippet

CALL FUNCTION 'SO_FOLDER_ROOT_ID_GET'

EXPORTING

owner = sy-uname

region = 'B'

IMPORTING

folder_id = l_folid

EXCEPTIONS

communication_failure = 1

owner_not_exist = 2

system_failure = 3

x_error = 4

OTHERS = 5.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

l_folderid = l_folid.

  • create the attachments for the workflow

LOOP AT file_contents INTO lw_fcontents.

REFRESH lt_content.

CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'

EXPORTING

buffer = lw_fcontents-contents

append_to_table = 'X'

IMPORTING

output_length = l_size

TABLES

binary_tab = lt_content.

IF lt_content IS NOT INITIAL.

SPLIT lw_fcontents-file_name AT '.' INTO l_file l_doctype.

TRANSLATE l_doctype TO UPPER CASE.

ENDIF.

ls_document_data-obj_name = 'ATTACHMENT'.

ls_document_data-obj_descr = lw_fcontents-file_name.

ls_document_data-obj_langu = sy-langu.

ls_document_data-doc_size = l_size.

ls_document_data-no_change = 'X'.

CALL FUNCTION 'SO_DOCUMENT_INSERT_API1'

EXPORTING

folder_id = l_folderid

document_data = ls_document_data

document_type = l_doctype

IMPORTING

document_info = l_docinfo

TABLES

object_content = lt_content

EXCEPTIONS

folder_not_exist = 1

document_type_not_exist = 2

operation_no_authorization = 3

parameter_error = 4

x_error = 5

enqueue_error = 6

OTHERS = 7.

IF sy-subrc NE 0.

MESSAGE e696(wl).

ENDIF.

l_att_key = l_docinfo-doc_id.

object_a-instid = l_docinfo.

object_a-typeid = 'SOFM'.

object_a-catid = 'BO'.

object_b-instid = l_docinfo.

object_b-typeid = 'MESSAGE'.

object_b-catid = 'BO'.

TRY.

CALL METHOD cl_binary_relation=>create_link

EXPORTING

is_object_a = object_a

is_object_b = object_b

ip_reltype = 'ATTA'.

CATCH cx_obl_parameter_error .

CATCH cx_obl_model_error .

CATCH cx_obl_internal_error .

ENDTRY.

IF sy-subrc EQ 0.

COMMIT WORK AND WAIT.

ENDIF.

swf_create_object l_attach 'SOFM' l_docinfo-doc_id.

APPEND l_attach TO me->t_objkey.

ENDIF.

Please help on this to open the >HTML format.

Thanks in advance for the help