on 11-30-2005 2:00 PM
I can get an XML file that contains a structure like
<order>
<onumber>12345</onumber>
<customer>
<name>Miller</name>
<street>XY Street</street>
<city>Bristol</city>
</customer>
<object>
<orderno>12345678</orderno>
<quant>5</quant>
<color>...</color>
...
</object>
...
</order>
But to import it into BW I need something like
<order>
<onumber>12345</onumber>
<i>Delete <customer></i>
<name>Miller</name>
<street>XY Street</street>
<city>Bristol</city>
<i>Delete </customer></i>
<i>Delete <object></i>
<orderno>12345678</orderno>
<quant>5</quant>
<color>...</color>
...
<i>Delete </object></i>
...
</order>
Is there any way to do this transformation from the BW side, e.g. by changing the generated function module?
Best regards
Dirk
It answers about 80%. The question is, how do I call the transformation XSL? Does the sender of the XML need to send a request to the XSL first, then send the receiving XSL to me? Or is there a chance that the XSL sends the generated XML automatically to my SOAP address?
Best regards
Dirk
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hello dirk,
i don't have any idea of you current system landscape.
you mentioned as well in your post as modifying the
"generated" function module in order to import it to BW.
i assume that you are getting your data from a different
source, transform it and import it to your BW generated FM.
is this the scenario? or is it the generated BW FM that
retrieves the XML from the source directly?
case1:
if you have an intermediate program which requests
for the data from a different source, you can extend your
program to do the transformation prior to importing it
to your BW.
case2:
if your BW FM is directly retrieving the data from a
source, you might need to modify that FM to transform
your XML data prior to importing.
i cannot give you the details on the code level as i
don't have any details on which scenario you are working
on. anyway, here's how to do it in java.
import javax.xml.transform.*;
import java.io.*;
public class TransformOrderXML {
public static void main(String[] args) {
try {
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer =
tFactory.newTransformer
(new javax.xml.transform.stream.StreamSource
("order.xsl"));
transformer.transform
(new javax.xml.transform.stream.StreamSource
("order.xml"),
new javax.xml.transform.stream.StreamResult
( new FileOutputStream("output.xml")));
}
catch (Exception e) {
e.printStackTrace( );
}
}
}
the output.xml is the resulting xml which you will be
importing to your BW FM.
hope this helps.
regards
jo
create the XLST program in SE80.
when the external systems call BW via soap protocol it will hit the following path
http://<BWSERVER>.doamin.com:<port>/sap/bc/srt/rfc/sap/<webservice name>
creat a custom http handler and attach it to the above service in txn SICF
you can create a custom http handler class implementing IF_HTTP_EXTENSION interface and in the method HANDLE_REQUEST use call transformation to convert the XML from one format to another fromat .
for more on writing custom http handler you can refer
/people/brian.mckellar/blog/2003/09/30/bsp-in-depth-writing-an-http-handler
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/p-r/real web services with rest and icf.article
Regards
Raja
Hi Dirk,
why do U not put XI in between?
Do the transformation in XI before sending the data via Proxy to BW. This interface will have the best quality of service.
reg.
michael
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hello dirk,
here's an xsl.
-
order.xsl -
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:apply-templates select="order"/>
</xsl:template>
<xsl:template match="*|@*|text()">
<xsl:copy>
<xsl:apply-templates select="*|@*|text()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="customer">
<xsl:copy-of select="*" />
</xsl:template>
<xsl:template match="object">
<xsl:copy-of select="*" />
</xsl:template>
</xsl:stylesheet>
here's the original xml sample data:
i added some elements below the object assuming
that you have other elements as expressed by ...
-
order.xml -
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="order.xsl"?>
<order>
<onumber>12345</onumber>
<customer>
<name>Miller</name>
<street>XY Street</street>
<city>Bristol</city>
</customer>
<object>
<orderno>12345678</orderno>
<quant>5</quant>
<color>...</color>
</object>
<other>
<otherchild>Test</otherchild>
</other>
</order>
here's the result:
-
result -
<?xml version="1.0" encoding="UTF-8"?>
<order>
<onumber>12345</onumber>
<name>Miller</name>
<street>XY Street</street>
<city>Bristol</city>
<orderno>12345678</orderno>
<quant>5</quant>
<color>...</color>
<other>
<otherchild>Test</otherchild>
</other>
</order>
i think the code answers your question.
does it?
regards
jo
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It can't be that simple but just to see the fun....ction
It would be better if you can publish the generated FM's code. [ I have no idea as i am not a BW consultant ].
I think if the FM is using iXML or TRANSFORMATIONS whatever...it would be reading the xml file into a string before processing it ..either through iXML lib functions or through TRANSFORM ..
Is it not possible to REPLACE ALL OCCURANCES OF <customer> with SPACE..and similarly for <object>..</object> and so on from the input string..Before passing it for TRANSFORMATION..
BTW...this is not the first time that i misunderstood the requirement.
Cheers,
Ram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
<b>Chance to Shine!</b>
So SDNer's Double points go to each answer to this post that the author gives points to.
So if Dirk gives you 2 points for a reply I'll give you 2 more. If he gives you 6 I'll give you 6 more.
If you answer it and he gives you 10 then I will give you an additional 50 points. If your answer is a weblog or article or how-to guide, then post the link here and let Dirk know and give you points!
Craig
Community Evangelist
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.