Skip to Content
Author's profile photo Former Member

Java mapping to read a csv file attachment and convert into required XML


This document will help us in understanding and achieving the following scenario by using Java Mapping


  • SAP PI receives a .csv file as an attachment.
  • The attachment needs to be read ,converted in to XML and place the XML file in the target location
  • The .csv file contains multiple records with 2 fields in each record

  Note: The above scenario can be further enhanced based on the requirement.


·        Java and PI Knowledge.

·        SAP PI 7.31(Single Stack), SAP NetWeaver Developer Studio 7.31 SP07, Java Version 1.6.


PFA Java Mapping Code and test sample files for reference.

ESR Configuration

Source Message Type


Target Message Type


–          Create Outbound and Inbound Service Interfaces and assign these message types.

    Note: For Outbound Interface, Please choose Interface Pattern as: Stateless (XI 3.0- Compatible)

–          Import the java mapping in ESR under Imported Archives

–          Create Operation mapping and assign the java class from the imported archives as shown below:


Please check Read Attachments check box in Operation Mapping

In Integration Directory, you can configure a simple File to File scenario

Note: While configuring the sender file adapter, make sure Additional File(s) section is selected under this section you have to mention the csv file name that will be picked as an attachment or you can refer to my blog where in an customized adapter module is being used to achieve this functionality.

Sender FILE Channel Configuration


NFS location contains the following files


Sender Channel is started and the following audit logs can be seen in the Audit logs


Message Monitoring Logs is as shown below . Here, in the below screenshot , you can see the File.csv coming as an attachment in the payload.


Following is the output of Java mapping


Assigned Tags

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

      Hi Vinay,

      How can I do the same with FTP server.

      Author's profile photo Joe S
      Joe S

      Hi Vinay,

      I'm trying to refer your adapter module development blogs -
      But looks like its not migrated yet. Would you be able to get this migrated or do you've a copy of the document for me to refer please?