on 03-20-2018 10:41 AM
Dear All,
I am working on B1if . I need to remove Duplicate row from B1 to Flat File. The XSLT is working fine when the record is not duplicate. but when i transfer the record with Duplicate row on the document. Please let me know how to solve the this?
My Code in atom0.
<?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="/">
<Msg
xmlns="urn:com.sap.b1i.vplatform:entity">
<xsl:copy-of select="/vpf:Msg/@*"></xsl:copy-of>
<xsl:copy-of select="/vpf:Msg/vpf:Header"></xsl:copy-of>
<Body>
<xsl:copy-of select="/vpf:Msg/vpf:Body/*"></xsl:copy-of>
<Payload Role="R" id="{$atom}" ts="{$vpts}">
<xsl:call-template name="transform"></xsl:call-template>
</Payload>
</Body>
</Msg>
</xsl:template>
<xsl:template name="transform">
<Fileout type="file">
<row>
<col>DocNum</col>
<col>PostingDate</col>
<col>CardCode</col>
<col>CardName</col>
<col>ItemCode</col>
<col>ItemName</col>
<col>Qty</col>
<col>Price</col>
<col>LineTotal</col>
</row>
<xsl:for-each select="$msg/BOM/BO/Document_Lines/*">
<row>
<col>
<xsl:value-of select="$msg/BOM/BO/Documents/row/DocNum"></xsl:value-of>
</col>
<col>
<xsl:variable name="datestr" select="$msg/BOM/BO/Documents/row/DocDate"></xsl:variable>
<xsl:variable name="mm">
<xsl:value-of select="substring($datestr,5,2)"></xsl:value-of>
</xsl:variable>
<xsl:variable name="dd">
<xsl:value-of select="substring($datestr,7,2)"></xsl:value-of>
</xsl:variable>
<xsl:variable name="yyyy">
<xsl:value-of select="substring($datestr,1,4)"></xsl:value-of>
</xsl:variable>
<xsl:value-of select="concat($dd,'/',$mm,'/',$yyyy)"></xsl:value-of>
</col>
<col>
<xsl:value-of select="$msg/BOM/BO/Documents/row/CardCode"></xsl:value-of>
</col>
<col>
<xsl:value-of select="$msg/BOM/BO/Documents/row/CardName"></xsl:value-of>
</col>
<col>
<xsl:value-of select="ItemCode"></xsl:value-of>
</col>
<col>
<xsl:value-of select="ItemDescription"></xsl:value-of>
</col>
<col>
<xsl:value-of select="Quantity"></xsl:value-of>
</col>
<col>
<xsl:value-of select="Price"></xsl:value-of>
</col>
<col>
<xsl:variable name="Qty" select="Quantity"></xsl:variable>
<xsl:variable name="Prc" select="Price"></xsl:variable>
<xsl:variable name="lineTot" select="$Qty * $Prc"></xsl:variable>
<xsl:variable name="currSym" select="'INR'"></xsl:variable>
<xsl:value-of select="concat($currSym,' ' ,$lineTot)"></xsl:value-of>
</col>
</row>
</xsl:for-each>
</Fileout>
</xsl:template>
</xsl:stylesheet>
<br>
Hello Lakshmi,
Do you mean the same ItemCode should only be one time?
<xsl:key name="product" match="//BOM/BO/Document_Lines/row/ItemCode" use="."/>
<xsl:template name="transform">
<Fileout type="file">
<row>
<col>DocNum</col>
<col>PostingDate</col>
<col>CardCode</col>
<col>CardName</col>
<col>ItemCode</col>
<col>ItemName</col>
<col>Qty</col>
<col>Price</col>
<col>LineTotal</col>
</row>
<xsl:for-each select="//BOM/BO/Document_Lines/row/ItemCode[generate-id()=generate-id(key('product',.)[1])]">
<row>
<itemcode>
<xsl:value-of select="."/>
</itemcode>
<col>
<xsl:value-of select="//BOM/BO/Documents/row/DocNum"/>
</col>
<col>
<xsl:variable name="datestr" select="//BOM/BO/Documents/row/DocDate"/>
<xsl:variable name="mm">
<xsl:value-of select="substring($datestr,5,2)"/>
</xsl:variable>
<xsl:variable name="dd">
<xsl:value-of select="substring($datestr,7,2)"/>
</xsl:variable>
<xsl:variable name="yyyy">
<xsl:value-of select="substring($datestr,1,4)"/>
</xsl:variable>
<xsl:value-of select="concat($dd,'/',$mm,'/',$yyyy)"/>
</col>
<col>
<xsl:value-of select="//BOM/BO/Documents/row/CardCode"/>
</col>
<col>
<xsl:value-of select="//BOM/BO/Documents/row/CardName"/>
</col>
<col>
<xsl:value-of select="../ItemCode"/>
</col>
<col>
<xsl:value-of select="../ItemDescription"/>
</col>
<col>
<xsl:value-of select="../Quantity"/>
</col>
<col>
<xsl:value-of select="../Price"/>
</col>
<col>
<xsl:variable name="Qty" select="../Quantity"/>
<xsl:variable name="Prc" select="../Price"/>
<xsl:variable name="lineTot" select="$Qty * $Prc"/>
<xsl:variable name="currSym" select="'INR'"/>
<xsl:value-of select="concat($currSym,' ' ,$lineTot)"/>
</col>
</row>
</xsl:for-each>
</Fileout>
</xsl:template>
Thanks & best regards
Huan Yang
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
89 | |
7 | |
6 | |
3 | |
3 | |
3 | |
3 | |
3 | |
3 | |
2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.