on 04-07-2009 2:40 AM
Hi,
A and B are in Source Structure. "C" is in Target Structure.
If "A" value has between 5001 and 6999 then pass "B" to C.
How to do this in XSLT map?
Thanks
Deepthi
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:for-each select="POS/Detail">
<xsl:if test="(POS/Detail/FieldA > 5000) and (POS/Detail/FieldA < 7000)">
<xsl:call-template name="insert_E1WPF02">
<xsl:with-param name="ReferenceNo"/>
<xsl:with-param name="ItemNo"/>
<xsl:with-param name="Amount"/>
</xsl:call-template>
</xsl:if>
</xsl:for-each>
<xsl:template name="insert_E1WPF02" match="/">
<xsl:param name="ItemNo"/>
<xsl:param name="Amount"/>
<xsl:param name="RefernceNo"/>
<ZUONR>
<xsl:value-of select="$ReferenceNo[$ItemNo>'5000' and $ItemNo<'7000']"/>
</ZUONR>
<POSNR>
<xsl:value-of select="$ItemNo"/>
</POSNR>
<WRBTR>
<xsl:value-of select="$Ammount"/>
</WRBTR>
</xsl:template>
</xsl:stylesheet>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
A and B are in Source Structure. "C" is in Target Structure.
If "A" value has between 5001 and 6999 then pass "B" to C.
If only the above condition has to be satisfied then you dont need to call a template, use a parameter etc just work on the below code:
<xsl:for-each select="POS/Detail">
<xsl:if test="(POS/Detail/FieldA > 5000) and (POS/Detail/FieldA < 7000)">
<C>
<xsl:value-of select="POS/Detail/FieldB"/>
</C>
</xsl:if>
</xsl:for-each>
Above code is assuming that Detail node is under POS but not under Header
Regards,
Abhishek.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Abhishek,
I need to pass the result to the parameter "ReferenceNo". This code is already in production.
I just want to insert this condition.
Once I pass the value to "ReferenceNo" . It will pass the value to Field ZUONR which is the Idoc Field.
Can you please suggest me how I can pass the resultant value to the parameter "ReferenceNo".
Hi,
Please understand the steps done in the code before you try it:)
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:for-each select="POS/Detail">
<xsl:if test="(POS/Detail/FieldA > 5000) and (POS/Detail/FieldA < 7000)">
<xsl:call-template name="insert_E1WPF02">
<xsl:with-param name="ReferenceNo" />
</xsl:call-template>
</xsl:if>
</xsl:for-each>
<xsl:template name="insert_E1WPF02" match="/">
<xsl:param name="RefernceNo" select="POS/Detail/FieldB" />
<C>
<xsl:value-of select="$ReferenceNo"/>
</C>
</xsl:template>
</xsl:stylesheet>
Regards,
Abhishek.
Hi Abhishek,
The condition is working partly.
The problem here is I will be getting any values in Detail/FieldA. But I need to pass FieldB only when FieldA >5000 and <7000.
Example: consider below two cases.
Case1:
if FieldA gets value like 3000 (Since it is <5000) then I need to pass only FieldA and I should not pass FieldB.
Case2:
- If FieldA gets value like 5300 (Since it is >5000) I need to pass both FieldA and FieldB.
The code which you specified is working only for case 2. But it is not working for Case1.
Any suggestions please.
Thanks
Deepthi.
Code:
-
- <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
- <xsl:for-each select="POS/Detail">
- <xsl:if test="(POS/Detail/FieldA > 5000) and (POS/Detail/FieldA < 7000)">
- <xsl:call-template name="insert_E1WPF02">
<xsl:with-param name="ReferenceNo" />
<xsl:with-param name="ItemNo" />
<xsl:with-param name="Amount" />
</xsl:call-template>
</xsl:if>
</xsl:for-each>
- <xsl:template name="insert_E1WPF02" match="/">
<xsl:param name="ItemNo" />
<xsl:param name="Amount" />
<xsl:param name="RefernceNo" select="POS/Detail/FieldB" />
- <ZUONR>
<xsl:value-of select="$ReferenceNo" />
</ZUONR>
- <POSNR>
<xsl:value-of select="$ItemNo" />
</POSNR>
- <WRBTR>
<xsl:value-of select="$Ammount" />
</WRBTR>
</xsl:template>
</xsl:stylesheet>
I Cannot use <xsl:template name="insert_E1WPF02> twice because it is creating 2 E1WPF02 Segments in Idoc for each transaction which is not correct.
Hi,
<xsl:if test=("A > 5000" and "A < 7000")>
The above format is wrong...use the below syntax:
<xsl:if test="(A > 5000 and A < 7000)">
For more reference view the example here: http://www.w3schools.com/xsl/el_if.asp
Also check your with-param declaration: http://www.w3schools.com/xsl/el_with-param.asp
Regards,
Abhishek.
Edited by: abhishek salvi on Apr 7, 2009 8:50 AM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It's not working. It is showing below error in XMLSPY.
XSLT 1.0 : Debugging Error : Unexpected element
<xsl:if
-
Code: I just tried for > 5000----
<xsl:for-each select="POS/Detail">
<xsl:call-template name="insert_E1WPF02">
xsl:with-param name="ItemNo" select="./FieldA"
<xsl:if test="(./Field1 > 5000">
<C>
<xsl:with-param name="ReferenceNo" select="./Field2" />
</C>
</xsl:if>
<xsl:with-param name="Ammount" select="./Field3"/>
</xsl:call-template>
Can I insert IF statement in between the template?
Lines from your code :
xsl:with-param name="ItemNo" select="./FieldA"
<xsl:if test="(./Field1 > 5000">
If you have pasted the exact code and is not a typo error, then the above lines have syntactical errors(First line enclose in braces representing the tag and in the if condition there is an extra '(' ). Correct them and check if it is still giving the error.
Edited by: BRREDDY on Apr 7, 2009 10:27 AM
>
> Hi,
>
> A and B are in Source Structure. "C" is in Target Structure.
>
> If "A" value has between 5001 and 6999 then pass "B" to C.
>
> How to do this in XSLT map?
>
> Thanks
> Deepthi
<xsl:if test=("A > 5000" and "A < 7000")>
<C>
<xsl:value-of select="B"/>
</C>
</xsl:if>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Shabharish,
It's not working.
Source Structure looks like below.
<POS>
<HEADER>
- <Field1>
- <Field2>
<Detail>
-- <FieldA>
-- <FieldB>
-- <Field3>
</Detail>
</POS>
XSLT map Code:
-
<xsl:for-each select="POS/Detail">
xsl:with-param name="ItemNo" select="./FieldA"
<xsl:if test=("./FieldA > 5000" and "./FieldA < 7000")>
<C>
<xsl:with-param name="ReferenceNo" select="./FieldB" />
</C>
</xsl:if>
<xsl:with-param name="Ammount" select="./Field3"/>
Looks like some syntax error.? please suggest.
User | Count |
---|---|
82 | |
10 | |
10 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.