cancel
Showing results for 
Search instead for 
Did you mean: 

How to add attachment in CRM order via SAP PI

safeer_shah2
Participant
0 Kudos

HI ,

I followed the following blog and now I am able to get the attachement in the system in binary format , the next part is that how I can upload or attach it with a CRM order? this is the blog i followed.

http://scn.sap.com/community/pi-and-soa-middleware/blog/2012/12/26/handle-soap-with-attachment-in-sa...

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Safeer,

Document can be attach to CRM order using class cl_crm_documents=>create_with_table . below is the code you can use:

DATA:

            ls_business_object  TYPE sibflporb,

              ls_sdok_property    TYPE sdokpropty,

             lt_properties       TYPE sdokproptys,

             ls_file_info        TYPE sdokfilaci,

             lt_file_info        TYPE sdokfilacis,

              lt_content_bin      TYPE sdokcntbins.

            

* Preparing attachment data .

* Business object = Knowledge Article

    ls_business_object-instid = GUID of CRM order"lv_header_guid.

    ls_business_object-typeid = Business Object of CRM Order"'BUS2000111'.

    ls_business_object-catid  = 'BO'.

    ls_sdok_property-name    = 'KW_RELATIVE_URL'.

* This is the name displayed as description

    ls_sdok_property-value   = File name "ls_file_access_info1-file_name."ls_attachment-filename.

    INSERT ls_sdok_property INTO TABLE  lt_properties.

* file info

    ls_file_info-file_size  = ls_file_access_info1-file_size. " Size of file

    ls_file_info-file_name  = ls_file_access_info1-file_name."File name

    ls_file_info-mimetype   = 'application/pdf' " For PDF File .

    ls_file_info-binary_flg = 'X'.

    APPEND ls_file_info TO lt_file_info.

* create binary file in CM as attachment from knowledge_article to activity_email

    CALL METHOD cl_crm_documents=>create_with_table

      EXPORTING

        business_object     = ls_business_object

        properties          = lt_properties

        file_access_info    = lt_file_info

        file_content_binary = lt_content_bin " Binary content.

Regards,

Wasim

Answers (2)

Answers (2)

safeer_shah2
Participant
0 Kudos

Thanks, Wasim, another question , do you have some sample code if i want to send from CRM to other system

BGarcia
Active Contributor
0 Kudos

Hi Safeer,

Never worked with PI but try to check method CREATE_WITH_TABLE from class CL_CRM_DOCUMENTS. It allows you to upload a binary content to a business object (like CRM Order).

See if it helps you a little more.

Kind regards,

Garcia