cancel
Showing results for 
Search instead for 
Did you mean: 

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

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

deepika_chandrasekar
Active Contributor
0 Kudos

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.

Former Member
0 Kudos

Hi Deepika,

Thanks for the response. If you go through my code snippet I have given, I have already mentioned the mimetype as "application/pdf" for pdf document and used the same in my coding. It still doesnt help out.

regards,

Sabarinathan C

deepika_chandrasekar
Active Contributor
0 Kudos

Hi Sabari,

Did you check the values you are passing in Properties and file access info table ?

Check in debugger what values are passed to those tables when you create through WEBUI and try those values.

Regards,

Deepika.

Answers (1)

Answers (1)

dharmakasi
Active Contributor
0 Kudos

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.

Former Member
0 Kudos

Hi Dharmakasi,

Thanks for the response. You are obsolutely right. I have chosen the mimetype from the table SDOKMIME. I have used mimetype as "image/jpeg" for jpeg image.

regards,

Sabari

dharmakasi
Active Contributor
0 Kudos

Hi Sabari,

Did you able to attach and open images successfully, was the suggestion helpful to you?

Best Regards,

Dharmakasi.