Skip to Content

Does xsl:key work in B1if?

I have a requirement to aggregate qtys and have the following XML going into an atom

<vpf:Msg xmlns:vpf="urn:com.sap.b1i.vplatform:entity" xmlns:xci="urn:com.sap.b1i.xcellerator:intdoc" xmlns:js="com.sap.b1i.bpc_tools.Javascript" xmlns:b1ie="urn:com.sap.b1i.sim:b1ievent" xmlns:uplt="urn:com.sap.b1i.xcellerator:upltdoc" xmlns:bfa="urn:com.sap.b1i.bizprocessor:bizatoms" xmlns:utils2="com.sap.b1i.bpc_tools.Utilities" xmlns:jdbc="urn:com.sap.b1i.adapter:jdbcadapter" xmlns:sim="urn:com.sap.b1i.sim:entity" xmlns:b1im="urn:com.sap.b1i.sim:b1imessage" xmlns:b1e="urn:com.sap.b1i.sim:b1event" xmlns:rfc="urn:sap-com:document:sap:rfc:functions" MessageId="180511213958937160400AFA3D64C851" BeginTimeStamp="20180511213958" logmsg="0000" SubMessageId="" status="success" owntst="true" test="true">
    <Header xmlns="urn:com.sap.b1i.vplatform:entity">
		<IPO Id="vPlatform_Test"/>
		<Sender Id="" ObjId=""/>
		<Receiver Id=""/>
		<ReceiverList>
			<Receiver Id="" handover="P"/>
		</ReceiverList>
		<Identification Ident="" IdPar=""/>
		<nsList/>
		<vBIU Id="lev.TestKey" ver="1.0.0" SId="lev.KEYTEST" filter="" phase=""/>
		<Variables>
			<var id="userid" value=""/>
			<var id="username" value=""/>
		</Variables>
		<Properties/>
		<SysTypeProperties type="B1if" offline="" snd="senderdummy" rcv="receiverdummy" ssystype="" rsystype=""/>
		<LocalProperties type="B1if" biu="lev.TestKey" snd="senderdummy" rcv="receiverdummy" sid="lev.KEYTEST" offline=""/>
		<VarProperties/>
	</Header>
	<vpf:Body>
		<Payload xmlns="urn:com.sap.b1i.vplatform:entity" Role="T" Type="Call"/>
		<Payload xmlns="urn:com.sap.b1i.vplatform:entity" Role="S">*** no test message specified ***</Payload>
		<vpf:Payload Role="X" id="atom1" ts="2018/05/11 21:39:58">
			<Invoice>
				<Line>
					<LineNum>1</LineNum>
					<ItemCode>1</ItemCode>
					<Qty>1</Qty>
				</Line>
				<Line>
					<LineNum>2</LineNum>
					<ItemCode>4</ItemCode>
					<Qty>3</Qty>
				</Line>
				<Line>
					<LineNum>3</LineNum>
					<ItemCode>1</ItemCode>
					<Qty>5</Qty>
				</Line>
			</Invoice>
		</vpf:Payload>
	</vpf:Body>
</vpf:Msg>

When I apply the following xsl to it, in anything but B1if it works beautifully.

<?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:b1im="urn:com.sap.b1i.sim:b1imessage" xmlns:bfa="urn:com.sap.b1i.bizprocessor:bizatoms" xmlns:jdbc="urn:com.sap.b1i.adapter:jdbcadapter" xmlns:js="com.sap.b1i.bpc_tools.Javascript" xmlns:rfc="urn:sap-com:document:sap:rfc:functions" xmlns:sim="urn:com.sap.b1i.sim:entity" xmlns:uplt="urn:com.sap.b1i.xcellerator:upltdoc" 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="" b1im:force="" uplt:force="" js:force=""><xsl:output method="xml" encoding="UTF-8" indent="yes"></xsl:output><xsl:param name="atom"></xsl:param><xsl:param name="sessionid"></xsl:param><xsl:variable name="msg" select="/vpf:Msg/vpf:Body/vpf:Payload[./@Role='S']"></xsl:variable><xsl:variable name="vptsDoc" select="document('/com.sap.b1i.internal/xml/timestamp')"></xsl:variable><xsl:variable name="vpts" select="concat($vptsDoc/*/@year,'/',$vptsDoc/*/@month,'/',$vptsDoc/*/@date,' ',$vptsDoc/*/@hour,':',$vptsDoc/*/@minute,':',$vptsDoc/*/@second)"></xsl:variable><xsl:variable name="vpSender" select="/vpf:Msg/vpf:Header/vpf:Sender/@Id"></xsl:variable><xsl:variable name="vpObject" select="/vpf:Msg/vpf:Header/vpf:Sender/@ObjId"></xsl:variable><xsl:variable name="vpReceiver" select="/vpf:Msg/vpf:Header/vpf:ReceiverList/vpf:Receiver[./@handover='P']/@Id"></xsl:variable><xsl:template match="/">
        <vpf:Msg>
            <xsl:copy-of select="/vpf:Msg/@*"></xsl:copy-of>
            <xsl:copy-of select="/vpf:Msg/vpf:Header"></xsl:copy-of>
            <vpf:Body>
                <xsl:copy-of select="/vpf:Msg/vpf:Body/*"></xsl:copy-of>
                <vpf:Payload Role="X" id="{$atom}" ts="{$vpts}">
                    <xsl:call-template name="transform"></xsl:call-template>
                </vpf:Payload>
            </vpf:Body>
        </vpf:Msg>
    </xsl:template>
<xsl:key name="itemGroup" match="Line" use="ItemCode"></xsl:key>
<xsl:template name="transform">
      <xsl:variable name="rootTag" select="/vpf:Msg/vpf:Body/vpf:Payload[@id='atom1']"></xsl:variable>
      <Grouped>
          <xsl:for-each select="$rootTag/Invoice/Line[generate-id()=generate-id(key('itemGroup', ItemCode)[1])]">
            <ItemCode><xsl:value-of select="ItemCode"></xsl:value-of></ItemCode>
            <Qty><xsl:value-of select="sum(key('itemGroup', ItemCode)/Qty)"></xsl:value-of></Qty>    
          </xsl:for-each>
      </Grouped>
    </xsl:template></xsl:stylesheet>

I get the following aggregated values with sum of Qty grouped by ItemCode....

<Grouped>
  <ItemCode>1</ItemCode>
  <Qty>6</Qty>
  <ItemCode>4</ItemCode>
  <Qty>3</Qty>
</Grouped>

And when I apply the same XSL within B1if, it doesn't seem to work at all...

<vpf:Payload Role="X" id="atom2" ts="2018/05/11 22:03:08">
<Grouped/>

</vpf:Payload>

So am I missing something? Is xsl:key a thing in B1if? I don't get any error saying it's not, it just doesn't seem to work.

I am using B1if on SBO 9.3 PL03

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    May 18 at 02:04 AM

    Hello Adam Kimmorley,

    Thanks for your reporting.

    Based on the investigation, it's an xsl engine issue.

    Integration Framework, aka B1if, uses JDK xsl processor. We do the test in Java code, and xsl:key doesn't work.

    Thanks & Best regards

    Huan Yang

    Add comment
    10|10000 characters needed characters exceeded