In this article, we are going to learn about SAP PI/PO File Adapter.
First, we will understand the File adapter configuration for both sender and receiver. Then we will have a look at File Content Conversion (FCC) with simple and complex file structures.
This example convert 2 different recordsets inside single file to xml. First recordset is “SINGER”, second recordset is “SONG”. First column is 1 character length. It is a key column to identify different recordset. “A” from first half mean SINGER, “B” from second half mean SONG. This is the target Message Type.
- You use the File Adapter with File Content Conversion. The incoming/outgoing file is PGP encrypted and you would like to decrypt it with the PGPDecryption module. The messages in the scenario fail with the following error: Caused by: com.sap.aii.af.lib.mp.module.Modul.
- SAP XI/PI: 1.N Message Split Interface without BPM. Select file content conversion as the Message protocol. Configure the FCC parameters normally. Run the interface. Surprisingly, XI creates multiple files for each of the Header and Line Items pairs from the source.
File Adapter converts the incoming files into XML and vice versa. The File adapter resides on the J2EE stack of the PI server. It can read/write files directly from/to the PI server at the OS level using File System protocol. It also works using FTP protocol, using which it can read/write files from/to any server location. The configuration of File Adapter is quite simple and straightforward.
Sender File Adapter
Select the Transport protocol as FTP or NFS and Message Protocol as File. Specify the Directory and filename from where the source file needs to be picked up. File type can be either text (or XML) or binary. In the case of FTP protocol, you will need to provide FTP connection parameters as well. Below configuration for the File sender channel for NFS.
![Sap Sap](/uploads/1/1/9/3/119387850/813134613.png)
Below configuration for File sender channel for FTP
The adapter supports all the three QoS
- BE (Best Effort),
- EO (Exactly Once) and
- EOIO (Exactly Once in Order).
Specify QoS as per your scenario. Poll Interval indicates the time interval between two consecutive attempts by PI to read the files from the source directory. Processing mode defines how the file should be handled once it is processed by the adapter engine. The file will not get deleted If processing mode selected as “Test”. The File will get deleted if the processing mode is selected “Delete” after the processing. If you specify a queue name (in case of EOIO) it is automatically created in PI. You can also specify the empty file handling.
Receiver File Adapter
Select the Transport protocol as FTP or NFS and Message Protocol as File. Specify the directory and filename where the target file is to be put. The target directory if it does not exist gets created automatically. Specify connection parameters in the case of FTP protocol. You can specify the File Construction mode as per your choice. QoS possible here are EO and EOIO and is inherited from the Integration Server.
You can also Specify the “Add Timestamp” to append file create time to filename. Also, specify the way to handle an empty file.
To see an example of a file adapter using NFS protocol, go through this article about File to IDoc scenario.
![File content conversion in sap pi at receiver configuration File content conversion in sap pi at receiver configuration](/uploads/1/1/9/3/119387850/533862985.jpg)
In the next part, we shall discuss setting up File Adapter for File Content Conversion with simple structure (CSV File) at sender File Adapter
and also check
File Content Conversion with simple structure (Fixed Length Fields ) at sender File Adapter
File Content Conversion In Sap Pi At Receiver Configuration
Imagine you need to read a file content from a remote application and you do not want to set up a replication?
This scenario explains how to expose a CSV file (here a product list) as a WebService using the standard SOAP Adapter and the WHINT FileReader Adapter.
This scenario explains how to expose a CSV file (here a product list) as a WebService using the standard SOAP Adapter and the WHINT FileReader Adapter.
CSV File:
Sap Pi 7.1
Design (ESR):
- Create Service Interfaces (Sender and Receiver side)
- For the receiver side you can also use the synchronous Inbound Service Interface FileReaderQueryResponse_In which is shipped with the Adapter
- Optional: Create a Mapping if you do not want to expose the result of the CSV-to-XML conversion of the MessageTransformBean
Configuration (Eclipse/NWDS):
iFlow:
Receiver Channel (FileReader):
SFTP Connectivity (of course you can read the file from NFS or FTP as well):
Module Configuration (MessageTransformBean: CSV->XML):
Upload File to SFTP Server:
Test from SOAP UI:
Sap Pi Sheet
Update: I think it is obvious that the Files can be also queried with other sender channels, not only from SOAP (like e.g. REST providing the response in JSON format):