XI - File Content Conversion. By Punit J, YASH PI Competency Team, Yash Technologies. Description: File Content Conversion is used to convert non-XML file (flat file) to XML file and vice-versa.In this. Many a times, you are required to read a non XML file into SAP PI. SAP provides an out of the box solution for this, wherein you read the contents of a non XML file, e.g., a text(.txt) file or a comma separated(.csv) file and convert it into standard XML format that PI understands. Step-by-step guide on File-to-IDoc using SAP PI 7.0. By Deepak Shah, L&T Infotech. Brief Overview: The purpose of this exercise is to implement a simple one way Asynchronous link between a file sender and SAP R/3 system using SAP XI/PI. Custom XML Document Containing Vendor information is picked up from the FTP server by file adapter.Skip to end of metadataGo to start of metadata
This is a basic overview of content conversion using the file adapter.
This is a simple asynchronous File to File scenario. A flat file is deposited on a local FTP server; it's read by a Communications Channel, converted to XML, mapped to an inbound XML document and sent back to the FTP server
I'm going to create two Data Types, two Messages Types , two Message Interfaces and a single Interface Mapping. The flat file is being read by a File Adapter so I'll need to configure 'Content Conversion' on the sender communications channel.
The input file contains a list of employees and their previous employers as shown below. Please note that the first two rows are for reference only and won't be included when testing.
The records are grouped by employee, the first record being the header. Each Header Record contains a key, employee number, first name, current employer and phone number. Subsequent rows contain detail records. The detail records hold the employee's previous employers and company locations. The first character is the key field, 'H' for header and 'D' for detail. I've assumed that the records are presented in the correct sequence - one header record, an unlimited number of detail records, followed by another header record and so on.
1) The first data type will hold the outbound file (flat file) once it's been received by PI. You need to be aware that the Sender Communications Channel 'Content Conversion' configuration has references to elements within this XML document so they need to be an exact match.
The second data type will contain the inbound file. I've tidied it up a little, the 'key' has been dropped and the prior employers sit underneath the employee record.
2) Create two Message Types.
3) Create an outbound asynchronous Message Interface that references the flat file Message Type and an inbound asynchronous Message Interface that references the XML Message Type.
Enclosuresign In Fcc In Sap Pi
4). Create a single Interface Mapping and a single Message Mapping. Map as required.
1) The following objects are required.
- Sender communications channel
- Sender Agreement
- Receiver Determination
- Interface Determination
- Receiver Agreement
- Receiver Communications Channel
I'm going to focus on the Sender Communication Channel as the rest of the configuration is straightforward. When creating the Communications Channel select 'File Content Conversion' as the message protocol. Configure the File or FTP server details as required and click on the 'Content Conversion' tab.
OK, now we can concentrate on the 'Content Conversion' parameters which are shown below.
- Name: The name of the XML structure receiving the document. This is will be the Outbound Message Type.
- Namespace: Namespace of the Outbound Message Type
- Offset: Number of lines to be ignored at the beginning of the document.
Complex Fcc In Sap Pi
- Name: Name of the recordset structure.
- Namespace: Namespace to be appended to the document structure.
- Structure: The name of substructures within the outbound document followed by the number of times the substructures occur. * indicates an unknown number of substructures.
- Sequence: The help documentation is a confusing when describing sequence. I've left this as Ascending on the assumption that the data within the Outbound file is formatted correctly and appears in ascending order. If anyone can provide a detailed explanation of this parameter it would be appreciated.
- Per Message: Number of recordsets that should be included in the message. If this number is exceeded another message is created.
- Field Name: Name of the key field within the file.
- Field Type: I left this as string and didn't see any reason why it should be changed.
Now we can move on to the Recordset parameters. This is the where I tell PI how to locate the substructures, the elements contained within them and the field lengths. Each parameter is prefixed with the name of the element it refers to. All of this has to be typed in so double check everything before you activate the object. As you saw earlier I have two recordset substructures, Header and Detail. The parameters I used are shown below.
- FieldNames - These names correspond to the elements within the outbound XML.
- FieldFixedLengths - The length of each field. It is assumed that each field starts after the previous field.
- KeyFieldValue - The value contained within the key field. In this example the key values are 'H' for header and 'D' for detail.
- ProcessConfiguration - I'm not sure why I used this parameter or where I got it from. If anyone can provide some detail or a link to the appropriate help document it would be appreciated.
The following screen shot shows the relationship between the 'Content Conversion' parameters and the input file.
For example the header row contains 5 elements. Key, EmpID, Name, Company and Phone. The key is indicated by 'H' in column one and will be one character long. EmpID will be eight characters long and starts in column two and so on.
This is a small selection of the available recordset parameters. More detailed information can be found on SAP Help. http://help.sap.com/saphelp_nw04/helpdata/en/2c/181077dd7d6b4ea6a8029b20bf7e55/frameset.htm
Fcc In Sap Pill
Now its just a case of putting the outbound file in the appropriate directory on your FTP server. Make sure the file has the correct filename. In my scenario the Sender Communications Channel checks for files every 60 seconds. Once the file has been read it's archived to another directory. You won't see any content conversion in SXMB_MONI so I assume this is done within the adapter (please correct if I'm wrong).
This is a very simple way of importing flat files into PI. The only problems I encountered were with the 'Content Conversion' parameters. With a little trial and error I managed to get it working. I'd advise getting yourself a decent text editor as this helped me when designing the content conversion.