- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Transforming XML file into fixed length flat file in SAP
This is an EDIfact invoice. Try using the script, and it can help −
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text" encoding="ISO-8859-1"/> <xsl:template match="/"> <!-- EDI_DC40 --> <xsl:for-each select="IDataXMLCoder/record/idatacodable/array/idatacodable/record/value"> <xsl:value-of select="text()"/> <xsl:choose> <!-- TABNAM (10) --> <xsl:when test="@name = 'TABNAM'"> <xsl:choose> <xsl:when test="string-length(text()) = 0"> <xsl:text></xsl:text> </xsl:when> <xsl:when test="string-length(text()) = 1"> <xsl:text></xsl:text> </xsl:when> <xsl:when test="string-length(text()) = 2"> <xsl:text></xsl:text> </xsl:when> <xsl:when test="string-length(text()) = 3"> <xsl:text></xsl:text> </xsl:when> <xsl:when test="string-length(text()) = 4"> <xsl:text></xsl:text> </xsl:when> <xsl:when test="string-length(text()) = 5"> <xsl:text></xsl:text> </xsl:when> <xsl:when test="string-length(text()) = 6"> <xsl:text></xsl:text> </xsl:when> <xsl:when test="string-length(text()) = 7"> <xsl:text></xsl:text> </xsl:when> <xsl:when test="string-length(text()) = 8"> <xsl:text></xsl:text> </xsl:when> <xsl:when test="string-length(text()) = 9"> <xsl:text></xsl:text> </xsl:when> <xsl:when test="string-length(text()) > 10"> <xsl:message terminate="yes">ERROR: The maximum length of "TABNAM" is 10 characters.</xsl:message> </xsl:when> <xsl:otherwise/> </xsl:choose> </xsl:when> <!-- MANDT (3)--> <xsl:when test="MANDT"> <xsl:choose> <xsl:when test="string-length(text()) = 0"> <xsl:text></xsl:text> </xsl:when> <xsl:when test="string-length(text()) = 1"> <xsl:text></xsl:text> </xsl:when> <xsl:when test="string-length(text()) = 2"> <xsl:text></xsl:text> </xsl:when> <xsl:when test="string-length(text()) > 3"> <xsl:message terminate="yes">ERROR: The maximum length of "MANDT" is 3 characters.</xsl:message> </xsl:when> <xsl:otherwise/> </xsl:choose> </xsl:when> <!-- DOCNUM (16) --> <!-- DOCREL (4) --> <!-- STATUS (4) --> <!-- etc. --> </xsl:choose> </xsl:for-each> <xsl:text>
</xsl:text> <!-- E1EDK01 --> <xsl:for-each select="IDataXMLCoder/record/idatacodable/array/idatacodable/array/idatacodable/record/value"> <xsl:value-of select="text()"/> <xsl:choose> <!-- ACTION (3) --> <xsl:when test="@name = 'ACTION'"> <xsl:choose> <xsl:when test="string-length(text()) = 0"> <xsl:text></xsl:text> </xsl:when> <xsl:when test="string-length(text()) = 1"> <xsl:text></xsl:text> </xsl:when> <xsl:when test="string-length(text()) = 2"> <xsl:text></xsl:text> </xsl:when> <xsl:when test="string-length(text()) > 3"> <xsl:message terminate="yes">ERROR: The maximum length of "ACTION" is 3 characters.</xsl:message> </xsl:when> <xsl:otherwise/> </xsl:choose> </xsl:when> <!-- KZABS (1)--> <xsl:when test="KZABS"> <xsl:choose> <xsl:when test="string-length(text()) = 0"> <xsl:text></xsl:text> </xsl:when> <xsl:when test="string-length(text()) > 1"> <xsl:message terminate="yes">ERROR: The maximum length of "KZABS" is 1 character.</xsl:message> </xsl:when> <xsl:otherwise/> </xsl:choose> </xsl:when> <!-- CURCY (3) --> <!-- HWAER (3) --> <!-- WKURS (12) --> <!-- etc. --> </xsl:choose> </xsl:for-each> </xsl:template> </xsl:stylesheet>
There are various sites which provide a built-in script to convert your EDIfact to XSLT. Check this site and it may also help −
https://www.codeproject.com/Articles/11278/EDIFACT-to-XML-to-Anything-You-Want
- Related Articles
- Using flat file load in SAP HANA database
- System measurement of SAP HANA system in XML file
- Using header rows during flat file upload in SAP HANA
- How to convert XML file into array in PHP?
- Exporting list of all SAP HANA systems in XML file
- Table type while importing data from flat file in SAP HANA
- Table mapping while data replication from flat file in SAP HANA database
- Different mapping options in SAP HANA while importing data from flat file
- Getting an error while previewing swf file from XML data in SAP Dashboard Designer
- Export Preferences to XML file in Java
- How to echo XML file in PHP
- Converting a file into a byte array in SAP ABAP
- How to read the XML file in PowerShell?
- What is a TestNG xml file in TestNG?
- How to get specific nodes in xml file in Python?

Advertisements