Enterprise Resource Planning Blog Posts by Members
cancel
Showing results for 
Search instead for 
Did you mean: 
-Mustafa_Onur-
Explorer
818

Hello everyone,

I hope everything is all right and well. Since I was a junior, we have been asked many times by our customers to perform services that change file formats. Even though they are similar services, I had to find alternative solutions because the methods I used sometimes did not work. In some services, I had to combine different methods or services I used. In this scenario, I will show you how to convert the zip-compressed CSV file sent via SFTP to text format. While doing these operations, we will not write any code or create an ESR object.

For example, let's say we have a zip-compressed CSV file named Necropolis with the file content as follows:

Mustafa_Onur_0-1718848890908.png

First, let's unzip the compressed file and convert the resulting CSV file to XML format.

You can find detailed information on how to unzip files with the Zip extension in one of my previous blogs:

https://community.sap.com/t5/enterprise-resource-planning-blogs-by-members/unzip-and-send-a-zip-file...

After the unzip process, we will transmit our CSV file in XML format. To do this, we will use message transform beans. You can find detailed technical information about this on Mr. Engswee's blog :

https://community.sap.com/t5/technology-blogs-by-members/fcc-parameter-reference-for-messagetransfor...

 

Unlike our previous services, this time we will not use ASMA in our SFTP sender channel:

Mustafa_Onur_1-1718848890912.png

Here, we go directly to the module tab, just like in the other examples we have done. By entering the following parameters, we will perform unzip and XML conversions:

Mustafa_Onur_2-1718848890916.png

Below you can find the modules and parameters we used:

 

1

AF_Modules/PayloadZipBean

Local Enterprise Bean

zip

2

localejbs/AF_Modules/MessageTransformBean

Local Enterprise Bean

Plain2XML

3

localejbs/CallSapAdapter

Local Enterprise Bean

entry

 

Plain2XML      Transform.Class                       com.sap.aii.af.sdk.xi.adapter.Conversion

Plain2XML      Transform.ContentType             text/xml;charset=utf-8 

Plain2XML      xml.conversionType                  SimplePlain2XML 

Plain2XML      xml.fieldNames                        Units,Attack,Defense,Damage,Health,Speed

Plain2XML      xml.fieldSeparator                    ,

Plain2XML      xml.processFieldNames            fromConfiguration 

zip                    zip.filenameKey                       contentType 

zip                    zip.mode                                  unzip

 

After the procedures here, our file will be unzipped and converted to XML format.

 

There are some points I want to mention here :

  • If we set the xml.processFieldNames parameter fromConfiguration, we have to use the xml.fieldNames parameter.
  • In the xml.fieldNames section, we enter the field names in the CSV file here.
  • When you open the CSV file with Notepad, you will see which characters separate the fields. We specify that character in the xml.fieldSeparator section. In this example, our character is a comma.
  • During this process, never use ASMA settings on the sender side

 

In order to convert our XML data into text format, the following changes must be made on the File receiver channel. First, we write the location where the file will be saved and the file name and extension:

Mustafa_Onur_3-1718848890918.png

Again, we need message transform beans to convert XML data to text format.

In order to convert XML formats to text format, we need to use the following information under the module tab:

Mustafa_Onur_4-1718848890922.png

Below you can find the modules and parameters we used:

 

1        localejbs/AF_Modules/MessageTransformBean          Local Enterprise Bean        XML2Plain

2        CallSapAdapter                                                             Local Enterprise Bean        0

 

 

XML2Plain  Transform.Class                                  com.sap.aii.messaging.adapter.Conversion 

XML2Plain  Transform.ContentType                      text/plain;charset=utf-8

XML2Plain  xml.addHeaderLine                             0 

XML2Plain  xml.conversionType                            SimpleXML2Plain 

XML2Plain  xml.endSeperator                                 'nl' 

XML2Plain  xml.fieldSeparator                                ; 

XML2Plain  xml.field.Names                                Units,Attack,Defense,Damage,Health,Speed

XML2Plain  xml.processFieldNames                       fromConfiguration 

XML2Plain  xml.fixedLengthTooShortHandling     Ignore

 

There are some points I want to mention here :

  • We used the value 'nl' for the xml.endSeperator field. nl stands for new line. Quotation marks must be used.
  • In the xml.fieldSeparator section, we specify which character will separate the fields in the Text file. Here we wanted our areas to be separated by semicolons.
  • We entered the Ignore value for the xml.fixedLengthTooShortHandling field. This means that the system copies the value completely, regardless of how long it takes.
  • The field names are given in the xml.field.Names parameter must be the same as the field names in the CSV file
  • If we set the xml.processFieldNames parameter fromConfiguration, we have to use the xml.fieldNames parameter.
  • During this process, never use ASMA settings on the receiver side.

 

If you remember, we were going to do these operations without creating any ESR object. The important parts here are the Interface and Namespace names. Even if you have not created the objects, you can give dummy names to these objects on the Integrated Configuration side :

Mustafa_Onur_5-1718848890925.png

After these steps, our text file will be created without any problems :

Mustafa_Onur_6-1718848890940.png

Below you can see our file converted to text format:

Mustafa_Onur_7-1718848890943.png

Thus, we can easily convert CSV files in zip-to-text format without using any code or creating an ESR object.

 

Thank you, have a great day!