on 2014 Aug 06 4:01 PM
Hi experts,
I have this kind of file :
<Msg>
<Body>
<Payload Role="S">
<Msg>
<Body>
<Payload Role="S">
<BOM>
<BO>
<Documents>
<DocEntry>123<Docentry/>
...........
</Documents>
</BO>
</BOM>
</Payload>
</Body>
</Msg>
</Payload>
</bODY>
</mSG>
I would like to get the value of DocEntry in my <xsl:value of select=""/> but I don't know what is the correct syntaxe to use with the payload S.
Can you help me please?
Thanks
Best regards
Sarah
Hello Sarah,
Try this Msg/Body/Payload[@Role='S']/Msg/Body/Payload[@Role='S']/BOM/BO/Documents/DocEntry, if this xml came from an atom, try $msg//Msg/Body/Payload[@Role='S']/BOM/BO/Documents/DocEntry.
Regards,
Leo.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Leo,
This is the message in Message Log for my second step:
<?xml version="1.0" encoding="utf-8" ?>
</Resumption>
</Variables>
</ReceiverList>
</Header>
</Resumption>
</Variables>
</VarProperties>
</ReceiverList>
</Header>
</b1e:b1event>
</b1e:b1events>
</b1ie:B1IEvent>
</Event>
</Payload>
</row>
</Documents>
</row>
</Document_Lines>
</row>
</TaxExtension>
</row>
</AddressExtension>
</BO>
</BOM>
</Payload>
</Payload>
</AdmInfo>
</CommandeClient>
</row>
</CommandeClient-Lines>
</BO>
</BOM>
</Fileout>
</Payload>
</AdmInfo>
</CommandeClient>
</row>
</CommandeClient-Lines>
</BO>
</BOM>
</Fileout>
</Payload>
</Body>
</Msg>
</vPStatus>
</Payload>
</Body>
</Msg>
Hi Sarah
Based on your input you should be able to get value of DocEntry using one of two methods:
<xsl:template name="transform">
<DocEntry>
<xsl:value-of select="//b1e:value"/>
</DocEntry>
<DocEntry2>
<xsl:value-of select="//vpf:Payload[./@Role = 'S' and @Result != '']//DocEntry"/>
</DocEntry2>
</xsl:template>
Since Msg element belongs to a namespace xmlns="urn:com.sap.b1i.vplatform:entity" you should almost always attach 'vpf:' prefix to Payload, Body and Msg tags.
Kind regards,
Radek
Hi Radek,
it's work thank you very much!!
Just another question, now I have access to DocEntry i want to update row of my order.
I have to access to Document_Lines but it's the same problem how to access if it's in the inbound of the first step?
your method works for the DocEntry but I don't see how to do with other things?
Thank you very much
regards
sarah
Hi Radek and Leo,
I don't know if it's because the syntax but when I do that:
<B1out xmlns="" type="object">
<Documents>
<row>
<DocEntry> <xsl:value-of select="//b1e:value"/> </DocEntry>
<DocType>dDocument_Items</DocType>
</row>
</Documents>
<Document_Lines>
<xsl:for-each select="//vpf:Payload[./@Role = 'S' and @Result != '']//Document_Lines/*">
<xsl:if test= "//vpf:Payload[./@Role = 'S' and @Result != '']//Document_Lines/row/U_GTI_E046='Y' and //vpf:Payload[./@Role = 'S' and @Result != '']//Document_Lines/row/U_GTI_E021='N'">
<row>
<U_GTI_E021>Y</U_GTI_E021>
<U_PFL_DateExpImp>
<xsl:value-of select="//vpf:Payload[./@Role = 'S' and @Result != '']//CreationDate"/>
</U_PFL_DateExpImp>
</row>
</if>
</xsl:for-each>
</Document_Lines>
</B1out>
The sytem read always the first line and not the other. because of that I can't do update my order correctly.
Can you help me again with that please?
Thank you very much
regards
Sarah
Hi Sarah
The following document has helped me many times when dealing with XSLT:
http://www.ibm.com/developerworks/library/x-xsltmistakes/
I think that your current problem is related to 'Don't lose the context node' section, listening 8.
Hope this helps - otherwise please send your input XML.
Kind regards,
Radek
Hi radek
this is my input xml:
<?xml version="1.0" encoding="utf-8" ?>
</Resumption>
</Variables>
</Properties>
</ReceiverList>
</Header>
</Resumption>
</Variables>
</Properties>
</VarProperties>
</ReceiverList>
</Header>
</b1e:b1event>
</b1e:b1events>
</b1ie:B1IEvent>
</Event>
</Payload>
</row>
</Documents>
</row>
</row>
</Document_Lines>
</TaxExtension>
</row>
</AddressExtension>
</BO>
</BOM>
</Payload>
</AdmInfo>
</CommandeClient>
</row>
</row>
</CommandeClient-Lines>
</BO>
</BOM>
</Fileout>
</Payload>
</AdmInfo>
</CommandeClient>
</row>
</row>
</CommandeClient-Lines>
</BO>
</BOM>
</Fileout>
</Payload>
</Body>
</Msg>
</vPStatus>
</Payload>
</Payload>
</Header>
</Envelope>
</Payload>
</Body>
</Msg>
As you see the system read only line 0 twice (2 lines).
I would like test for each line the value of an attribut and if the test is ok update order but the code which I post doesn't work.
Did you see my error ou do you have an idea to do that please?
There is my code :
<B1out xmlns="" type="object">
<Documents>
<row>
<DocEntry> <xsl:value-of select="//b1e:value"/> </DocEntry>
<DocType>dDocument_Items</DocType>
</row>
</Documents>
<Document_Lines>
<xsl:for-each select="//vpf:Payload[./@Role = 'S' and @Result != '']//Document_Lines/*">
<xsl:if test= "//vpf:Payload[./@Role = 'S' and @Result != '']//Document_Lines/row/U_GTI_E046='Y' and //vpf:Payload[./@Role = 'S' and @Result != '']//Document_Lines/row/U_GTI_E021='N'">
<row>
<U_GTI_E021>Y</U_GTI_E021>
<U_PFL_DateExpImp>
<xsl:value-of select="//vpf:Payload[./@Role = 'S' and @Result != '']//CreationDate"/>
</U_PFL_DateExpImp>
</row>
</if>
</xsl:for-each>
</Document_Lines>
</B1out>
Thanks
regards
Sarah
Hi Sarah
Actually in the document that I referred to in my previous comment you could find that for-each function creates new context:
The expression /invoice/item in xsl:for-each correctly selects all items in the invoice. But expressions inside xsl:for-each are wrong, as they start with /, which means that they're absolute. Such expressions always return a description, the quantity, and price of the first item (remember from the previous section that xsl:value-of returns only the first node from a node set), because an absolute expression does not depend on the current node, which corresponds to the currently processed item.
To easily fix this problem, use a relative expression inside xsl:for-each
i. e.: <xsl:if test= "U_GTI_E046='Y' and U_GTI_E021='N'">
Kind regards,
Radek
Hi Sarah
Your xsl:for-each is ok.
The only thing that needs to be changed is your if statement. Since when your loop is being executed it changes a processing context you don't have to use absolute paths inside your loop. Thus you need to change only your if statement to:
<xsl:if test= "U_GTI_E046='Y' and U_GTI_E021='N'">
Kind regards,
Radek
Hi Radek,
Thank you for your answer.
I try that you said but it doesn't work.
The test is made only on the first line and it's not made correctly.
My code is:
<B1out xmlns="" type="object">
<Documents>
<row>
<DocEntry> <xsl:value-of select="//b1e:value"/> </DocEntry>
<DocType>dDocument_Items</DocType>
</row>
</Documents>
<Document_Lines>
<xsl:for-each select="//vpf:Payload[./@Role = 'S' and @Result != '']//Document_Lines/*">
<xsl:if test="U_GTI_E046='Y' and U_GTI_E021='N'">
<row>
<U_GTI_E021>Y</U_GTI_E021>
<U_PFL_DateExpImp>
<xsl:value-of select="//vpf:Payload[./@Role = 'S' and @Result != '']//CreationDate"/>
</U_PFL_DateExpImp>
</row>
</xsl:if>
</xsl:for-each>
</Document_Lines>
</B1out>
Is that ok?
Thank you very much for your help
Regards,
Sarah
Hi Radek,
I work on another scenario but I have almost the same problem that at my first post.
I have scenario with two steps. First step export an order of sap to a file on a FTP. The second step get back this file from the FTP and create a Delivery notes in sap from this file.
The two steps are link by Succesor/predecessor,
This is the message from B1i:
<?xml version="1.0" encoding="utf-8" ?>
</Resumption>
</Variables>
</ReceiverList>
</Header>
</Resumption>
</Variables>
</ReceiverList>
</Header>
</b1e:b1event>
</b1e:b1events>
</b1ie:B1IEvent>
</Event>
</Payload>
</row>
</Documents>
</row>
</row>
...
</Document_Lines>
</BO>
</BOM>
</Payload>
</AdmInfo>
</LivraisonClient>
</row>
</row>
</LivraisonClient-Lines>
</BO>
</BOM>
</Fileout>
</Payload>
</AdmInfo>
</LivraisonClient>
</row>
</row>
</LivraisonClient-Lines>
</BO>
</BOM>
</Fileout>
</Payload>
</AdmInfo>
</LivraisonClient>
</row>
</row>
</LivraisonClient-Lines>
</BO>
</BOM>
</Fileout>
</Payload>
</Body>
</Msg>
</vPStatus>
</Payload>
</AdmInfo>
</LivraisonClient>
</row>
</row>
</LivraisonClient-Lines>
</BO>
</BOM>
</Fileout>
</ftp.file>
</Payload>
</Header>
</Body>
</Envelope>
</Payload>
</Body>
</Msg>
and my code in atom0 of the second step is :
<?xml version="1.0" encoding="UTF-8" ?>
- <xsl:stylesheet xmlns:b1e="urn:com.sap.b1i.sim:b1event" xmlns:b1ie="urn:com.sap.b1i.sim:b1ievent" xmlns:bfa="urn:com.sap.b1i.bizprocessor:bizatoms" xmlns:jdbc="urn:com.sap.b1i.adapter:jdbcadapter" xmlns:rfc="urn:sap-com:document:sap:rfc:functions" xmlns:sim="urn:com.sap.b1i.sim:entity" xmlns:utils2="com.sap.b1i.bpc_tools.Utilities" xmlns:vpf="urn:com.sap.b1i.vplatform:entity" xmlns:xci="urn:com.sap.b1i.xcellerator:intdoc" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" bfa:force="" vpf:force="" jdbc:force="" rfc:force="" b1ie:force="" b1e:force="" xci:force="" sim:force="" utils2:force="">
<xsl:output method="xml" encoding="UTF-8" indent="yes" />
<xsl:param name="atom" />
<xsl:param name="sessionid" />
<xsl:variable name="msg" select="/vpf:Msg/vpf:Body/vpf:Payload[./@Role='S']" />
<xsl:variable name="vpSender" select="/vpf:Msg/vpf:Header/vpf:Sender/@Id" />
<xsl:variable name="vpObject" select="/vpf:Msg/vpf:Header/vpf:Sender/@ObjId" />
<xsl:variable name="vpReceiver" select="/vpf:Msg/vpf:Header/vpf:ReceiverList/vpf:Receiver[./@handover='P']/@Id" />
<xsl:variable name="vpfile" select="/vpf:Msg/vpf:Header/vpf:Variables/vpf:var[./@id='file']/@value" />
- <xsl:template match="/">
- <Msg xmlns="urn:com.sap.b1i.vplatform:entity">
<xsl:copy-of select="/vpf:Msg/@*" />
<xsl:copy-of select="/vpf:Msg/vpf:Header" />
- <Body>
<xsl:copy-of select="/vpf:Msg/vpf:Body/*" />
- <Payload Role="R" id="{$atom}">
<xsl:call-template name="transform" />
</Payload>
</Body>
</Msg>
</xsl:template>
- <xsl:template name="transform">
<B1out xmlns="" type="object">
<Documents>
<row>
<DocEntry><xsl:value-of select="//b1e:value"/></DocEntry>
<U_PFL_NumTransKN1><xsl:value-of select="//vpf:Payload[./@Role = 'C' and @calltype ='FTTP']//Num-Transaction"/></U_PFL_NumTransKN1>
<U_PFL_DateTransKN1><xsl:value-of select="//vpf:Payload[./@Role = 'C' and @calltype ='FTTP']//Date-Transaction"/></U_PFL_DateTransKN1>
<CardCode><xsl:value-of select="//vpf:Payload[./@Role = 'C' and @calltype ='FTTP']//CodeClient"/></CardCode>
<U_PFL_NumBLKN><xsl:value-of select="//vpf:Payload[./@Role = 'C' and @calltype ='FTTP']//bonlivraison-KN"/></U_PFL_NumBLKN>
<U_PFL_DatePrepaKN><xsl:value-of select="//vpf:Payload[./@Role = 'C' and @calltype ='FTTP']//date-preparation"/></U_PFL_DatePrepaKN>
<U_PFL_TypCde><xsl:value-of select="//vpf:Payload[./@Role = 'C' and @calltype ='FTTP']//type-commande"/></U_PFL_TypCde>
<Conformite><xsl:value-of select="//vpf:Payload[./@Role = 'C' and @calltype ='FTTP']//conformite"/></Conformite>
<U_GTI_D013><xsl:value-of select="//vpf:Payload[./@Role = 'C' and @calltype ='FTTP']//nb_colis_total"/></U_GTI_D013>
<U_PFL_nb_pallet><xsl:value-of select="//vpf:Payload[./@Role = 'C' and @calltype ='FTTP']//nb_palette_total"/></U_PFL_nb_pallet>
<U_PFL_volume_total><xsl:value-of select="//vpf:Payload[./@Role = 'C' and @calltype ='FTTP']//volume_total"/></U_PFL_volume_total>
<U_PFL_Poids><xsl:value-of select="//vpf:Payload[./@Role = 'C' and @calltype ='FTTP']//poids_total"/></U_PFL_Poids>
<U_PFL_ship_date><xsl:value-of select="//vpf:Payload[./@Role = 'C' and @calltype ='FTTP']//Shipment_Date"/></U_PFL_ship_date>
</row>
</Documents>
<Document_Lines>
<xsl:for-each select="//vpf:Payload[./@Role = 'C' and @calltype ='FTTP']//Document_Lines/*">
<row>
<LineNum><xsl:value-of select="//vpf:Payload[./@Role = 'C' and @calltype ='FTTP']//num-ligne"/></LineNum>
<ItemCode><xsl:value-of select="//vpf:Payload[./@Role = 'C' and @calltype ='FTTP']//code-article"/></ItemCode>
<ItemDescription><xsl:value-of select="//vpf:Payload[./@Role = 'C' and @calltype ='FTTP']//desc-article"/></ItemDescription>
<Quantity><xsl:value-of select="//vpf:Payload[./@Role = 'C' and @calltype ='FTTP']//quantite"/></Quantity>
</row>
</xsl:for-each>
</Document_Lines>
</B1out>
<xsl:attribute name="pltype">xml</xsl:attribute>
</xsl:template>
</xsl:stylesheet>
The first step works fine but the second fails and the result message is :
Exception : Invoke of: ReadXml Source: Description: '' is not a valid value for property 'U_PFL_TypCde'. The valid values are: 'NO' - 'NO', 'EX' - 'EX', 'TRF' - 'TRF', 'CDS' - 'CDS', 'WEB' - 'WEB'
or when I delete the UPFLTypCde the message is :
Exception : Invoke of: ReadXml Source: Description: Property 'Conformite' of 'Document' is invalid
and when I delete again Conformite I have this message:
Exception : DI Error: (-2028) No matching records found (ODBC -2028)
In resume, The system doesn't get back informations to create the delivery notes
Do you see where is my mistake in my syntaxe please?
Thank you for your help
Best regards
Sarah
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.