Skip to Content
Author's profile photo Former Member

Attachment to Business Partner or Product in CRM

This Blog is a step by step tutorial for attaching documents to a Business Partner and Product in CRM using ABAP from Application Server.

Business Partner is a Person, Organizations and Group to which we have a Business Relationship. A Business Partner can be for example An Account, Prospect, Vendor or Competitor. Account can be subdivided into Person (a private person), Organization (Part of a legal person or legal person), and Group (Partner Group).

SAP CRM provides creation of Product in Product Master. Product Master can be defined with different Product Types. Product types are as follows Material, Service, Financing, and Warranty.

The Objective is to automate the process of attaching additional document to a Business Partner or Product document tab.

Business partner:


CRM Web UI of Business Partner




CRM Web UI of Product


Procedure for Attachment Uploading in CRM:

The step by step process involved in uploading attachment to Business Partner or Product from Application Layer automatically (with the help of a program) is as follows.

  1. File that needs to be attachment to Business Partner or Product is available on Application server (AL11).
  2. The file can be place on Application server with the help of a Basis team, or a utility program can be developed to place files on Application server.

    E.g.: Files on Application Server


3.    Once the files to be uploaded are available on Application server, we need to fetch the file details as follows.

4.    Read the File from application server into internal table one at a time in binary format. As file in Binary format support multiple formats of attachments.

5.    Reading File from Application server as follows


                    lv_file is the absolute file path on Application Server

        lv_msg if any error occurs in opening file, the corresponding error message is assigned for the reference.

b.  Move the data read into internal table of type binary format i.e. SDOKCNTBIN along with the size of the file, e.g.: i_text[].

6.    Attaching File

a.    In order to attach documents from Application Server to an existing Business partner or Product one of the mostly used

       class is CL_CRM_DOCUMENTS (KW Explorer in CRM).

b.    This class have various build in methods for document attachment, method CREATE_WITH_TABLE (Create a Document (Content in Table)) is used in this procedure.

C.  The basic parameters used in this method CREATE_WITH_TABLE are shown below


Of all the parameters listed, we are concerned about few parameters like BUSINESS_OBJECT, PROPERTIES, FILE_ACCESS_INFO, FILE_CONTENT_BINARY, and RAW_MODE.


i.        BUSINESS_OBJECT: Local Persistent Object Reference – BOR-Compatible, following attribute are to be considered.

1.    INSTID: Instance Identification in BOR Compatibility, Persistent Object Reference. Pass the Business partner GUID or Product GUID for which Account or the Product the attachment need to be maintained. Business Partner GUID can be found in table BUT000 and Product GUID in COMM_PRODUCT.

2.    TYPEID: Type of Objects in Persistent Object References. Object reference are present in table TOJTB.


TYPEID = TOJTB-NAME, w.r.t Business Partner and Product.

3.    CATID: Category of Objects in Persistent Object References, as Business partner and Product are Business Objects.

CATID = ‘BO’ (BO = BO Instances of BOR Object Types).

ii.        PROPERTIRES: SDOK: Object attribute, name and feature. It has following attributes.

1.    NAME: It represents Attribute of a document or a relationship.

2.    VALUE: Attribute Value.

The above two parameters have a combination of 3 values to be passed w.r.t NAME and VALUE i.e.


  • Unique Name with in a folder


VALUE = File Name for the attachment.                E.g.: EXCEL.xlsx

  • Short Description


VALUE = File description text.                            E.g.: Excel file

  • Language

Name = ‘LANGUAGE’.

    VALUE = Language in which the attachment is loaded.    E.g.: ‘EN’.

iii.        FILE_ACCESS_INFO : File Access Information properties has following attributes


  • File Size: Size of the file which have to be attached, point 5.b.
  • Binary flag: As the file is read in Binary format.
  • First line: Stating the line number in the internal table to be read.
  • File Name: Absolute file path of the attachment from application server.
  • Mime type: Internal representation of File format/extension which the file need to be read. MIME types are available in table SDOKMIME (MIME content type for file name enhancement).
  • Property: Extension of the file.

                        e.g.: The properties of the attachment are saved as


