on 07-21-2014 9:28 AM
Dear Experts,
I was trying to attach an image document to SAP CRM WebUI through cl_crm_documents (Method :- create_with_table) by passing the binary value.
I receive a string value for the image from IOS team and I convert the same to Xstring and binary in the code. And pass the binary value to the method "create_with_table".
And I could see the document gets attached. When I try to open the same. The image looks like a small cross bar(i.e :- As if we try to open an unsupported file format.) Though I tried passing both jpeg and png files.
On the other hand, when I try to attach the same image manually in WebUI. I could view the attached image perfectly. Please find the below code snippet I have used.
Help me out in getting it resolved.
CONCATENATE it_flup_gen2-or_img_faci_desc '.pdf' INTO ls_file_access_info-file_name.
* Convert string to Xstring value for FACI Image
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
text = it_flup_gen2-or_img_faci
mimetype = 'application/pdf'
IMPORTING
buffer = lv_faci_xstr
EXCEPTIONS
failed = 1
OTHERS = 2.
IF sy-subrc = 0.
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = lv_faci_xstr
IMPORTING
output_length = lv_len
TABLES
binary_tab = lv_file_content_binary.
* Assign file properties
ls_file_access_info-file_size = lv_len.
ls_file_access_info-binary_flg = 'X'.
ls_file_access_info-file_name = ls_file_access_info-file_name.
ls_file_access_info-mimetype = 'application/pdf'.
APPEND ls_file_access_info TO lt_file_access_info.
* Assign business object
ls_business_object-instid = lv_guid.
ls_business_object-typeid = 'BUS2000125'.
ls_business_object-catid = 'BO'.
** Fill property values
** Get the unique name for the Attachment
ls_properties-name = skwfc_prop_relative_url.
ls_properties-value = it_flup_gen2-or_img_faci_desc.
APPEND ls_properties TO lt_properties.
** Get the decription and title
ls_properties-name = skwfc_prop_description.
ls_properties-value = it_flup_gen2-or_img_faci_desc.
APPEND ls_properties TO lt_properties.
** Get the document mime type
ls_properties-name = skwfc_prop_mime_type.
ls_properties-value = 'application/pdf'.
APPEND ls_properties TO lt_properties.
ls_properties-name = 'LANGUAGE'.
ls_properties-value = sy-langu.
APPEND ls_properties TO lt_properties.
ENDIF.
* Creating a document with provided data
CALL METHOD cl_crm_documents=>create_with_table
EXPORTING
business_object = ls_business_object
properties = lt_properties
file_access_info = lt_file_access_info
file_content_binary = lv_file_content_binary
raw_mode = 'X'
IMPORTING
loio = ls_loio
phio = ls_phio
error = ls_error.
IF ls_error IS INITIAL.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
ENDIF.
regards,
Sabarinathan
HI,
Check the mimetype and passed values while attaching through WEBUI in method CREATE_WITH_TABLE then use the same values you are getting in the debugger in coding and check.
Regards,
Deepika.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sabari,
Try using the mimetype as image/jpeg for jpeg image type and image/png for .png image type formats.
You can check MIME type by using the FM "SDOK_MIMETYPE_GET" by giving the file extension type.
Best Regards,
Dharmakasi.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
8 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.