Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
Showing results for 
Search instead for 
Did you mean: 
Active Contributor

Hi All,

In one of our projects, we had a requirement to read the incoming .CSV file and pass its entire content as-is in one of the Target Structure Node.

As in normal scenario, I decided to use FCC in order to achieve this requirement. But when I started testing the scenario, I noticed that we are not able to read the Entire CSV data in one single Target field. Instead it creates a new Record of each single line in CSV file. (Whenever a Newline is encountered in Source File, it creates a new Record node; even placing some vague value for endSeparator did not help).

Thus with FCC, we were not able to achieve this.

As next steps I started to look for other alternatives. I had the option to achieve it using either XSLT mapping or using Java Mapping.

I decided to go for Java mapping over XSLT because its light weight & performance efficient.

To start With Java Mapping we have to import all the relevant jar files and also have the Local IDE - Eclipse or NWDS available for our development. Since there were some challenges in getting these we were stuck in our development, until I stumbled across this blog: Write Java Mapping directly in ESR!

written by sunil.chandra

I decided to extend the same logic as mentioned in the blog for my case. I wrote the java logic in Message Mapping - Functions Tab under Attributes and Methods as follows:

//Following code is to read the Flat File As-Is from source into the Target Node and to map Constants to rest of the Target XML Nodes:

public void transform(TransformationInput in, TransformationOutput out)

  throws StreamTransformationException {

try {

  String source = ""; String targetxml =""; String line ="";

  InputStream ins =    in.getInputPayload().getInputStream();

  BufferedReader br = new BufferedReader( new InputStreamReader(ins));

  while ((line = br.readLine()) != null) 

  source +=line+'\n'; 


     String XML_START_TAG = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><ns1:SendFile xmlns:ns1=\"\">";

  String XML_END_TAG = "</ns1:SendFile>";

  targetxml = XML_START_TAG+




   "<ns1:UserId>test</ns1:UserId>" +

   "</ns1:Security>" +

   " <ns1:Action>New</ns1:Action>" +

   "<ns1:File>" +

   "<ns1:FileContent>"+source+"</ns1:FileContent>" +

   "<ns1:FileType>CSV</ns1:FileType>" +

   "</ns1:File>" +

   "</ns1:EM>" +




  catch (Exception e) {   throw new StreamTransformationException(e.getMessage());  


//End of the code

Following are the screenshots attached for the Function Mapping and Testing in ESR:

1. Message Mapping - Functions Tab:

2. ESR Testing:

3. ESR Testing:

We are able to see & verify the required output in ESR Message Mapping Testing.

Rest of the configuration remains same as we do in other scenarios. However there is one important configuration setting that needs to be taken care. Since we are not parsing the Input file (not doing conversion from CSV to XML) we need to keep the Sender SWCV empty in our Configuration Scenario, else we might end up getting error at runtime - "Content not allowed in prolog" as mentioned in the blog- The Mystery of 'Content is not allowed in prolog'

We will use dummy Sender Interface in this case, since we are not converting the CSV file into XML structure, but passing it as-is to target.

Advantages of this approach:

1. No need to worry about getting the Jar files and having IDE in your local system.

2. No need to do FCC conversions in Configuration

3. Instantaneous testing can be done in ESR - MM test tab for your Java code

Same logic and steps can be further extended to suit other requirements as well.

This blog covers one of the possible ways to read the entire Source file data into single Node field. There are few other blogs that provides alternative solution like: Read Input Text File as a Single Field. - Process Integration - SCN Wiki

Whole Payload to a XML field - Process Integration - SCN Wiki

Hope this blog will be helpful and informative & as one of the alternatives to achieve this requirement.

Please let me know your valuable feedback and suggestions.



Labels in this area