Skip to Content

What is the XIF adapter?

In release CRM 3.X SAP introduced a new adapter for the CRM middleware as a mechanism to load and retrieve data from a CRM system. This adapter was called the eXternal InterFace Adapter or XIF for short. The adapter is series of API’s that provide external access to the CRM middleware.

Traditionally in the R/3 development we used BAPI’s to change data externally. The XIF concept is similar to BAPI’s with the exception that it was designed for multiple layers of access. The three primary access methods are RFC, IDOC and SOAP. These access methods provide the necessary means to use the XIF adapter.

Getting Started with XIF the easy way:

First off, using the XIF IDOC’s or RFC’s is merely a mapping exercise. I have seen many questions on how to map the function module parameters. There is an easy way to do this regardless of how you are using XIF.

I recommend using LSMW to determine your mapping. The benefits of this tool, is you can build a mapping to the XIF adapter without writing any code. This allows for rapid tweaking of the mapping to see how things will work.

Now unlike many other things delivered by SAP, the documentation for the XIF contains 90% of what you need in order to use it, for either RFC or IDOC. The key part is how SAP names the XIF function modules and some of your most common business objects:

SAP follows the convention for the inbound XIF function modules:
CRMXIF_*_SAVE

Where * = Business Object

The most common and useful objects are:

  • ORDER – Business Transactions
  • PARTNER – Business Partner
  • PRODUCT_MATERIAL – please note that in CRM terminology that the PRODUCT object is actually a CRM product catalog. PRODUCT_MATERIAL is what we would consider equivalent to an R/3 material master.

If you look at the code for each function module the general outline looks quite similar:

  1. Determine where the message is being imported
  2. Build a BDOC header for the corresponding BDOC object
  3. Map the XIF structure to a corresponding BDOC structure
  4. Start the middleware flow passing in our newly generated BDOC
  5. Determine errors and call commit work or rollback depending on success or error.

Now this requires middleware on the CRM system to be configured. We do not need to point CRM to an R/3 backend, but we do need to define a site type defined for the XIF adapter.

After keeping this all in mind here is the recipe for building the LSMW project:

  1. Create a new project
  2. Setup IDOC inbound processing for the project
  3. In LSMW define the business transfer as IDOC processing
  4. Create a test data structure
  5. Map the values to the test structure
  6. Convert in the test file and determine if successfully
  7. Adjust the mapping and re-run until successful

Now the details for each step

I am not going to cover in detail the exact steps for each part of the process. I am going to cover the pain points which are not obvious, during the setup in LSMW. For now a good working knowledge of LSMW along with the notes below will lead you to success.

LSMW Project

You will require a new LSMW project to be setup. The most difficult parts of the initial configuration will be the IDOC Inbound Processing Setup and a few issues with mapping.

IDOC Inbound Processing

This is the key to make this work. From the main screen of LSMW choose the menu option:
Settings->IDOC Inbound processing

We need to make sure we have two things setup on this screen: a file port and a partner number. The file port should follow the standard setup for LSMW usage. For the partner number a partner needs to be maintained that has the XIF message type on the Outbound and Inbound Parameters. For Products use message type: CRMXIF_PRODUCT_MATERIAL_SAVE. The Basic type on the IDOC type will be CRMXIF_PRODUCT_MATERIAL_SAVE01.

LSMW Data Object Definition

The object data definition should be of message type CRMXIF_PRODUCT_MATERIAL_SAVE, and basic type CRMXIF_PRODUCT_MATERIAL_SAVE01.

Test data structure

The minimum data to load a product master in CRM is typically a product id code, description, and base unit of measure. Your file will need to contain this data at a minimum.

Mapping files to test structure

Products in CRM are different from your typical R/3 material. A product in CRM does not have any attributes until assigned to a category. Therefore we will need to assign our product to a category in order for it to load. The hierarchy will will commonly use is ‘R3PRODSTYP’ and category id of ‘MAT_FERT’. This corresponds to finished goods type of R/3. If you are not connected to an R/3 system you will need to setup a product hierarchy and assign the basic product views to that category.

