Skip to Content
author's profile photo Former Member
Former Member

I can attach an image to SAP CRM WebUI but was not able to view it

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Jul 21, 2014 at 09:06 AM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 21, 2014 at 11:12 AM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.