cancel
Showing results for 
Search instead for 
Did you mean: 

Receiving XML file and convertion it into text

Former Member
0 Kudos

Hi Friends,

I am working on scenario in which I wll be receiving as XML file of format something like :

<PaymentInfoMessageResponse> - Root node

<PaymentInfoResponse> - Section containing the tags related to the MT940 data.

<TransactionType dt:dt=u201Dstringu201D> - 940 for all banking statements

<SequenceNum dt:dt=u201DIntu201D> - Unique number generated by SHB.

<ReceiptTime dt:dt=u201DdateTimeu201D> - Banking Statements receipt time

<ProcessStatus dt:dt=u201Dstringu201D> - Process Status usually u20181u2019

<Comment dt:dt=u201Dstringu201D> - String field containing any comments.

<TransactionData dt:dt=u201Dstringu201D> - String field containing the MT940 formatted data.

<CompanyCode dt:dt=u201Dstringu201D> - the partner identifier

<StatusCode dt:dt=u201Dstringu201D> - Status code for the above XML document. Usually OK status.

I want to convert the data in tag <TransactionData dt:dt=u201Dstringu201D> into a txt file and same it in a folder.

Which will be the best and simpler way to do it ?

Accepted Solutions (1)

Accepted Solutions (1)

former_member181962
Active Contributor
0 Kudos

Have a target message structure something like

Root Node

Record (0:unbounded)

data

map the record node to the TransactionData node

and map the value in the TransactionData field to data.

Follow the steps here to convert the XML to text using receiver file adapter:

http://help.sap.com/saphelp_nwpi71/helpdata/en/44/686e687f2a6d12e10000000a1553f6/content.htm

Regards,

Ravi

Former Member
0 Kudos

Hi Ravi,

So first i need to create structure like that to receive message .

And my creating structure, what I understand is by using data types in IR..Am i correct with these?

this question might sound stupid.. bt m very new with XI...

thanks...

former_member200962
Active Contributor
0 Kudos

Hi,

data types in IR

Yes you will need data type in IR.

what you will need:

1) data type to represent the xml format (coming from source if it is not an IDOC, RFC, BAPI, WSDL)

2) data type to represent the target elements...as you need only one element in the target file you can have your DT as:

<DT_Target>

<Field/> (of type string)

</DT_Target>

And then in the configuration part use the file adapter on the receiver side...

Regards,

Abhishek.

former_member181962
Active Contributor
0 Kudos

Please proceed as Abhishek suggested.

To get started, this might be useful:

http://www.sap-xi.com/sap-xi-scenarios-file-file.html

Regards,

Ravi

Former Member
0 Kudos

Hi!

It think you are doing the scenario which is nothing but..XML to TEXT scenario right ?

If that is the case you can achive your requirement very simply with this module.

Please go through the blog written by pooja which is very nice one. Such that remaining all other steps are fine I mean same as usual 2 data types  , 2 message types , 2Syn Interfaces , 2 message mappings
one Interface mappings at which told by earlier is exactly correct and alsor remaining ID part is also same but only diff is Tranport protocol as File instead of FCC and include this module in the Sender File cc module tab: **StrictXml2PlainBean*

