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:
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:
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 :
Unlike our previous services, this time we will not use ASMA in our SFTP sender channel:
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:
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 :
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:
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:
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 :
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 :
After these steps, our text file will be created without any problems :
Below you can see our file converted to text format:
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
5 | |
4 | |
3 | |
3 | |
2 | |
2 | |
2 | |
2 | |
1 | |
1 |