Hi guys,
I am using the FM SAP_WAPI_ATTACHMENT_ADD to add .txt format document to a work item in the following way:
I am using BDS_ALL_CONNECTIONS_GET first to fetch all the attachments attached to the BO BUS2089.
Then for .txt type attachments, to get the text, I am using following piece of code:
IF l_file_ext EQ'txt'OR l_file_ext EQ'TXT'.
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.
ls_att_header-file_type = lc_t.
ls_att_header-file_extension = l_file_ext.
ls_att_header-file_name = ls_conn-descript.
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.
IF ls_atta ISNOTINITIAL.
APPEND ls_atta TO t_atta.
ENDIF.
CLEAR ls_atta.
ENDIF.
But while debugging I found that ls_comment-cont_text comes out blank due to which I am unable to get the text which is there in the file.
And so in turn, I cannot see any attachments to the particular workitem in the UWL.
What might be the reason for the same?
Please throw some light.
Regards,
Pranita