Frequent question on SDN;
1. How can I map my incoming flat file into a single field of an XML?
2. How can I get the complete payload of a message into a single node/field of an XML?
So this is how it can be done.
If using PI 7.1 and above, you can use this simple option as mentioned in the below blog;
Else if you are on a version below 7.1;
Option : JAVA Mapping
A very simple java code can help you achieve the results. Note that this is not a UDF but a java mapping.
The code above is extremely simple. All it does is the follows;
1. Converts the inputstream that will contain the source payload (it can be a flat file or XML etc) to string
2. An output string is created using string concat. Assign tags and place the output string which has your complete source between it.
3. Write out the result to an outputstream.
1. In FILE adapter, do not use any FCC parameters. Give the Message protocol as FILE. This is in case you want the whole content of the file to come into XI
2. In java mapping, you will have to use the jar aii_map_api.jar
To locate the jar, Go to your XI server folders and use this path, j2ee\cluster\server0\apps\sap.com\com.sap.xi.services. Inside com.sap.xi.services folder you'll find the jar file. Import the jar for your mapping.