iv.        FILE_CONTENT_BINARY: File contents of internal table saved as per    point 5.

v.        RAW_MODE: Indicating that file is Raw Data. (pass value  ‘X’)


i.        The Importing parameter are as follows: LOIO, PHIO, and ERROR.

  • LOIO: A unique Logical Document number is generated for attachment.



  • PHIO: A unique Physical Document number is generated for attachment.



  • ERROR: Any error while attaching Document are assigned.

This above process is common for Business Partner and Product, but product have Predefined folders were attachments are saved.


As we intend to place the attachment in DOCUMENTS->PICTURES->THUMBNAILS, so the class CL_CRM_DOCUMENTS has a method GET_INFO_FOR_FOLDER (Get Folders for BOR Objects/Attributes).

The various parameters used in this method are BUSINESS_OBJECT, PROPERTIES_RESULT, and FOLDERS.


i.        BUSINESS_OBJECT: Local Persistent Object Reference – BOR-Compatible, it has following attributes

1.    INSTID: Instance Identification in BOR Compatibility, Persistent Object Reference. Pass the Product GUID for the product to which the attachment need to be uploaded, Product GUID can be found from table COMM_PRODUCT for the corresponding Product.

2.    TYPEID: Type of Objects in Persistent Object References. Object reference are present in table TOJTB.   



3.    CATID: Category of Objects in Persistent Object References, Product as Business Objects. 

CATID = ‘BO’ (BO = BO Instances of BOR Object Types).


i.          PROPERTIES_RESULT: The predefined folder details are fetched. Now read the folder in which we want to attach the files.

                    E.g.: As we are trying to place files to THUMBNAILS folder, read the NAME and VALUE attributes.

Read PROPERTIES_RESULT where NAME = ‘KW_RELATIVE_URL‘ and          VALUE = ‘THUMBNAILS‘ and get OBJTYPE, CLASS, and OBJID fill this values into internal table LS_FOLDER type SKWF_IO.

ii.      FOLDERS: Table with folders.

Once the Folder details are fetched, pass above details to Class CL_CRM_DOCUMENTS, the method CREATE_WITH_TABLE with necessary parameters.

Pseudo Code:

Sample pseudo code and usage of class CL_CRM_DOCUMENTS and methods used for create attachment in Document tab of Business partner or Product.

Pseudo Code  (file1)

With the above code we can attachment multiple attachments that are maintained either form Application server or Presentation server, this program main objective mass loading of attachment to Business Partner or Product automatically.

Example of attachments attached.

Excel 1 Test.xslx (file2)    Test PPT1.pptx (file3)

  1. After execution of the sample code, go to Transaction BP / COMMPR01 else CRM_UI.
  2. Check Business Partner Attachment in GUI T-CODE: BP or in WEB UI under ACCOUNT MANAGEMENT -> ACCOUNT passing Account ID (BP).
  3. Pass Account ID (BP) Number for which attachment are loaded.


4.    Check the details of Account by clicking on the Name of the Account.


5.    Check the Details of the Attachment by clicking on Name of the attachment.


E.g: Test PPT 1.pptx


Similarly other attachments can be viewed by double click on the link of the attachment.

6.    In order to check the attachment for Product GUI T-CODE: COMMPR01 or in Web UI as follows SALES OPERATIONS->PRODUCTS.

7.    Give the product ID for which attachment are loaded.


8.    Double click on Product ID to check details.


Click on Name of the attachment to open attachments.               

Eg: Excel 1 Text.xslx


Conclusion: This Document explains the procedure to attach multiple attachments from Application server to Business Partner or Products (Generally Mass Uploading of Attachments)

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Arjun Pawar
      Arjun Pawar

      Very helpful blog, thanks a lot Bhanu Chander

      Author's profile photo Parveen Kumar
      Parveen Kumar

      Thanks for sharing.

      Author's profile photo Hari Kishore Nidiganti
      Hari Kishore Nidiganti

      Hi Bhanu,

      This very helpful, i am working on same requirement, The Pseudo Code attachment is missing, Could you please provide Pseudo Code.