[https://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/13292] [original link is broken] [original link is broken] [original link is broken];

[http://help.sap.com/saphelp_nwpi71/helpdata/en/44/748d595dab6fb5e10000000a155369/frameset.htm]

I hope this will be useful to you.

Regards::

Amar Srinivas Eli

Edited by: Amar Srinivas Eli on Apr 1, 2009 4:12 PM

Former Member
0 Kudos

I am trying module StrictXml2PlainBean to convert xml file to text file.

I am refering to link

http://help.sap.com/saphelp_nw70/helpdata/en/44/748d595dab6fb5e10000000a155369/frameset.htm and

/people/pooja.pandey/blog/2009/02/23/xml-to-text-conversion-made-easy-by-strictxml2plainbean

but still not able to do it. What I did is , I configure a simple file to file scenario in which one xml file is transfered from one folder to another. after in receiving comm channel, in module tab i had given name as

AF_Modules/StrictXml2PlainBean and in module configuration I had provided 2 entries,

dataRec.fieldSeparator *

singleRecordType dataRec

after this when I am puttin xml file in sender folder,it is being picked up, bt it is not coming on destination folder.

I am not sure,what this dataRec means here.

Please suggest, how can i solve this issue.

Former Member
0 Kudos

Hi! Brajesh,

What exactly Ravi told is correct.

See in the blog I have give..:: STep 3 and Step 4 he carefully mentioned that::

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 : *

Note:: See actually there instead of dataRec you need to give your Record Set name okay.

See the help documentation given in the above reply.

In the remainder of this documentation the parameters are specified by the prefix <RecordType>. In your configuration, replace this name with the name of the recordset type.

All these data's is there in the help doc...I am giving from there only.

Add Parameters in the Module Configuration::

○ If you want to define a different type of conversion for each recordset type that occurs in the XML document, specify the following:

■ Under Parameter Name, enter recordTypes.

■ Under Parameter Value, enter the complete, comma-separated list of all names of recordset types that occur in the document to be converted.

For example, you could name the recordset types as follows: RecordType1,RecordType2,RecordType3.

○ If you want to define the same type of conversion for all recordset types that occur in the XML document, specify the following:

■ Under Parameter Name, enter singleRecordType.

■ Under Parameter Value, enter the name of a recordset type that is to be used to convert all elements that occur in the XML document.

Regards::

Amar Srinivas Eli

Answers (2)

Answers (2)

Former Member
0 Kudos

Thanks All

former_member181962
Active Contributor
0 Kudos

Hi Brijesh,

Did you try the steps in the link that I have provided? Its much simpler.

If your target strucure is somethinglike this:

<Root>

<Record>

<Data></Data>

</Record>

</Root>

Then in your receiver file adapter, Just chose File Content Conversion option.

And specify:

Record.endSeparator = nl

That is sufficient.

Regards,

Ravi

Former Member
0 Kudos

Hi Ravi ,

I tried it, bt was didnt worked. I m nt sure where i m making mistake.

On receiver comm channel,i selected file content conversion

and in content conversion tab, i had given Record Structure = PaymentInfoResponse

PaymentInfoResponse.endSeparator = nl

xml file that i wan to convert is like this,

<?xml version="1.0" encoding="UTF-8" ?>

- <ns0:mtsender xmlns:ns0="https:/green.com">

- <PaymentInfoResponse>

<TransactionType>MT940</TransactionType>

<SequenceNum>1</SequenceNum>

<ReceiptTime>1</ReceiptTime>

<ProcessStatus>1</ProcessStatus>

<Comment>1</Comment>

<TransactionData>asdasd brijesh soni</TransactionData>

<CompanyCode>1000</CompanyCode>

</PaymentInfoResponse>

<StatusCode>OK</StatusCode>

</ns0:mtsender>

Former Member
0 Kudos

Hi! Brajesh,

What exactly the status in the MONI ?

Is it showing success payload in moni and u r unable to see the output file in the FTP target location or else.. provide the errror once.

Also check have you u created the target folder already if not check the radio button of create target directory at Receiver File adapter.

okay

Regards::

Amar Srinivas Eli

Former Member
0 Kudos

Moni is showing success... target folder is also created.

I m getting error in communication channel monitoring, error is :

Message processing failed. Cause: com.sap.aii.af.modules.conversion.xml2plain.ConversionException: No data is allowed on this structure level (2) at XML element mtsender,StatusCode

Detail of error is as follows :

2009-04-02 14:55:34 Success The message was successfully retrieved from the receive queue.

2009-04-02 14:55:34 Success The message status set to DLNG.

2009-04-02 14:55:34 Success Delivering to channel: rec_comc2

2009-04-02 14:55:34 Success MP: Entering module processor

2009-04-02 14:55:34 Success MP: Processing local module localejbs/AF_Modules/StrictXml2PlainBean

2009-04-02 14:55:34 Success Starting strict XML to plain text conversion

2009-04-02 14:55:34 Error MP: Exception caught with cause com.sap.aii.af.modules.conversion.xml2plain.ConversionException: No data is allowed on this structure level (2) at XML element mtsender,StatusCode

2009-04-02 14:55:34 Error Exception caught by adapter framework: No data is allowed on this structure level (2)

2009-04-02 14:55:34 Error Delivery of the message to the application using connection File_http://sap.com/xi/XI/System failed, due to: com.sap.aii.af.ra.ms.api.RecoverableException: No data is allowed on this structure level (2): com.sap.aii.af.modules.conversion.xml2plain.ConversionException: No data is allowed on this structure level (2) at XML element mtsender,StatusCode.

I think i had done some mistake in IR..jst goin through it...

Edited by: brijesh soni on Apr 2, 2009 2:05 PM

Former Member
0 Kudos

Hey

No need to use that message transform bean when you have message protocol FCC.

Provide your target Message type used and also your FCC parameter s then its easier to find out whats wrong

Check the below link

http://help.sap.com/saphelp_nw70/helpdata/en/0b/9a50465ccf84479e39a6d50c90fb3f/frameset.htm

Rajesh

Edited by: Rajesh on Apr 2, 2009 5:34 PM

Former Member
0 Kudos

Hi rajesh,

the error msg thn i mention above was whn i dnt use FCC and jst go with that module..

Former Member
0 Kudos

Hi!

As per the blog This module you can use after SP 9 because this feature is available from PI 7.0 SP09.

Also please check you version once.Or else may be some issue with your java stack. Previously I faced similar type of issue when I am doing File to RFC to File without BPM by using module in the module tab of File sender CC later after 12 days after clearing issue with java stack it worked fine.

this may be also one reason.

Regards::

Amar Srinivas Eli

Former Member
0 Kudos

thanks amar, i wll try to look at that all problems...