Skip to Content
Author's profile photo Former Member

Xml to Text conversion made easy by StrictXml2PlainBean

h3.  New module on the block : Often we come across a requirement to convert XML to text. The module *StrictXml2PlainBean* has made our life easier to do that conversion. *StrictXml2PlainBean* module can be used to convert an XML document in the main payload of the XI message to text format. Within an XML document, different recordset types can be displayed either separately or with a fixed field length (mixed display). The structure of the XML document is checked based on the entries you make in the module. If any structures are found in document that do not correspond to your definition, a processing error is triggered at runtime. h3. _An example is worth a thousand words :_  Lets take a simple example to understand the usability of this module. Lets assume a scenario for converting an XML data to a asterisk separated TEXT file, wherein we don’t need any data transformation between source and target and we have same number of fields under the different recordsets. *+Input XML :+* image Before the module came,  to convert the above xml to text format, we needed to specify a separate  File Content Conversion for “_Customer_” and for “_ContactInfo_ “. But now we can replace our File Content Conversion with the *StrictXml2PlainBean* module.  The module provides more conversion options and a check of the structure that is to be converted h3. _Lets see how :_ *Step 1: *In your receiver File Communication channel, select the message protocol as “File” and fill the rest of the information needed for your receiver file CC. 

*Step 2:* Go to the_Module tab in your CC_ and insert the module in front of the adapter module as shown in the screen shot.  �›       Enter the module name _AF_Modules/StrictXml2PlainBean_. �›       Select the module type _Local Enterprise Bean._       The default module key is displayed. ( In our case its 1, as highlighted) *Step 3:* In the module configuration, enter the parameter names and parameter values for the module key 1 of the module. Here comes the exciting part. As we can see that in our example we have same number of fields in the “Customer” as well as in the “ContactInfo”, we can use the parameter Name “*singleRecordType*” and avoid defining the parameters twice for the different recordset. _Module Key: 1 _ Parameter Name : *singleRecordType* _Parameter Value : dataRec_ *Step 4:*  For the asterisk separator, define the following parameters in your module configuration.  As we have defined “*SingleRecordType*” in the above step, all the parameters we will be defined in our module configuration will be applicable to all recordsets. _Module Key: 1_ _Parameter Name : dataRec.fieldSeparator _  Parameter Value : *

 

image

Assigned Tags

      13 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member
      Author's profile photo Former Member
      Former Member
      Hi Tuhin,

      Thanks for your point. I corrected the blog.  Actually I referred the below PI7.1 document

      http://help.sap.com/saphelp_nwpi71/helpdata/en/44/75bdab7b2618e8e10000000a1553f7/frameset.htm

      and as for the module it says...XML to Text Conversion Module (NEW), I thought its a newly added module in PI7.1

      Thanks,
      Pooja Pandey

      Author's profile photo Prateek Raj Srivastava
      Prateek Raj Srivastava
      Hi Pooja,

      Thanks for sharing the content. However, this feature was available with PI 7.0 too. You may add this as a note in your blog.

      Best Regards,
      Prateek

      Author's profile photo Former Member
      Former Member
      Thanks you raising this point. I have updated the blog. I think, I misconstrued one help document.

      Thanks,
      pooja Pandey

      Author's profile photo Former Member
      Former Member
      Great blog Pooja, even if it was already available...It helps people like myself who have just started learning XI...

      Trevor

      Author's profile photo Former Member
      Former Member
      Thanks Trevor 🙂
      Author's profile photo Former Member
      Former Member
      Nice explanation and easily understood by dumb like me 🙂

      One more thing..... Tag line at the end ..is Good and true.!!!

      Thanks
      Gaurav

      Author's profile photo Former Member
      Former Member
      Thanks for your feedback Gaurav.

      As I dint find any sdn blog for the module, I thought there was no harm in highlighting the module :).

      ^Pooja^

      Author's profile photo Former Member
      Former Member
      Hi Pooja,
      I have a similar payload as you've shown in the example but when I use the module, my text file is being created but it is empty. I donno why.Please help me out if possoble.
      Regards.
      Author's profile photo Former Member
      Former Member
      Hi mates, i'm trying to work with to configure the comm channel moduele: StrictXML2PlainBean. But when i test it, the sxmb_moni only gives me the same message response: NameNotFoundException: Object not found in lookup of StrictXML2PlainBean.

      Some one knows something about the reason of this issue?
      Thanks in advance.

      Author's profile photo Former Member
      Former Member
      hi,

      please use StrictXml2PlainBean instead of StrictXML2PlainBean (check camel case).

      Cheers,
      alex

      Author's profile photo Former Member
      Former Member

      Hi Pooja,USA13<br/>0110Preeti25<br/>0220David30<br/>0210109, Briarcliff roadAtlanta, GA, 30889<br/>02201009, Marshal StreetAtlanta, GA, 30007<br/><br/>I want the whole "Store" segment to have "01" begin segment and the segments inside will have "02*". It returns me an error "Invalid structure name encountered during conversion: Store at XML element MT_Src_File,Store". <br/><br/>Regards,<br/>Kevin

      Author's profile photo Former Member
      Former Member
      I want the output to be:

      01*USA*13
      02*10*Preeti*25
      02*20*David*30
      02*10*109, Briarcliff road*Atlanta, GA, 30889
      02*20*1009, Marshal Street*Atlanta, GA, 30007