on 06-25-2016 5:53 AM
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.
Hello Rahul,
Please check the below points once again.
I see that you are calling method copy_data_to_ref inside loop. This has to be called only once at the end.
You need to get the complete media content and call the above method at the end.
Please check this.
Pass back the mime type in lower case and check.
Regards,
Ashwin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Ashwin,
Did as you mentioned but still facing the same issue .
Please look at the code below
READ TABLE it_key_tab INTO ls_key_tab WITH KEY name = 'Qmnum'.
IF sy-subrc EQ 0.
lv_qmnum = ls_key_tab-value.
ENDIF.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = lv_qmnum
IMPORTING
output = lv_qmnum.
lv_instid = lv_qmnum.
ls_object-instid = lv_instid.
ls_object-typeid = 'BUS2038'.
ls_object-catid = 'BO'.
ls_rel_option-sign = 'I'.
ls_rel_option-option = 'EQ'.
ls_rel_option-low = 'URL'.
APPEND ls_rel_option TO lt_rel_option.
ls_rel_option-low = 'ATTA'.
APPEND ls_rel_option TO lt_rel_option.
TRY.
" 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.
IF sy-subrc = 0 .
ENDIF.
CATCH cx_obl_parameter_error .
CATCH cx_obl_internal_error .
CATCH cx_obl_model_error .
ENDTRY.
LOOP AT lt_links INTO ls_links.
CLEAR lv_doc_id.
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.
IF sy-subrc EQ 0.
lv_length = ls_doc_data-doc_size .
TRY.
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.
ENDIF.
ENDLOOP.
copy_data_to_ref( EXPORTING is_data = ls_stream
CHANGING cr_data = er_stream ).
Actually the attachment is added in SAP and not through Gateway. We are just testing how GOS attachment works. But going forward it would be through Gateway.
So if we attach JPG file, it returns JPG in mime type and respectively for other file extensions as well.
First we need to get the GET_STREAM method working properly and then we wil move on to CREATE_STREAM.
User | Count |
---|---|
93 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.