Blog Banner Image

Common Utility to Convert End-of-line in SAP PI

In middleware projects, we come across messages/files that need to be transmitted between computers having different operating systems (Windows, UNIX, or Mac). All operating systems expect the end-of-line in different ways. Windows expect Carriage Return and Line Feed (CRLF), UNIX expect Line Feed (LF), and Mac expect Carriage Return (CR). 

Here are a few steps to develop a common utility that can handle any type of file and carry out the end-of-line conversion. This utility is generic and can be used without doing any content conversion.

Step 1: There is no need to define objects in the Enterprise Services Repository (ESR). You can directly create an Integrated Configuration (ICO) in the Integration directory. Create ICO and give a generic (dummy) name to “Interface” and “Namespace.” The interface and the Namespace do not need to be defined in the ESR.

 

SAP PI1

Step 2: Define the sender communication channel which will pick the files. There is no need to do File Content Conversion. You can specify multiple source directories too.

SAPPI2

Step 3: Assign the sender channel under “Inbound Processing.”

SAPPI3

Step 4: Specify the receiver business system/component.

SAP PI 4

Step 5: For the receiver interface, specify the same name as the sender interface and Namespace.

SAP PI 5

Step 6: Create a receiver communication channel. For the same, you can use “Adapter Specific message attributes” as the sender file.

SAP PI 6

Step 7: Go to the Modules table and specify the below Adapter Module before CallSapAdapter.

Module Name: SAP XI Sample/ConvertCRLFfromToLF

Type: Local Enterprise Bean

Parameter Name: convert

Parameter Value: CRLFtoLF (You can also specify LFtoCRLF if you want UNIX (LF) to Windows (CRLF) conversion)

SAP PI 7


Now you can begin testing your configuration. Here, I am using two files with different formats:

Source File 1: Windows Format

SAP PI 8

Receiver File 1: UNIX Format

SAP PI 9

 Source File 2: Windows Format

SAP PI 10

Receiver File 2: UNIX Format

SAP 11

The SAP standard Adapter Module (ConvertCRLFfromToLF) can be used in any communication channel which will allow enhancements via Adapter module and convert line feeds from one format to the other.