Another point to make is that all segments you map will require at least a logical system identifier. The easiest way to handle this is to retrieve the current logical system from T000 with a small mapping routine in LSMW. The logical system indicates where the data originated from, and in this case we want the logical system to show that CRM is the origin of this data.

A project that I built to load a product with an ID, description and UOM mapped the following segments

  • E101COMXIF_PRODUCT_MATERIAL
  • E101COMXIF_PR_S_COMM_PR_MAT
  • E116COMXIF_PRODUCT_S_ADMIN
  • E101OMXIF_PRD_S_COMM_PR_MAT
  • E101MXIF_PRD_SX_COMM_PR_MAT
  • E101COMXIF_PR_S_CATEGORIES
  • E101COMXIF_PRODUCT_S_ADMIN
  • E101COMXIF_PRD_S_CATEGORIES
  • E101COMXIF_PR_S_SHORT_TEXT
  • E102COMXIF_PRODUCT_S_ADMIN
  • E101COMXIF_PRD_S_SHORT_TEXT
  • E101COMXIF_PR_S_UNIT
  • E103COMXIF_PRODUCT_S_ADMIN
  • E101MXIF_PRD_S_COMM_PR_UNIT
  • E101XIF_PRD_SX_COMM_PR_UNIT

CRM Middleware Setup

In transaction SMOEAC you will need to define a new site for the XIF. Create a new site of type External Interface for IDOC’s. You will then need to maintain under the site attributes the EDI partner setup for your LSMW project.

Conclusion

The final issue is the mapping and trying to decipher the XIF data structures. In general this again is relatively straight forward. If you understand CRM data structures and underlying tables then you will have no problem. If you don’t understand the CRM data structures then mapping will be difficult at the least. We may cover CRM data structures in a future blog.

To report this post you need to login first.

15 Comments

