Hi Experts,
I have implemented GET_STREAM method to read GOS attachment from PM Notifications. The service is getting executed but it returns garbage values. Please look at the screenshot attached.
GET_STREAM Method Logic
InstID: QMEL-QMNUM
TypeID: BUS2038
CatID: BO
REL_OPTION: ATTA & URL
" Call Method to read links.
CALL METHOD cl_binary_relation=>read_links
EXPORTING
is_object = ls_object
it_relation_options = lt_rel_option
IMPORTING
et_links = lt_links.
LOOP AT lt_links into ls_links.
lv_doc_id = ls_links-instid_b.
" FM to Read Link/Attachment.
CALL FUNCTION 'SO_DOCUMENT_READ_API1'
EXPORTING
document_id = lv_doc_id
IMPORTING
document_data = ls_doc_data
TABLES
object_header = lt_obj_header
object_content = lt_obj_cont
attachment_list = lt_attachment
contents_hex = lt_cont_hex
EXCEPTIONS
document_id_not_exist = 1
operation_no_authorization = 2
x_error = 3
OTHERS = 4.
TRY.
" Convert Binary to Xstring
CALL METHOD cl_bcs_convert=>xtab_to_xstring
EXPORTING
it_xtab = lt_cont_hex
RECEIVING
rv_xstring = lv_xstring.
CATCH cx_bcs .
ENDTRY.
ls_stream-value = lv_xstring.
ls_stream-mime_type = ls_doc_data-obj_type.
*
* TRANSLATE ls_stream-mime_type TO LOWER CASE.
copy_data_to_ref( EXPORTING is_data = ls_stream
CHANGING cr_data = er_stream ).
endloop.