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 PM
I 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>
Similar Messages
-
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 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 -
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 youHello 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 -
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 -
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 -
Using XSLT to link XML and ABAP data
Hi Experts,
I am using XSLT to deal with XML and ABAP data.
I using the following statement to convert a Internal Table to XML String:
CALL TRANSFORMATION id SOURCE root = lt_sflight RESULT XML l_xml_string.
And I get the XML String:
<?xml version="1.0" encoding="utf-16" ?>
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<ROOT>
<SFLIGHT>
</SFLIGHT>
<SFLIGHT>
</SFLIGHT>
</ROOT>
</asx:values>
</asx:abap>
But What I expected is:
<?xml version="1.0" encoding="utf-16" ?>
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<ROOT>
<DATA>
</DATA>
<DATA>
</DATA>
</ROOT>
</asx:values>
</asx:abap>
Could you tell me how to get my dream format using XSLT?
Best Regards,
Guo Guo Qing
Edited by: guoqing guo on Jun 11, 2008 9:58 AMHi Experts,
I am using XSLT to deal with XML and ABAP data.
I using the following statement to convert a Internal Table to XML String:
CALL TRANSFORMATION id SOURCE root = lt_sflight RESULT XML l_xml_string.
And I get the XML String:
<?xml version="1.0" encoding="utf-16" ?>
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<ROOT>
<SFLIGHT>
</SFLIGHT>
<SFLIGHT>
</SFLIGHT>
</ROOT>
</asx:values>
</asx:abap>
But What I expected is:
<?xml version="1.0" encoding="utf-16" ?>
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<ROOT>
<DATA>
</DATA>
<DATA>
</DATA>
</ROOT>
</asx:values>
</asx:abap>
Could you tell me how to get my dream format using XSLT?
Best Regards,
Guo Guo Qing
Edited by: guoqing guo on Jun 11, 2008 9:58 AM -
XSLT transformation of XML string
Hello Everyone,
This is my first endeavor to use XSLT and XML in our newly upgraded system. I can't for the life of me figure out what is wrong with my code and would appreciate someone just glancing over it and pointing out what is likely a realy dumb problem.
I have a program that reads a PEXR2002 IDoc. For testing purposes, I've hardcoded that IDoc number. It runs fine, creates the XML fine, the xslt in STRANS tests fine as well...but in the end my ls_table is blank. I've been fuddling with this for a while and would really appreciate another pair of eyes taking a look at it.
THANKS!!
Greg
My program. (xslt is below...really simple, but it's my first time).
TYPES: BEGIN OF ty_table,
sndprn LIKE edidc-sndprn,
bgmref TYPE edif1004_r,
moabetr TYPE edif5004_a,
credat TYPE edidat8,
datum TYPE edidat8,
END OF ty_table.
DATA: o_idoc TYPE REF TO cl_idoc_xml1, str type string, ls_table type ty_table.
CREATE OBJECT o_idoc
EXPORTING
docnum = '0000000000211014'.
CALL METHOD o_idoc->get_xmldata_as_string
IMPORTING
data_string = str.
CALL TRANSFORMATION ZUSL_PEXR2002_V1
SOURCE XML str
RESULT HEADER_DATA = ls_table.
My XSLT....
<xsl:transform
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:asx="http://www.sap.com/abapxml"
xmlns:sap="http://www.sap.com/sapxsl" version="1.0">
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<asx:abap version="1.0">
<asx:values>
<HEADER_DATA>
<SNDPRN>
<xsl:value-of select="PEXR2002/IDOC/EDI_DC40/SNDPRN"/>
</SNDPRN>
<BGMREF>
<xsl:value-of select="PEXR2002/IDOC/E1IDKU1/BGMREF"/>
</BGMREF>
<MOABETR>
<xsl:value-of select="PEXR2002/IDOC/E1IDKU5/MOABETR"/>
</MOABETR>
<CREDAT>
<xsl:value-of select="PEXR2002/IDOC/EDI_DC40/CREDAT"/>
</CREDAT>
<DATUM>
<xsl:value-of select="PEXR2002/IDOC/E1EDK03/DATUM"/>
</DATUM>
</HEADER_DATA>
</asx:values>
</asx:abap>
</xsl:template>
</xsl:transform>Hi Greg,
please try it with the following (just slightly) modified transformation (works fine for me):
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:asx="http://www.sap.com/abapxml"
xmlns:sap="http://www.sap.com/sapxsl"
version="1.0">
<xsl:strip-space elements="*"/>
<xsl:template match="/PEXR2002/IDOC">
<asx:abap version="1.0">
<asx:values>
<HEADER_DATA>
<SNDPRN>
<xsl:value-of select="EDI_DC40/SNDPRN"/>
</SNDPRN>
<BGMREF>
<xsl:value-of select="E1IDKU1/BGMREF"/>
</BGMREF>
<MOABETR>
<xsl:value-of select="E1IDKU5/MOABETR"/>
</MOABETR>
<CREDAT>
<xsl:value-of select="EDI_DC40/CREDAT"/>
</CREDAT>
<DATUM>
<xsl:value-of select="E1EDK03/DATUM"/>
</DATUM>
</HEADER_DATA>
</asx:values>
</asx:abap>
</xsl:template>
</xsl:transform>
I recommend to test all transformations that you define on a sample source and check the output. If you apply your original transformation you would see that it basically doesn't select anything and therefore you just get an XML document with the field names but no values.
Cheers, harald -
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 Transform in XML Signature: Exception
Hello,
I have following problem with an XSLT tranform in my XML signature. Here is the code I use to add XSLT to signature:
main() {
DOMStructure stylesheet = new DOMStructure( getStylesheet() );
XSLTTransformParameterSpec spec = new XSLTTransformParameterSpec( stylesheet );
transforms.add( fac.newTransform( Transform.XSLT, spec ) );
private Element getStylesheet() throws Exception {
String stylesheet = //"<?xml version=\"1.0\"?>" +
"<xslt:stylesheet version=\"1.0\" xmlns:xslt=\"http://www.w3.org/1999/XSL/Transform\">\n" +
" <xsl:include href=\"http://extern XSLT\" />\n" +
" <xslt:template match=\"/\">" +
" <xsl:apply-imports />" +
" </xslt:template>" +
"</xslt:stylesheet>\n";
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
//dbf.setValidating( true );
return dbf.newDocumentBuilder().parse( new ByteArrayInputStream( stylesheet.getBytes() ) ).getDocumentElement();
I get following exception:
javax.xml.crypto.dsig.XMLSignatureException: javax.xml.crypto.dsig.TransformException: com.sun.org.apache.xml.internal.security.transforms.TransformationException: Cannot find xslt:stylesheet in Transform
Original Exception was com.sun.org.apache.xml.internal.security.transforms.TransformationException: Cannot find xslt:stylesheet in Transform
at org.jcp.xml.dsig.internal.dom.DOMReference.transform(Unknown Source)
at org.jcp.xml.dsig.internal.dom.DOMReference.digest(Unknown Source)
at org.jcp.xml.dsig.internal.dom.DOMXMLSignature.digestReference(Unknown Source)
at org.jcp.xml.dsig.internal.dom.DOMXMLSignature.sign(Unknown Source)
In google I cannot find any details what can be wrong.
Any suggestions?
Thanks in advance,
errnoThanks for your response. Sorry - I tried both versions with xslt and xsl - doesn't worked -> the error in my post is actually caused through the multiple changes of this part of code. Here once again:
private Element getStylesheet() throws Exception {
String stylesheet = //"<?xml version=\"1.0\"?>" +
"<xslt:stylesheet version=\"1.0\" xmlns:xslt=\"http://www.w3.org/1999/XSL/Transform\">\n" +
" <xslt:include href=\"external XSLTl\" />\n" +
" <xslt:template match=\"/\">" +
" <xslt:apply-imports />" +
" </xslt:template>" +
"</xslt:stylesheet>\n";
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
//dbf.setValidating( true );
return dbf.newDocumentBuilder().parse( new ByteArrayInputStream( stylesheet.getBytes() ) ).getDocumentElement();
Thanks,
errno -
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 -
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. -
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 -
Error in ABAP XSLT transformation
Hi,
Im trying to upload some data from XML to abap. But Im getting an error while transforming xml data to internal table.
Here are the details.
XML:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!-- Edited by XMLSpy® -->
<?xml-stylesheet type="text/xsl" href="ABAP1.xsl"?>
<conceptRevDecisionXml>
<projectInfo>
<projectId>P000755</projectId>
<stage>CON</stage>
<country>Ethiopia</country>
<region>AFRICA</region>
<teamleader>Priya Agarwal</teamleader>
<teamleaderfirstname>Priya</teamleaderfirstname>
<teamleaderlastname>Agarwal</teamleaderlastname>
<actionType>X</actionType>
</projectInfo>
</conceptRevDecisionXml>
XSLT: Transformation
<xsl:transform version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:sapxsl="http://www.sap.com/sapxsl"
>
<xsl:strip-space elements="*"></xsl:strip-space>
<xsl:template match="/">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<PROJID>
<xsl:apply-templates select="//conceptRevDecisionXml"></xsl:apply-templates>
</PROJID>
</asx:values>
</asx:abap>
</xsl:template>
<xsl:template match="conceptRevDecisionXml">
<xsl:for-each select="projectInfo">
<xsl:value-of select="projectId"></xsl:value-of>
<xsl:value-of select="stage"></xsl:value-of>
<xsl:value-of select="country "></xsl:value-of>
<xsl:value-of select="region"></xsl:value-of>
<xsl:value-of select="teamleader"></xsl:value-of>
<xsl:value-of select="teamleaderfirstname"></xsl:value-of>
<xsl:value-of select="teamleaderlastname"></xsl:value-of>
<xsl:value-of select="actionType"></xsl:value-of>
</xsl:for-each>
</xsl:template>
</xsl:transform>
Once I run the program...Im getting an error saying...ABAP XML Formatting error in XML node..
Im new to ABAP-XML parsing..Pls help me where Im going wrong..
Thanks in advance.
Regards,
PriyaHi Priya,
you can try with the below,
1) Create a local ITAB with the structure of the XML,
TYPES: BEGIN OF t_data,
projectid TYPE char30,
stage TYPE char30,
country TYPE char30,
region TYPE char30,
teamleader TYPE char30,
teamleaderfirstname TYPE char30,
teamleaderlastname TYPE char30,
actiontype TYPE char30,
END OF t_data.
2) Create an XSLT prog in "STRANS" with the below code,
<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="/">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<L_DATA>
<xsl:apply-templates select="//projectInfo"/>
</L_DATA>
</asx:values>
</asx:abap>
</xsl:template>
<xsl:template match="projectInfo">
<conceptRevDecisionXml>
<PROJECTID>
<xsl:value-of select="projectId"/>
</PROJECTID>
<STAGE>
<xsl:value-of select="stage"/>
</STAGE>
<COUNTRY>
<xsl:value-of select="country"/>
</COUNTRY>
<REGION>
<xsl:value-of select="region"/>
</REGION>
<TEAMLEADER>
<xsl:value-of select="teamleader"/>
</TEAMLEADER>
<TEAMLEADERFIRSTNAME>
<xsl:value-of select="teamleaderfirstname"/>
</TEAMLEADERFIRSTNAME>
<TEAMLEADERLASTNAME>
<xsl:value-of select="teamleaderlastname"/>
</TEAMLEADERLASTNAME>
<ACTIONTYPE>
<xsl:value-of select="actionType"/>
</ACTIONTYPE>
</conceptRevDecisionXml>
</xsl:template>
</xsl:transform>
3) Call the transformation as shown below,
CALL TRANSFORMATION zxslt_project ---> "Name of the XSLT prog created above
SOURCE XML l_xml_str ---> Source XML string
RESULT l_data = l_data. ---> ITAB as in step 1 above
Regards,
Chen -
Automatic insert of xmlns:xsl during XSLT transformation
I am using the xmlparserv2.jar of dated "12/10/00" to perform a XSLT transformation. I need to insert a xml:space="preserve" attribute to a generated tag. However, there is an addition attribute added : xmlns:xml="http://www.w3/org/XML/1998/namespace". How can I suppress the generation of this attribute ?
Here is my XML :
<?xml version = '1.0' standalone = 'no'?>
<COLDdoc>
<Page template="bkgnd1" num="1">
<Line num="1"> CN011A021C 1A021</Line>
<Line num="2"> 1954.90 7713.36</Line>
</Page>
</COLDdoc>
My XSL is :
<?xml version = '1.0' standalone = 'yes'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="no" doctype-system="svg-20000303-stylable.dtd"/>
<xsl:template match="Line">
<text>
<xsl:attribute name="x">0</xsl:attribute>
<xsl:attribute name="y">
<xsl:value-of select="@num*10"/>
</xsl:attribute>
<xsl:attribute name="xml:space">preserve</xsl:attribute>
<xsl:value-of select="."/>
</text>
</xsl:template>
</xsl:stylesheet>
The result XSLT Transformation :
<?xml version = '1.0' encoding = 'UTF-8'?>
<!DOCTYPE text SYSTEM "svg-20000303-stylable.dtd">
<text x="0" y="10" xmlns:xml="http://www.w3/org/XML/1998/namespace" xml:space="preserve"> CN011A021C 1A021</text>
<text x="0" y="20" xmlns:xml="http://www.w3/org/XML/1998/namespace" xml:space="preserve"> "> 1954.90 7713.36</text>
Regards.
Jeffrey
nullHi Greg,
please try it with the following (just slightly) modified transformation (works fine for me):
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:asx="http://www.sap.com/abapxml"
xmlns:sap="http://www.sap.com/sapxsl"
version="1.0">
<xsl:strip-space elements="*"/>
<xsl:template match="/PEXR2002/IDOC">
<asx:abap version="1.0">
<asx:values>
<HEADER_DATA>
<SNDPRN>
<xsl:value-of select="EDI_DC40/SNDPRN"/>
</SNDPRN>
<BGMREF>
<xsl:value-of select="E1IDKU1/BGMREF"/>
</BGMREF>
<MOABETR>
<xsl:value-of select="E1IDKU5/MOABETR"/>
</MOABETR>
<CREDAT>
<xsl:value-of select="EDI_DC40/CREDAT"/>
</CREDAT>
<DATUM>
<xsl:value-of select="E1EDK03/DATUM"/>
</DATUM>
</HEADER_DATA>
</asx:values>
</asx:abap>
</xsl:template>
</xsl:transform>
I recommend to test all transformations that you define on a sample source and check the output. If you apply your original transformation you would see that it basically doesn't select anything and therefore you just get an XML document with the field names but no values.
Cheers, harald
Maybe you are looking for
-
Oracle Replication - Encrypted Data and Oracle Data Guard
We are working on a high availability architecture for one of our new projects. The preliminary architecture has Oracle 10g Release 2(10.2.0.2) production database (primary database) running on Solaris10 server for OLTP operations. And a production r
-
Auto create final assembly orders
when autocreate final assembly order is run for configured item its creating work order for parent assembly only. its not creating work order for sub assemblies involved in that parent assembly. even after setting in BOM parameters, create lower leve
-
Organization unit in process modeler
In process modeler I have created stores, like SUPPLIERS, INVOICES, which will be entities. I placed them in the unspecified organization unit. It is better to create a new organization unit like IT_DATABASE? Is an IT_DATABASE an organization unit? W
-
Ok, I've had it. I have tried to set up a new theme for my site to hopefully overwrite all material on MobileMe, I am currently in the process of erasing all my site data on the remote disk, and still, when I publish, it goes for a long time, and the
-
Hi guys I have a .txt file. In that file the data are stored like "$341ACF12341ACF12341ACF12341ACF12341" now I want to read the next 128 bytes after that "$" character ?? How to execute that?? Thanks in advance Niladri Solved! Go to Solution.