You must be Logged on to comment or reply to a post.

  1. £ukasz Krys
    Hi,
    I loaded material master data such as product type, name, unit … I used lsmw and Message Type CRMXIF_PRODUCT_MATERIAL_SAVE. I’d like additionally add Conditions (price e.g. 0PR0 type, Sales org., Dis. Chan.) to this data. Which message type should I use to this job.
    (0) 
    1. Stephen Johannes Post author
      Try the IDOC CRMXIF_COND_REC_COMPL_SAVE_M01.  I have never used this before, so you are definitely on your own with the mapping issues.  You might also want to do a notes search in SAP Service Marketplace to determine if there are any known issues/help documents on this message before using it.

      Good luck,

      Stephen

      (0) 
      1. Manoj Tiwari
        Hi Stephen,

        I have a question on mapping using LSMW with Inbound idoc processing.

        If i have 4 field like matnr, UOM , Description  it means its a plane structure flat file.

        Since my basic idoc type would be crmxif_product_material_m02 and its a complex data structure how i am going to map it with my source structure which i designed like my plane flat file.

        Please suggest me its very urgent, you can mail me on my id tiwari.manoj@gmail.com

        Thanks & Regards,
        Manoj Tiwari

        (0) 
  2. Luis Cirigliano
    Hi Stephen,

    Right now I’m working fine with the CRMXIF_PARTNER_SAVE to migrate Individual Objects from NON SAP system to CRM, by using the LSMW.

    But using the CRMXIF_PRODUCT_INDOBJ_SAVE message
    I can’t find the way to get rid of the IDOC failure.

    The error message is: “ID type has errors or does not exist. Message no. COM_ALTER_IDENT047″ I’ve tried to use the ” ” (Space value) in to the ALTID_TYPE field, even some values (f.e. ALT_NO).

    I really would like you to help me with this error, cause I have seach every were and I can’t find any answer.

    Thanks in advance,

    Luis

    (0) 
    1. Don Muthuvat
      I used CRMXIF_PARTNER_SAVE to create busines partners for number of  records , but  my problem is that when i use BAPI_TRANSACTION_COMMIT, all the records is getting created .
      i.e. bapi return parameter is having error staus( E ) also getting created as business partner with name1 and name 2.(no other value is mapped in this case)

      I wanted to create BP Where CRMXIF_PARTNER_SAVE  fun’n module gives only success message.


      Looking forward ur reply

      Don
      (0) 
  3. P A
    hello Stephen Johannes.
    First thing first gr8 blog to get me working.

    one issues if you can help??

    The mapping everything is done i am using CRMXIF_ORDER_SAVE_M and we have no. of items for one opportunity. How can we use one segment multiple times in LSMW??

    please help?? this looks like a tricky question i found nothing on it??

    many thanks!!
    pankaj(pank0906@yahoo.com)

    (0) 
  4. Frédéric REBEL
    Hi,

    As I would like to use XIF framework to create new XIF/XML Interfaces for existing BDocs (CND_M_SUP..), can you help me by providing an XIF developer guide ?

    Thx

    (0) 
  5. Mamatha Basavaraju
    Hi Stephen,
      I am using me CRMXIF_PRODUCT_SAVE_M01 to upload images into commpr01 transaction. It is attaching the image but i am getting this error “Content data for the object BDS_POC22 not found” as a Informational message and further if i accept that it is giving me the message “Error while opening the document ” . Our is a standalone CRM system .

    When i checked in the debug mode it is failing when executing this FM SDOK_PHIO_CREATE_NEW_VERSION. Also if i check the BDS related tables BDSPHI022 and BDSPHPR22  they are entries pertaining to records which i upload but there is no entry in the table BDSPHF22 . The only attribute i am passing in the message type is BDS_DOCUMENTTYPE BDS_IMAGE . I have tried all possible ways no luck. It would be much appreciated if can direct with a solution.
    Thanks
    Mamatha.

    (0) 
    1. Stephen Johannes Post author
      A lot of people had problems with the document image upload so they wrote a separate load for the images using class CL_CRM_DOCUMENTS instead.  I suggest do a search on SCN here for that term and narrow the results to the CRM General forum for all of time.

      I have to admit that I was shocked seeing a new comment on this blog after about six years.

      Take care,

      Stephen

      (0) 
    2. Mamatha Basavaraju
      Thanks for the inputs. I did the search for the same in the CRM general,but no luck . I am trying to use cl_crm_documents method Creat_with_table. Before I call this method . I have to read the mime file which is on my desktop and convert into binary format . Is there any one function Module which can read and convert it to binary format and capture it in a internal table. Any help would be much appreciated

      Many Thanks  

      Mamatha

      (0) 
      1. Mamatha Basavaraju
        Hi Stephen,
        Thank You for the Info Provided .I was able to attach the images to the Product Master using the Class Cl_CRM_DOCUMENTS with the method create_with_table . Now the challenge is i need to place the full size images under the folder FULL-SIZE and thumbnail images under the folder THUMBNAIL . For this what attributes i need to pass and any specific tables or classes to achieve this .
        Best Regards
        Mamatha
        (0) 
        1. Mamatha Basavaraju
          I was able to attach the images to the product master using cl_crm_documents using the method create_with_table.Thanks for that. But i am not sure why i cant do the same using the IDOC CRMXIF_PRODUCT_SAVE_M01 . I have observed in the debugging it calls the same API ‘s. Any inputs would be appreciated.

          Mamatha

          (0) 
        2. Mamatha Basavaraju
          I was able to attach the images to the product master using cl_crm_documents using the method create_with_table.Thanks for that. But i am not sure why i cant do the same using the IDOC CRMXIF_PRODUCT_SAVE_M01 . I have observed in the debugging it calls the same API ‘s. Any inputs would be appreciated.

          Mamatha

          (0) 

Leave a Reply