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,721

Hello everyone,

I hope everything is all right and well. In my previous articles, I shared with you how to create some scenarios on PI/PO without using ESR objects. I will show you how to convert the XML structure sent via SOAP or Proxy to CSV format this time. Unlike the previous examples, we will create ESR objects this time, but we will not write any code as in the previous examples.

While doing these operations, we will use Message Transform Bean again. You can find a few blogs about this on the internet, but Mr. Engswee's blogs are the more understandable ones I have read so far. You can access his blog about Message Transform Bean below:

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

We have no problem sending data in XML structure as Soap or Proxy. That's why we won't use any special methods when creating ESR objects.

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.

Below you can find the example data in XML structure:

<Record>

      <Necropolis>Power Lich</Necropolis>

      <Inferno>Efreet Sultan</Inferno>

      <Castle>Crusader</Castle>

      <Dungeon>Minotaur King</Dungeon>

      <Stronghold>Ancient Behemoth</Stronghold>

      <Tower>Titan</Tower>

      <Conflux>Magma Elemental</Conflux>

      <Fortress>Greater Basilisk</Fortress>

      <Rampart>Gold Dragon</Rampart>

      <Neutral>Azure Dragon</Neutral>

   </Record>

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_1-1719005550406.png

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

Mustafa_Onur_2-1719005568576.png

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

We chose Units as the file name :

Mustafa_Onur_3-1719005588373.png

From here, we go directly to the Module tab without making any changes (We did not use ASMA in this service). Then, by entering the following module and parameters in the module tab, we perform format conversion on the SFTP receiver channel:

Mustafa_Onur_4-1719005604291.png

Below you can find the modules and parameters we used:

1        localejbs/AF_Modules/MessageTransformBean     Local Enterprise Bean        <XML2Plain>

2        localejbs/ModuleProcessorExitBean                     Local Enterprise Bean        exit

 

<XML2Plain>  Transform.Class              com.sap.aii.af.sdk.xi.adapter.Conversion

<XML2Plain>  Transform.ContentType   text/xml;charset=utf-8 

<XML2Plain>  xml.addHeaderLine          1 

<XML2Plain>  xml.conversionType         SimpleXML2Plain 

<XML2Plain>  xml.fieldNames  Necropolis,Inferno,Castle,Dungeon,Stronghold,Tower,Conflux,Fortress,Rampart,Neutral 

<XML2Plain>  xml.fieldSeparator            ; 

<XML2Plain>  xml.processFieldNames  fromConfiguration 

exit  JNDIName  deployedAdapters/com.sap.aii.adapter.sftp.ra/shareable/com.sap.aii.adapter.sftp.ra

 

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

There are some points I want to mention here :

  • We gave the value 1 to the xml.addHeaderLine field. In this way, we will see the field names we set in the DT section in the CSV file. If we set the value here to 0, the CSV file will contain only the given values.
  • We gave the semicolon value to the xml.fieldSeparator section. This is completely optional. You can also use comma or pipe values ​​instead. This parameter is used mandatory and only a single value can be given. If we used fromConfiguration in the processFieldNames section, we define the field names.
  • Field names in the XML structure are defined in the xml.fieldNames parameter. When defining field names, care should be taken that they are the same as the field names in the XML structure. Additionally, the field names must be in their original order to avoid a shift in values.
  • If you give the fromConfiguration value for the xml.processFieldNames parameter, you have to use the xml.fieldNames parameter.
  • If you use the fromFile value here, you do not need to use the xml.fieldNames parameter. Field names will be detected automatically. However, since field names were not detected in some services where I used the fromFile value, I gave the fromConfiguration value instead.

 

After these steps, our CSV file will be created without any problems.

Mustafa_Onur_5-1719005620033.png

Below you can see our file converted to CSV format:

Mustafa_Onur_6-1719005628690.png

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

Thank you, have a great day!

Labels in this area