cancel
Showing results for 
Search instead for 
Did you mean: 

How to create manual XSD schema from fixed-length text file?

aehoster
Explorer
0 Kudos

Hello experts,

I am trying to manually create an XSD schema from a fixed-length text file to upload as a source schema in message mapping. The target schema was provided on the API hub in a WSDL file. Since the TXT file does not have any headers attached, what would be the best way to do this? I know the field names, starting points and lengths, but I am unsure of how to format the schema from the TXT file.

Any guidance on this would be greatly appreciated.

Thanks,

Alex

Accepted Solutions (1)

Accepted Solutions (1)

AdityaMani
Participant
0 Kudos

Hi,

There is no standard way to convert Fixed length file to xml in SAP CPI, You need to write script. Refer to below sample blog-

https://blogs.sap.com/2019/02/14/convert-flat-file-into-xml/

Once xml is created through groovy then you can create xsd through online tool xml to xsd converter.

Regards,

Aditya

aehoster
Explorer
0 Kudos

If I use this method to create my source schema, will the xsd used in the message mapping still read the fixed-length txt payload, or will the file have to be converted in the iFlow?

Answers (1)

Answers (1)

VijayKonam
Active Contributor
0 Kudos

Use https://www.convertcsv.com/csv-to-xml.htm. You need to use random headers to be used for XML element names. You may want to create a dummy header like field1, field2 etc. Then convert the flat file to XML. Then use the XML to generate XSD using online tools.

Or you could simply use CPI iFlow to convert CSV to XML. Then use the XML to generate XSD using similar online tools.

aehoster
Explorer
0 Kudos

Thanks for the response Vijay. How can I start the process you're recommending from the fixed-length TXT file? How can I transform one line of the TXT file into a CSV to get to the following steps of transforming the format of the file to XML then XSD?