Writing XSLT to perform transformation from XML to ABAP
Hi,
I've been struggling quite a bit with XSLT. I read several old discussions regarding transformations using ST and XSLT but I haven't been able to solve my problem.
I have a requirement to build a program to convert XML to an internal table.
I've been able to do it for smaller XMLs, but whenever I try to apply the same logic to a bigger XML it simply just doesn't work. I'm almost certain it has something to do with the way I wrote the XSLT but I haven't been able to figure out what.
The XML I have to read from goes something like this:
<?xml version="1.0" encoding="WINDOWS-1252"?>
-<AuditFile xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:OECD:StandardAuditFile-Tax:PT_1.02_01">
-<Header xmlns="urn:OECD:StandardAuditFile-Tax:PT_1.02_01">
<AuditFileVersion>1.02_01</AuditFileVersion>
<CompanyID>50002</CompanyID>
<TaxRegistrationNumber>5000</TaxRegistrationNumber>
<TaxAccountingBasis>F</TaxAccountingBasis>
<CompanyName>Company</CompanyName>
<BusinessName>Business</BusinessName>
-<CompanyAddress>
<AddressDetail>Address</AddressDetail>
<City>city</City>
<PostalCode>333333</PostalCode>
<Country>PT</Country>
</CompanyAddress>
<FiscalYear>2013</FiscalYear>
<StartDate>2013-07-01</StartDate>
<EndDate>2013-07-31</EndDate>
<CurrencyCode>EUR</CurrencyCode>
<DateCreated>2013-08-02</DateCreated>
<TaxEntity>Global</TaxEntity>
<ProductCompanyTaxID>00</ProductCompanyTaxID>
<SoftwareCertificateNumber>00</SoftwareCertificateNumber>
<ProductID>product</ProductID>
<ProductVersion>00</ProductVersion>
<Email>email@com</Email>
<Website>www.s.pt</Website>
</Header>
-<MasterFiles xmlns="urn:OECD:StandardAuditFile-Tax:PT_1.02_01">
-<Customer>
<CustomerID>1</CustomerID>
<AccountID>ID</AccountID>
<CustomerTaxID>999999990</CustomerTaxID>
<CompanyName>Desconhecido</CompanyName>
-<BillingAddress>
<AddressDetail>Desconhecido</AddressDetail>
<City>Desconhecido</City>
<PostalCode>0000-000</PostalCode>
<Country>PT</Country>
</BillingAddress>
<SelfBillingIndicator>0</SelfBillingIndicator>
</Customer>
-<Customer>
<CustomerID>2</CustomerID>
<AccountID>Desconhecido</AccountID>
<CustomerTaxID>571</CustomerTaxID>
<CompanyName>Company</CompanyName>
-<BillingAddress>
<AddressDetail>detail</AddressDetail>
<City>city</City>
<PostalCode>0000-000</PostalCode>
<Country>PT</Country>
</BillingAddress>
<SelfBillingIndicator>0</SelfBillingIndicator>
</Customer>
...and so on
And the XSLT I've written so far is something like this:
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output encoding="iso-8859-1" indent="yes" method="xml" version="1.0"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<ICUSTOMER>
<xsl:apply-templates select="//Customer"/>
</ICUSTOMER>
</asx:values>
</asx:abap>
</xsl:template>
<xsl:template match="Customer">
<item>
<CUSTOMER_ID>
<xsl:value-of select="CustomerID"/>
</CUSTOMER_ID>
<ACCOUNT_ID>
<xsl:value-of select="AccountID"/>
</ACCOUNT_ID>
<CUSTOMERTAX_ID>
<xsl:value-of select="CustomerTaxID"/>
</CUSTOMERTAX_ID>
<COMPANYNAME>
<xsl:value-of select="CompanyName"/>
</COMPANYNAME>
<ADDRESSDETAIL>
<xsl:value-of select="BillingAddress/AddressDetail"/>
</ADDRESSDETAIL>
<CITY>
<xsl:value-of select="BillingAddress/City"/>
</CITY>
<POSTALCODE>
<xsl:value-of select="BillingAddress/PostalCode"/>
</POSTALCODE>
<COUNTRY>
<xsl:value-of select="BillingAddress/Country"/>
</COUNTRY>
<SELFBILLINGINDICATOR>
<xsl:value-of select="SelfBillingIndicator"/>
</SELFBILLINGINDICATOR>
</item>
</xsl:template>
</xsl:transform>
Like I said, I'm almost certain that the problem is with the XSLT, as it returns an empty table / ALV. I've used this method before and it worked...
Any thoughts?
Thank you
Hello Goncalo,
I think, there are two problems:
1) The xmlns declaration within your xml is a problem for the SAP XSLT Processor.
2) I have written a similar XSLT-report, which performs directly with your data. Perhaps this is not necessary if 1) is solved:
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output encoding="iso-8859-1" indent="yes" method="xml" version="1.0"/>
<xsl:strip-space elements="*"/>
<xsl:template match="AuditFile">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<xsl:apply-templates select="MasterFiles"/>
</asx:values>
</asx:abap>
</xsl:template>
<xsl:template match="MasterFiles">
<ICUSTOMER>
<xsl:apply-templates select="./Customer"/>
</ICUSTOMER>
</xsl:template>
<xsl:template match="Customer">
<CUSTOMER_ID>
<xsl:value-of select="CustomerID"/>
</CUSTOMER_ID>
<ACCOUNT_ID>
<xsl:value-of select="AccountID"/>
</ACCOUNT_ID>
<CUSTOMERTAX_ID>
<xsl:value-of select="CustomerTaxID"/>
</CUSTOMERTAX_ID>
</xsl:template>
</xsl:transform>
Kind regards,
Hendrik
Similar Messages
-
XSLT Transformation from XML to ABAP field
Hi all,
How can I retrieve my XML node's value (EMPLOYEE) XML to an ABAP variable (W_KUNNR)
DATA w_kunnr TYPE string.
CONCATENATE
'<services>'
'<Myservice>'
'<APPLICATION>APPLI1</APPLICATION>'
'<SERVICE>SERV1</SERVICE>'
'<TOSAP>'
'<EMPLOYEE>00000036</EMPLOYEE>'
'</TOSAP>'
'</Myservice>'
'</services>'
INTO request.
CALL TRANSFORMATION z_trans
SOURCE XML request
RESULT kunnr = w_kunnr.
thanks.
Edited by: Noureddine MOUTAA on Oct 28, 2008 2:25 PMI did like this:
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output encoding="iso-8859-1" indent="yes" method="xml" version="1.0"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<KUNNR>
<xsl:value-of select="//services/Myservice/TOSAP/EMPLOYEE"/>
</KUNNR>
</asx:values>
</asx:abap>
</xsl:template>
</xsl:transform> -
I need help writing and XSLT to transform an XML in InDesign. I am new to XML and have no idea how to write an XSLT.
We are trying to bring in data from a database using a query language that is having trouble creating the image tags the way we need it to. Basically, I need to take this:
<Project href="file://C:\My test phot.jpg">
and transform it into this:
<Project> <image href="file://C:\My test phot.jpg" />
Can anyone help me with this?
Thanks!Not sure I can help you with this, as my understanding of XSL is very limited.
However, as a matter of trial and error, I find that if I transform this XML:
<?xml version="1.0" encoding="UTF-8"?>
<Root>
<Project href="file://C:\My test phot1.jpg">The first bit of textual content here</Project>
<Project href="file://C:\My test phot2.jpg">The second bit of textual content here</Project>
<Project href="file://C:\My test phot3.jpg">The third bit of textual content here</Project>
<Project href="file://C:\My test phot4.jpg">The fourth bit of textual content here</Project>
<Project href="file://C:\My test phot5.jpg">The fifth bit of textual content here</Project>
</Root>
...with this XSLT:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<Root>
<xsl:for-each select="/Root/Project">
<Project>
<image><xsl:attribute name="href"><xsl:value-of select="@href"/></xsl:attribute></image>
<xsl:value-of select="."/>
</Project>
</xsl:for-each>
</Root>
</xsl:template>
</xsl:stylesheet>
...I end up with this XML:
<?xml version="1.0" encoding="UTF-8"?>
<Root>
<Project><image href="file://C:\My test phot1.jpg"/>The first bit of textual content here</Project>
<Project><image href="file://C:\My test phot2.jpg"/>The second bit of textual content here</Project>
<Project><image href="file://C:\My test phot3.jpg"/>The third bit of textual content here</Project>
<Project><image href="file://C:\My test phot4.jpg"/>The fourth bit of textual content here</Project>
<Project><image href="file://C:\My test phot5.jpg"/>The fifth bit of textual content here</Project>
</Root>
...which seems what you're looking for.
[I edited the original solution slightly by removing a wildcard.] -
XSLT transformation for XML to ABAP internal table
Hi, can anyone please tell me how it should be the xslt tranformation to conver this xml
<Embargos_ARBA_DOC>
<ns:Embargos_ARBA_MT
xmlns:ns="un:swissmedical:sap:proxy:embargos_arba:file">
<Embargos_ARBA_MT>
<FECHA>20081101</FECHA>
<CUIT>50000002124</CUIT>
<MONTO>0000013794090</MONTO>
<RAZON_SOCIAL>RAUL ARMANDO CUNQUEIRO S.A.C.I.</RAZON_SOCIAL>
</Embargos_ARBA_MT>
<Embargos_ARBA_MT>
<FECHA>20081101</FECHA>
<CUIT>55000001456</CUIT>
<MONTO>0000001144410</MONTO>
<RAZON_SOCIAL>PARODI ESTEBAN ARMANDO</RAZON_SOCIAL>
</Embargos_ARBA_MT>
</ns:Embargos_ARBA_MT>
</Embargos_ARBA_DOC>
to this abap Table....
DATA: BEGIN OF i_embargos_arba_doc occurs 0,
fecha TYPE d,
cuit TYPE char11,
monto TYPE char13,
razon_social(120),
END OF i_embargos_arba_mt.
so i can transform it with this sentence
CALL TRANSFORMATION ('embargos_transformation')
SOURCE XML source
RESULT Embargos_ARBA_DOC = embargos.
pls i need help because i am unable to create this xslt transformation...
I will give the highest rewards points to the one who can help me.
thanks!
marianoHi Mariano
Why you need to use XSLT for transforming XML file into ABAP table
Code is a part of some ABAP report. Looks like it is reading a file from file system and updating table after transformation
If you have requirement like you need to read XML file and then insert the data into a SAP table
You can use
File to RFC
File to Proxy scenario using SAP PI.
Please provide more inputs on requirement to help
Thanks
Gaurav -
XSLT Transformation from XML to CVS format
I am using the following xsl sheet in conjunction with the XSLSample.java application delivered with xdk and cannot get the output I desire. Does Orcales xsl processor output text documents?
XSL:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:apply-templates select="ROWSET/ROWS[1]/*" mode="elementNames"/>
<xsl:apply-templates select="ROWSET/ROWS"/>
</xsl:template>
<xsl:template match="*" mode="elementNames">
<xsl:value-of select="name()"/>
<xsl:choose>
<xsl:when test="position() != last()">,</xsl:when>
<xsl:otherwise>
<xsl:text>
</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="ROW">
<xsl:apply-templates select="*"/>
</xsl:template>
<xsl:template match="*">
<xsl:if test="contains(.,' ')">"</xsl:if>
<xsl:value-of select="."/>
<xsl:if test="contains(.,' ')">"</xsl:if>
<xsl:choose>
<xsl:when test="position() != last()">,</xsl:when>
<xsl:otherwise>
<xsl:text>
</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
XML:
<?xml version = '1.0'?>
<ROWSET>
<ROW num="1">
<CUST_ID>1000000009</CUST_ID>
<NAME1>Pineview Preschool</NAME1>
<ITEM>0000000007</ITEM>
<POST_DATE>01/02/2001</POST_DATE>
<ENTRY_TYPE>PY</ENTRY_TYPE>
<DOCUMENT> </DOCUMENT>
</ROW>
<ROW num="2">
<CUST_ID>1000000006</CUST_ID>
<NAME1>Cellular One</NAME1>
<ITEM>0000000008</ITEM>
<POST_DATE>01/02/2001</POST_DATE>
<ENTRY_TYPE>PY</ENTRY_TYPE>
<DOCUMENT> </DOCUMENT>
</ROW>
</ROWSET>
Any help for this xsl beginner would be greatly appreciated.
null<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Steven Muench ([email protected]):
The problem is likely that you are incorrectly using:
[b]DocumentFragment processXSL(xsl,xml)
instead of the other API:
void processXSL(xsl,xml,PrintWriter)
the latter allows the XSLT engine to do its <xsl:output> serialization behavior. The former does not.<HR></BLOCKQUOTE>
Thanks Steve,
I am now doing that. How can I get rid of the top level xml tag that prints out after applying the xsl sheet. I need a simple text file with just the data.
Thanks,
Jeff
null -
Set file name with XSLT - receiver channel - elements from XML?
Dear experts,
I have an XSLT mapping for a message that is sent via a receiver channel to a customer.
The customer wants a certain file name which is put toghether by elements from the XML message.
I have looked at:
Re: Java Map for writing the file
The java code and the XSLT work perfectly!
In the line
fos = new FileOutputStream(new File("Fixed_" + new Date().getTime() + ".xml"));
a fixed value, date and time are used for the file name.
But I need some values from the XML message to create my name. But how do I do that? Can I somehow get values from the XML message through that java function or do I have to adapt the XSLT?
Can someone please help me!
Thank you,
PeterHi Udo, Hello experts,
Now I do have a problem. I am using this XSL file:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:map="java:java.util.Map"
xmlns:dyn="java:com.sap.aii.mapping.api.DynamicConfiguration"
xmlns:key="java:com.sap.aii.mapping.api.DynamicConfigurationKey">
<xsl:output indent="no" />
<xsl:param name="inputparam"/>
<xsl:template match="/">
<!-- change dynamic configuration -->
<xsl:variable name="dynamic-conf"
select="map:get($inputparam, 'DynamicConfiguration')" />
<xsl:variable name="dynamic-key"
select="key:create('http://sap.com/xi/XI/System/File', 'FileName')" />
<xsl:variable name="dummy"
select="dyn:put($dynamic-conf, $dynamic-key, 'TOOLDATA_.xml')" />
<xsl:copy-of select="." />
</xsl:template>
</xsl:stylesheet>
But then the output file is only named "TOOLDATA_.xml". So I assume the XSL is working.
And I am using this Java-file:
package pi_mappings;
import com.sap.aii.mapping.api.*;
import java.io.*;
import java.util.*;
public class SetFileName extends AbstractTransformation
static final int BUFFER = 1024*1000;
private Map param;
public SetFileName(){ }
public void setParameter (Map map)
param = map;
if (param == null)
param = new HashMap();
public static void main(String args[])
try
InputStream in = new FileInputStream(args[0]);
OutputStream out = new FileOutputStream(args[1]);
SetFileName sfn = new SetFileName();
//sfn.setParameter(mapOfMap);
sfn.execute(in, out);
catch (Exception e)
e.printStackTrace();
public void execute(InputStream inputstream, OutputStream outputstream)
throws StreamTransformationException {
try
DynamicConfiguration conf = (DynamicConfiguration) param.get("DynamicConfiguration");
DynamicConfigurationKey KEY_FILENAME = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
int len = 0;
byte buf[] = new byte[BUFFER];
FileOutputStream fos = null;
if (conf != null)
fos = new FileOutputStream(new File(conf.get(KEY_FILENAME) + new Date().getTime()) ); //sample only
else
fos = new FileOutputStream(new File("Fixed_" + new Date().getTime() + ".xml"));
while ((len = inputstream.read(buf)) > 0)
outputstream.write(buf, 0, len);
fos.write(buf, 0, len);
fos.close();
catch(Exception e){ e.printStackTrace();}
public void transform(TransformationInput arg0, TransformationOutput arg1)
throws StreamTransformationException {
getTrace().addInfo("JAVA Mapping Called");
this.execute(arg0.getInputPayload().getInputStream(), arg1
.getOutputPayload().getOutputStream());
Could you please help me find the mistake. I tried to test it locally by changing the main-method but I could not get it to work.
Thank you very much for any ideas!
Best regards,
Peter -
Default XSLT Stylesheet to transform BW XML Data?
I'm currently working on a deafult XSLT Stylesheet to convert a BW XML Query Result Set into an html grid.
[code]
<!--
#==========================================================================
XSL Transformation that displays
Template Properties, List of Data Providers and List of Items
#==========================================================================
-->
<xml id="xsl_transform_1">
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:variable name="header">
<tr bgcolor="white"> <xsl:for-each select="//RRWS_SX_TUPLE[1]/*">
<td>
<xsl:value-of select="local-name()"/>
</td>
</xsl:for-each>
</tr>
</xsl:variable>
<xsl:template match="/">
<table bgcolor="gold" border="1">
TESTVALUE -
<tr>
<xsl:copy-of select="$header" /> <xsl:apply-templates />
</tr>
<xsl:for-each select="//RRWS_SX_TUPLE">
<tr>
<td><xsl:value-of select="TUPLE_ORDINAL"/></td>
<xsl:for-each select="//RRWS_S_CELL">
<td><xsl:value-of select="CELL_ORDINAL"></td>
</xsl:for-each>
<td><xsl:value-of select="TUPLE_ORDINAL"/></td>
<td><xsl:value-of select="CHANM"/></td>
<td><xsl:value-of select="CAPTION"/></td>
<td><xsl:value-of select="CHAVL"/></td>
<td><xsl:value-of select="CHAVL_EXT"/></td>
<td><xsl:value-of select="NIOBJNM"/></td>
<td><xsl:value-of select="TLEVEL"/></td>
<td><xsl:value-of select="DRILLSTATE"/></td>
<td><xsl:value-of select="OPT"/></td>
<td><xsl:value-of select="SIGN"/></td>
<td><xsl:value-of select="ATTRIBUTES"/></td>
</tr>
<xsl:for-each select="//RRWS_S_CELL">
<tr>
<td><xsl:value-of select="CELL_ORDINAL"/></td>
<td><xsl:value-of select="VALUE"/></td>
<td><xsl:value-of select="FORMATTED_VALUE"/></td>
<td><xsl:value-of select="VALUE_TYPE"/></td>
<td><xsl:value-of select="CURRENCY"/></td>
<td><xsl:value-of select="UNIT"/></td>
<td><xsl:value-of select="MWKZ"/></td>
<td><xsl:value-of select="NUM_SCALE"/></td>
<td><xsl:value-of select="NUM_PREC"/></td>
<td><xsl:value-of select="CELL_STATUS"/></td>
<td><xsl:value-of select="BACK_COLOR"/></td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
<xsl:template match="RRWS_S_CELL/*">
<td> <xsl:value-of select="." /> </td>
</xsl:template></xsl:stylesheet>
</xml>
[/code]
I've started this, but I need to join the top tree with the bottom. Right now I'm just flattening the tree. Does anyone know if any work has been done in this area? I'm looking to create these XSLT Transforms. Also, I'd like to create generic javascript functions that I can use as an include, such as
function join_BW_Table(table1, table2, fieldtojoin, typeofjoin)
This would allow anyone to generically combine BW Data from multiple sources all on the FrontEnd and render it all as an html table. My ultimate goal would be have all this in includes and available for all BW Reporting. Anyone have any thoughts on:
1. Has this been done before?
2. If it hasn't, anyone have comments on how I can combine the 2 tables that I'm rendering with the attached XSLT transform?
I'm running these transforms via a javscript function on the load of the html page.
PrakashPrakash,
did you ever compile the Stylesheet? I am looking for an alternative way to format the pre-compiled XML file from the Report Designer. The more complex my report is, the less robust the application becomes.
Your insight would be greatly appreciated.
Thank you -
About transformation from xml to html
Hello all, I have just learnt xml for a week.
I am preparing to use servlet and Jsp to convert xml to html,
but I wonder how to make the convertion.
Since the xml source is not in well design,
I would like to ask what does the suitable way to do.
The xml source is about the typesetting in a page.
<book> element indicate a book
<page> - element indicate a page
attribute:
id - id of the page
height - height of the page
width - width of the page
<area> element indicate a area
attribute:
pos - in the form of "x1, y1, x2, y2",
(x-coordindate starting from left side of the page)
(y coordinate starting form top side oft the page)
<line> element indicate a line
attribute:
start - the x-coordinate, starting from left
width - the width of the line
<words> element indicate a word
attribute:
top - the y-coordinate, starting from top
height - the height of the words
all of them are defined as empty tag, except <book>
example:
<book>
<page id=1 height=100, width=200/>
<area pos"10,10,20,20"/>
<line start=11 width=5/>
<words top=11, height=5>
word1
<words top=16, height=2/>
word2
<page id=2 height=100, width=250/>
</book>
I would like to transfer page, area, line+words into 3 different of layer in html.
I have try to use xslt style sheet (xsl),
but I find difficulty getting information from element to form a layer and building up the template.
For example, how can I get attributes info from two elements and generate a layer(html).
Or, does it better to do the transformation in servlet and read the xml as a DOM tree?
Furthermore, I would like to ask does it need much time to convert source to html,
as there is nearly 4 thousand line in a xml file?
Thanks!!Steve tks for Your suggestions, but my problem is a little different from the one You illustrate (or I didn't understand well Yur suggestion).
1 - I don't use BC4J in this project
2 - I don't need to insert data in the DB but only receive the data from an HTML form as a XML Document.
I understand the idea You gave me would be a good basis for the solution but I don't understand how I can apply it.
TIA
Tullio -
XSLT transformation in XML to ABAP: special characters issue
Hi,
I am parsing well-formed XML file that has the following data (:
<projects><project><name>Wallis & Futuna</name></project></projects>
I use XSLT transformation:
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sap="http://www.sap.com/sapxsl" version="1.0">
<xsl:strip-space elements="*"/>
<xsl:template match="projects">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<PROJECTS>
<xsl:for-each select="project">
<PROJECT>
<NAME>
<xsl:value-of select="name"/>
</NAME>
</PROJECT>
</xsl:for-each>
</PROJECTS>
</asx:values>
</asx:abap>
</xsl:template>
</xsl:transform>
If I use the above example without &amp; everything works fine, but the original XML fails with exception CX_XSLT_DESERIALIZATION_ERROR and message "Error during deserialization". Googling around did not give an answer.
Any words of wisdom?
Edited by: Alexei Isaev on Apr 26, 2011 5:04 AM
Edited by: Alexei Isaev on Apr 26, 2011 5:05 AMHi,
Please visit the following link for reference.
http://help.sap.com/abapdocu_70/en/ABAPCALL_TRANSFORMATION.htm
Thanks & Regards,
Harish -
Tuxedo Response Transformation from XML to FML
Request flow :Tuxedo -> OSB Proxy Service > OSB Business Serivice >Target Web Service.
Response flow : Target Web Service send response to -> Business Service ->OSB Proxy serivice (Transforma the Complex XML to FML) ->send to Tuxedo Client.
i have following response form webserive call
<StudentList>
<Student universitytype="AU " accurrence = 'undbounded'>
<stdname>
<stdyear>
<stdscore>
<Student/>
<Student universitytype="AU " accurrence = 'undbounded'>
<stdname>
<stdyear>
<stdscore>
<Student/>
<Student universitytype="MIT" accurrence = 'undbounded'>
<stdname>
<stdyear>
<stdscore>
<Student/>
<Student universitytype="AO " accurrence = 'undbounded'>
<stdname>
<stdyear>
<stdscore>
<Student/>
<StudentList/>
can i transform above complexity form of XML to FML using XmlFmlCnv Class and send it to Tuxedo
Since FML is flat strucured, i am not sure how the Complex tyHello,
It depends on the release of WebLogic and the field table definitions used by WTC (and Tuxedo).
I believe embedded/nested FML32 fields were added to XmlFmlCnv in WLS 9.0 (but the doc needs to be updated).
Have you tried this yet?
Regards,
Bob Finan -
XML to ABAP Structure transformation
Hi SAP,
Can anyone tell how to transform from XML to ABAP structure. The ABAP structure i'm getting in runtime.
Please do the needful.
Thanks in advance
Vinod.using XSLT or ST you can do that check this thread
https://forums.sdn.sap.com/click.jspa?searchID=5585367&messageID=1661688
and also search ABAP forum for more code samples -
Simple Transformation XML to ABAP - error CX_ST_MATCH_ELEMENT
Hi all,
I have a problem with a transformation from xml to abap. My XML file (taken from a pdf file) is
<?xml version="1.0" encoding="iso-8859-1" ?>
- <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
- <asx:values>
<NETWORK>E60000000000</NETWORK>
<OPERAZIONE>0010</OPERAZIONE>
- <TABELLA>
- <ROW xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/" xfa:dataNode="dataGroup">
<MANDT>300</MANDT>
<NETWORK>E60000000000</NETWORK>
<OPERAZIONE>0010</OPERAZIONE>
<ID_ACT>1</ID_ACT>
<DESC_ACT>ATTIVITÀ1</DESC_ACT>
<LONG_TXT></LONG_TXT>
<MAKE_BUY></MAKE_BUY>
<WP></WP>
<EVENTO_TECH></EVENTO_TECH>
<TIPO_LEGAME></TIPO_LEGAME>
<CONSEGNA></CONSEGNA>
</ROW>
- <ROW xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/" xfa:dataNode="dataGroup">
<MANDT>300</MANDT>
<NETWORK>E60000000000</NETWORK>
<OPERAZIONE>0010</OPERAZIONE>
<ID_ACT>2</ID_ACT>
<DESC_ACT>ATTIVITÀ2</DESC_ACT>
<LONG_TXT>ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2</LONG_TXT>
<MAKE_BUY>M</MAKE_BUY>
<WP></WP>
<EVENTO_TECH></EVENTO_TECH>
<TIPO_LEGAME></TIPO_LEGAME>
<CONSEGNA></CONSEGNA>
</ROW>
</TABELLA>
</asx:values>
</asx:abap>
my transformation is
<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
<tt:root name="ROOT"></tt:root>
<tt:root name="NETWORK"></tt:root>
<tt:root name="OPERAZIONE"></tt:root>
<tt:template>
<abap>
<values>
<network>
<tt:value ref="NETWORK"></tt:value>
</network>
<operazione>
<tt:value ref="OPERAZIONE"></tt:value>
</operazione>
<tabella>
<tt:loop ref=".ROOT" name="line">
<mandt>
<tt:value ref="$line.mandt"></tt:value>
</mandt>
<network>
<tt:value ref="$line.network"></tt:value>
</network>
<OPERAZIONE>
<tt:value ref="$line.OPERAZIONE"></tt:value>
</OPERAZIONE>
<ID_ACT>
<tt:value ref="$line.ID_ACT"></tt:value>
</ID_ACT>
<DESC_ACT>
<tt:value ref="$line.DESC_ACT"></tt:value>
</DESC_ACT>
<LONG_TXT>
<tt:value ref="$line.LONG_TXT"></tt:value>
</LONG_TXT>
<MAKE_BUY>
<tt:value ref="$line.MAKE_BUY"></tt:value>
</MAKE_BUY>
<WP>
<tt:value ref="$line.WP"></tt:value>
</WP>
<EVENTO_TECH>
<tt:value ref="$line.EVENTO_TECH"></tt:value>
</EVENTO_TECH>
<TIPO_LEGAME>
<tt:value ref="$line.TIPO_LEGAME"></tt:value>
</TIPO_LEGAME>
<CONSEGNA>
<tt:value ref="$line.CONSEGNA"></tt:value>
</CONSEGNA>
</tt:loop>
</tabella>
</values>
</abap>
</tt:template>
</tt:transform>
when I execute my code
the system dump with this error
ST_MATCH_FAIL
excep. CX_ST_MATCH_ELEMENT
TRY.
CALL TRANSFORMATION ('ZT_NETWORK')
SOURCE XML lv_xml_data_string
RESULT network = l_network
operazione = l_operazione
root = it_data_tmp.
CATCH cx_sy_conversion_data_loss .
CATCH cx_xslt_exception INTO xslt_error.
xslt_message = xslt_error->get_text( ).
WRITE:/ xslt_message .
ENDTRY.
Any help?
thanks
enzoEnzo Porcasi wrote:
> I have a problem with a transformation from xml to abap. My XML file (taken from a pdf file) is
>
<?xml version="1.0" encoding="iso-8859-1" ?>
> <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
> <asx:values>
Your XML is strange, it looks like a mix of pdf form content (xfa) and identity transformation (asx).
Could you explain more ?
Anyway, I tried to find out the errors (not only cx_st_match_element, that was just a catch missing), it works with the following program. Here are the main issues I have found :
- always catch exception class cx_st_error when you use simple transformations (it contains cx_st_match_element and all other simple transformation exceptions)
- xml "asx:abap" and "asx:values" in your input XML are useless, they are only used by identity transformation ("ID"); you may keep them if you want, but I advise you to see why they are in the xml !
- Use same case in your tags (if xml contains in the transformation so that it corresponds to the input XML
- I renamed all abap names with prefix ABAP_ so that to clearly differentiate xml tags and abap field names (so that it is more easy to understand, for every sdn reader; I hope it will help as I didn't find many threads in the forum).
Simple transformation :
<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
<tt:root name="ABAP_NETWORK"></tt:root>
<tt:root name="ABAP_OPERAZIONE"></tt:root>
<tt:root name="ABAP_TABELLA"></tt:root>
<tt:template>
<ROOT>
<NETWORK>
<tt:value ref=".ABAP_NETWORK"></tt:value>
</NETWORK>
<OPERAZIONE>
<tt:value ref=".ABAP_OPERAZIONE"></tt:value>
</OPERAZIONE>
<TABELLA>
<tt:loop ref=".ABAP_TABELLA" name="line">
<ROW>
<MANDT>
<tt:value ref="$line.ABAP_MANDT"></tt:value>
</MANDT>
<NETWORK>
<tt:value ref="$line.ABAP_NETWORK"></tt:value>
</NETWORK>
<OPERAZIONE>
<tt:value ref="$line.ABAP_OPERAZIONE"></tt:value>
</OPERAZIONE>
<ID_ACT>
<tt:value ref="$line.ABAP_ID_ACT"></tt:value>
</ID_ACT>
<DESC_ACT>
<tt:value ref="$line.ABAP_DESC_ACT"></tt:value>
</DESC_ACT>
<LONG_TXT>
<tt:value ref="$line.ABAP_LONG_TXT"></tt:value>
</LONG_TXT>
<MAKE_BUY>
<tt:value ref="$line.ABAP_MAKE_BUY"></tt:value>
</MAKE_BUY>
<WP>
<tt:value ref="$line.ABAP_WP"></tt:value>
</WP>
<EVENTO_TECH>
<tt:value ref="$line.ABAP_EVENTO_TECH"></tt:value>
</EVENTO_TECH>
<TIPO_LEGAME>
<tt:value ref="$line.ABAP_TIPO_LEGAME"></tt:value>
</TIPO_LEGAME>
<CONSEGNA>
<tt:value ref="$line.ABAP_CONSEGNA"></tt:value>
</CONSEGNA>
</ROW>
</tt:loop>
</TABELLA>
</ROOT>
</tt:template>
</tt:transform>
Program and XML included :
REPORT zsro2.
DATA l_network TYPE string.
DATA l_operazione TYPE string.
DATA : BEGIN OF lt_data_tmp OCCURS 0,
abap_mandt TYPE string,
abap_network TYPE string,
abap_operazione TYPE string,
abap_id_act TYPE string,
abap_desc_act TYPE string,
abap_long_txt TYPE string,
abap_make_buy TYPE string,
abap_wp TYPE string,
abap_evento_tech TYPE string,
abap_tipo_legame TYPE string,
abap_consegna TYPE string,
END OF lt_data_tmp.
DATA xslt_error TYPE REF TO cx_xslt_exception.
DATA lo_st_error TYPE REF TO cx_st_error.
DATA lv_xml_data_string TYPE string.
DATA xslt_message TYPE string.
DEFINE conc.
concatenate lv_xml_data_string &1 into lv_xml_data_string.
END-OF-DEFINITION.
*conc '<?xml version="1.0" encoding="iso-8859-1" ?>'.
*conc '<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">'.
*conc ' <asx:values>'.
conc ' <ROOT>'.
conc ' <NETWORK>E60000000000</NETWORK> '.
conc ' <OPERAZIONE>0010</OPERAZIONE> '.
conc ' <TABELLA>'.
conc ' <ROW xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/" xfa:dataNode="dataGroup">'.
conc ' <MANDT>300</MANDT> '.
conc ' <NETWORK>E60000000000</NETWORK> '.
conc ' <OPERAZIONE>0010</OPERAZIONE> '.
conc ' <ID_ACT>1</ID_ACT> '.
conc ' <DESC_ACT>ATTIVITÀ1</DESC_ACT> '.
conc ' <LONG_TXT></LONG_TXT> '.
conc ' <MAKE_BUY></MAKE_BUY> '.
conc ' <WP></WP> '.
conc ' <EVENTO_TECH></EVENTO_TECH> '.
conc ' <TIPO_LEGAME></TIPO_LEGAME> '.
conc ' <CONSEGNA></CONSEGNA> '.
conc ' </ROW>'.
conc ' <ROW xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/" xfa:dataNode="dataGroup">'.
conc ' <MANDT>300</MANDT> '.
conc ' <NETWORK>E60000000000</NETWORK> '.
conc ' <OPERAZIONE>0010</OPERAZIONE> '.
conc ' <ID_ACT>2</ID_ACT> '.
conc ' <DESC_ACT>ATTIVITÀ2</DESC_ACT> '.
conc ' <LONG_TXT>ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2</LONG_TXT> '.
conc ' <MAKE_BUY>M</MAKE_BUY> '.
conc ' <WP></WP> '.
conc ' <EVENTO_TECH></EVENTO_TECH> '.
conc ' <TIPO_LEGAME></TIPO_LEGAME> '.
conc ' <CONSEGNA></CONSEGNA> '.
conc ' </ROW>'.
conc ' </TABELLA>'.
conc ' </ROOT>'.
*conc ' </asx:values>'.
*conc '</asx:abap>'.
DATA lv_xml_data_string_2 TYPE string.
TRY.
CALL TRANSFORMATION zsro
SOURCE
XML lv_xml_data_string
RESULT
abap_network = l_network
abap_operazione = l_operazione
abap_tabella = lt_data_tmp[].
CATCH cx_sy_conversion_data_loss .
CATCH cx_st_error INTO lo_st_error.
xslt_message = lo_st_error->get_text( ).
WRITE:/ xslt_message .
CATCH cx_xslt_exception INTO xslt_error.
xslt_message = xslt_error->get_text( ).
WRITE:/ xslt_message .
ENDTRY.
BREAK-POINT. -
Can i use XSD / XML in Abap Programs
Hi friends
I need to validate a xml file against xsd file. Can i validate it in abap program?
Best Regards.
PHi Pedro,
Simple transformations, or ST, is a proprietary SAP programming language that describes the transformation of ABAP data to XML (serialization) and from XML to ABAP data (deserialization).
Check this out...
Simple Transformations - SAP Library
Regards,
Raj
<dead link corrected>
Message was edited by: Manish Kumar -
Hello,
From a provider we get the following XSD from a response message:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://xxx" targetNamespace="http://yyy">
<xsd:element name="loginResponse" type="loginResponse" />
<xsd:complexType name="loginResponse">
<xsd:sequence>
<xsd:element name="result" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
His actual response looks like this:
<SOAP-ENV:loginResponse
xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'
xmlns:SOAPENC='http://schemas.xmlsoap.org/soap/encoding/'
xmlns:xsd='http://www.w3.org/2001/XMLSchema'
xmlns:xsi='http://www.w3.org/2001/XMLSchema-Instance'>
<Result xsi:type='xsd:string'>artv8uv38gvqu05gjohv26g8l5</Result>
</SOAP-ENV:loginResponse>
PI accepts this well, but during the conversion from XML to ABAP we get the following error:
PARSE_APPLICATION_DATA Error during XML => ABAP conversion (Response Message; error ID: CX_ST_MATCH_ELEMENT; (/1SAI/TXS3656E9BD8
Error during XML => ABAP conversion (Response Message; error ID: CX_ST_MATCH_ELEMENT; (/1SAI/TXS3656E9BD8A34AE8B7F16 XML Bytepos
Element 'loginResponse' verwacht
I have the impression that there is a problem with the namespace and wonder how I can solve this. I do not know enough about XML to judge if the returned XML is valid according to the definition. Maybe the problem lies there.
Thanks for any help.
KrisYou are right. The error is the root node:
SOAP-ENV:loginResponse
This prefix is not allowed.
It should be something like this:
<loginResponse xmlns="http://xxx"
Edited by: Stefan Grube on Aug 23, 2010 4:35 PM -
BI Admin Tool and XSLT transformation for XML data source - How it works ?
Hello,
There is a possibility to import data from XML data source using BI Admin Tool.
In the import window we can point XSLT file. What is the purpose of that XSLT field?
Why I am asking ?
I thought it is smth like XSLT processor, but simply it doesnt work.
What I did:
- I pointed XML data source file
- I pointed XSLT transformation file
- Click OK, and still get the message that the XML file structure is not supported
After that I transformed that XML file with some desktop XSLT processor using the same XSLT file, and I tried to connect that file directly using BI Admin tool.Then it works. So it means that the transformation is ok.
So basically one question comes to my mind in that situation:
What is the purpose of XSLT field in BI Admin Tool when it comes to XML data source ?
(it doesnt look like XSLT processor)
Greetings
/MichalHi Mariano
Why you need to use XSLT for transforming XML file into ABAP table
Code is a part of some ABAP report. Looks like it is reading a file from file system and updating table after transformation
If you have requirement like you need to read XML file and then insert the data into a SAP table
You can use
File to RFC
File to Proxy scenario using SAP PI.
Please provide more inputs on requirement to help
Thanks
Gaurav
Maybe you are looking for
-
Error (102) while updating the software. Solution please?
I'm encountering an error (102) while updating my software to 10.8.4. I need a solution?
-
HT1212 if i restore my ipod will it erase my itunes library on my computer
if i restore my ipod will it erase my itunes library on my computer
-
Somehow when I plugged my I phone into my sons Macbook i synched all of his info to my phone. Now his contacts and pics are on my phone and mine are lost. Any way I can get mine back?
-
To find the Biztalk Active and Dehydrated instances using powershell script
Hi, Has anyone has the power shell script to finf the number of active and dehydrated instances in Biztalk?
-
How can i program ftp details to access my web site to upload a single html file. ta.