Enterprise Resource Planning Blogs by Members
Gain new perspectives and knowledge about enterprise resource planning in blog posts from community members. Share your own comments and ERP insights today!
cancel
Showing results for 
Search instead for 
Did you mean: 
-Mustafa_Onur-
Explorer
1,699

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. In this scenario, I will show you how to convert CSV file sent via SFTP to XML format. Unlike the previous examples, this time we will create ESR objects, but we will not write any code as in the previous examples.

 

There are some points I want to mention here :

  • Our service is an asynchronous service.
  • No special method or code was used when creating ESR objects.
  • There is no special setting used in the mapping section, all fields are mapped exactly

For example, let's say we have a CSV file named Units with the file content as follows:

Mustafa_Onur_5-1719157497551.png

We use message transform beans to convert our CSV file to XML format. 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...

First of all, what we need to do is to create ESR objects.The first important part is to create a Data Type :

Mustafa_Onur_6-1719157497555.png

The second important part is that while service interfaces are defined, they must be asynchronous:

Mustafa_Onur_7-1719157497557.png

After the ESR objects are created, we need an SFTP Sender channel that can convert the CSV format to into XML structure.

After entering SFTP information, ASMA settings are made as follows:

Mustafa_Onur_8-1719157497562.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 XML conversions:

Mustafa_Onur_9-1719157497566.png

Below you can find the modules and parameters we used:

 

localejbs/Custom_AF_Modules/MessageTransformBean                Local Enterprise Bean     Plain2XML

localejbs/CallSapAdapter                                                                 Local Enterprise Bean     entry

 

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

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

Plain2XML  xml.conversionType                              SimplePlain2XML 

Plain2XML  xml.documentName                             MT_TEST 

Plain2XML  xml.documentNamespace                    http://namespace/TEMPTEST

Plain2XML  xml.documentsSkipFirstRows              1 

Plain2XML  xml.endSeparator                                'nl' 

Plain2XML  xml.fieldNames  Necropolis,Inferno,Castle,Dungeon,Stronghold,Tower,Conflux,Fortress,Rampart,Neutral

Plain2XML  xml.fieldSeparator                                   ; 

Plain2XML  xml.processFieldNames                         fromConfiguration 

Plain2XML  xml.structureTitle                                    Record

 

After the procedures here, our file will be converted to XML format. After these steps, Integrated Configuration is created.

 

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. Field names must be in their original order in the CSV file to avoid shifting values.
  • When you open the CSV file with notepad, you will see which character separate the fields. We specify that character in the xml.fieldSeparator section. In this example, our character is a semicolon.
  • We used the value 'nl' for the xml.endSeperator field. nl stands for new line. Quotation marks must be used.

 

Thus, we can easily convert CSV file format to XML data without using any code.

Thank you, have a great day!

 

Labels in this area