Oject-10438 Generate synthetic SGTIN-96 EPCs in test mode when EPCs absent
Both delivery paths (HU via E1EDL37/E1EDL44 and no-HU via E1EDL24) now produce one SGTIN-96 XMLEPC per unit when EDI_DC40/TEST = 'X' and no E1EPC03 URNs are present in the message. Serials are derived from MD5(DOCNUM + SSCC+POSNR+counter) for HU items and MD5(DOCNUM + POSNR+counter) for direct items, ensuring uniqueness across positions and handling units. DeliveredQuantity in the no-HU path corrected from LGMNG to LFIMG.
This commit is contained in:
@@ -6,7 +6,8 @@
|
|||||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||||
xmlns:xs="http://www.w3.org/2001/XMLSchema"
|
xmlns:xs="http://www.w3.org/2001/XMLSchema"
|
||||||
xmlns:ns0="http://sap.com/xi/XI/SplitAndMerge"
|
xmlns:ns0="http://sap.com/xi/XI/SplitAndMerge"
|
||||||
exclude-result-prefixes="xs ns0">
|
xmlns:gs1="urn:gs1:epc"
|
||||||
|
exclude-result-prefixes="xs ns0 gs1">
|
||||||
|
|
||||||
<xsl:output method="xml" indent="yes"/>
|
<xsl:output method="xml" indent="yes"/>
|
||||||
<xsl:strip-space elements="*"/>
|
<xsl:strip-space elements="*"/>
|
||||||
@@ -22,6 +23,8 @@
|
|||||||
|
|
||||||
<!-- Template für IDOC: eine einzige XMLDESADV -->
|
<!-- Template für IDOC: eine einzige XMLDESADV -->
|
||||||
<xsl:template match="ZFSHDLV/IDOC">
|
<xsl:template match="ZFSHDLV/IDOC">
|
||||||
|
<xsl:variable name="docnum" select="normalize-space(EDI_DC40/DOCNUM)"/>
|
||||||
|
<xsl:variable name="testMode" select="EDI_DC40/TEST = 'X'"/>
|
||||||
<XMLDESADV>
|
<XMLDESADV>
|
||||||
|
|
||||||
<xsl:comment>SAP IDOC Number: <xsl:value-of select="EDI_DC40/DOCNUM"/> </xsl:comment>
|
<xsl:comment>SAP IDOC Number: <xsl:value-of select="EDI_DC40/DOCNUM"/> </xsl:comment>
|
||||||
@@ -121,10 +124,15 @@
|
|||||||
|
|
||||||
<!-- Artikel für diese HU -->
|
<!-- Artikel für diese HU -->
|
||||||
<xsl:for-each select="E1EDL44">
|
<xsl:for-each select="E1EDL44">
|
||||||
<xsl:variable name="posnr" select="POSNR"/>
|
<xsl:variable name="posnr" select="POSNR"/>
|
||||||
|
<xsl:variable name="rawGtin" select="normalize-space(../../../E1EDL20/E1EDL24[POSNR = $posnr]/EAN11)"/>
|
||||||
|
<xsl:variable name="gtin14" select="substring(concat('00000000000000', $rawGtin), string-length($rawGtin) + 1, 14)"/>
|
||||||
|
<xsl:variable name="qty" select="xs:integer(xs:decimal(./VEMNG))"/>
|
||||||
|
<xsl:variable name="sscc" select="normalize-space(../EXIDV)"/>
|
||||||
|
<xsl:variable name="hasEpc" select="E1EPC03[URN and string-length(normalize-space(URN)) > 0]"/>
|
||||||
<XMLITEMS>
|
<XMLITEMS>
|
||||||
<PositionNumber><xsl:value-of select="$posnr"/></PositionNumber>
|
<PositionNumber><xsl:value-of select="$posnr"/></PositionNumber>
|
||||||
<GTIN><xsl:value-of select="../../../E1EDL20/E1EDL24[POSNR = $posnr]/EAN11"/></GTIN>
|
<GTIN><xsl:value-of select="$rawGtin"/></GTIN>
|
||||||
<DeliveredQuantity>
|
<DeliveredQuantity>
|
||||||
<xsl:value-of select="xs:decimal(./VEMNG)"/>
|
<xsl:value-of select="xs:decimal(./VEMNG)"/>
|
||||||
</DeliveredQuantity>
|
</DeliveredQuantity>
|
||||||
@@ -138,14 +146,30 @@
|
|||||||
<xsl:value-of select="../../../E1EDL20/E1EDL24[POSNR = $posnr]/VGBEL"/>
|
<xsl:value-of select="../../../E1EDL20/E1EDL24[POSNR = $posnr]/VGBEL"/>
|
||||||
</ReferenceSupplierOrder>
|
</ReferenceSupplierOrder>
|
||||||
<ReferenceBuyerOrder></ReferenceBuyerOrder>
|
<ReferenceBuyerOrder></ReferenceBuyerOrder>
|
||||||
<!-- EPCs -->
|
<!-- EPCs from message -->
|
||||||
<xsl:if test="E1EPC03">
|
<xsl:if test="$hasEpc">
|
||||||
<xsl:for-each select="E1EPC03[URN and string-length(normalize-space(URN)) > 0]">
|
<xsl:for-each select="E1EPC03[URN and string-length(normalize-space(URN)) > 0]">
|
||||||
<XMLEPC>
|
<XMLEPC>
|
||||||
<EPC><xsl:value-of select="normalize-space(URN)"/></EPC>
|
<EPC><xsl:value-of select="normalize-space(URN)"/></EPC>
|
||||||
</XMLEPC>
|
</XMLEPC>
|
||||||
</xsl:for-each>
|
</xsl:for-each>
|
||||||
</xsl:if>
|
</xsl:if>
|
||||||
|
<!-- Test-mode synthetic EPCs: one per unit (VEMNG), keyed by SSCC+POSNR+counter -->
|
||||||
|
<xsl:if test="$testMode and not($hasEpc)">
|
||||||
|
<xsl:for-each select="1 to $qty">
|
||||||
|
<XMLEPC>
|
||||||
|
<EPC>
|
||||||
|
<xsl:value-of select="gs1:encodeSgtin96FromIdoc(
|
||||||
|
$gtin14,
|
||||||
|
$docnum,
|
||||||
|
concat($sscc, '-', $posnr, '-', string(.)),
|
||||||
|
xs:integer(1),
|
||||||
|
xs:integer(7)
|
||||||
|
)"/>
|
||||||
|
</EPC>
|
||||||
|
</XMLEPC>
|
||||||
|
</xsl:for-each>
|
||||||
|
</xsl:if>
|
||||||
</XMLITEMS>
|
</XMLITEMS>
|
||||||
</xsl:for-each>
|
</xsl:for-each>
|
||||||
</XMLSSCCGROUP>
|
</XMLSSCCGROUP>
|
||||||
@@ -160,6 +184,12 @@
|
|||||||
|
|
||||||
<!-- Process direct items when no handling units exist -->
|
<!-- Process direct items when no handling units exist -->
|
||||||
<xsl:for-each select="E1EDL20/E1EDL24">
|
<xsl:for-each select="E1EDL20/E1EDL24">
|
||||||
|
<!-- Capture node values before context shifts inside the seq loop -->
|
||||||
|
<xsl:variable name="rawGtin" select="normalize-space(./EAN11)"/>
|
||||||
|
<xsl:variable name="gtin14" select="substring(concat('00000000000000', $rawGtin), string-length($rawGtin) + 1, 14)"/>
|
||||||
|
<xsl:variable name="posnr" select="string(./POSNR)"/>
|
||||||
|
<xsl:variable name="qty" select="xs:integer(xs:decimal(./LFIMG))"/>
|
||||||
|
<xsl:variable name="hasEpc" select="E1EPC03[URN and string-length(normalize-space(URN)) > 0]"/>
|
||||||
<XMLITEMS>
|
<XMLITEMS>
|
||||||
<PositionNumber>
|
<PositionNumber>
|
||||||
<xsl:value-of select="./POSNR"/>
|
<xsl:value-of select="./POSNR"/>
|
||||||
@@ -168,7 +198,7 @@
|
|||||||
<xsl:value-of select="./EAN11"/>
|
<xsl:value-of select="./EAN11"/>
|
||||||
</GTIN>
|
</GTIN>
|
||||||
<DeliveredQuantity>
|
<DeliveredQuantity>
|
||||||
<xsl:value-of select="xs:decimal(./LGMNG)"/>
|
<xsl:value-of select="xs:decimal(./LFIMG)"/>
|
||||||
</DeliveredQuantity>
|
</DeliveredQuantity>
|
||||||
<QuantityQualifier>
|
<QuantityQualifier>
|
||||||
<xsl:call-template name="QuantityQualifier">
|
<xsl:call-template name="QuantityQualifier">
|
||||||
@@ -182,6 +212,24 @@
|
|||||||
<xsl:value-of select="./VGBEL"/>
|
<xsl:value-of select="./VGBEL"/>
|
||||||
</ReferenceSupplierOrder>
|
</ReferenceSupplierOrder>
|
||||||
<ReferenceBuyerOrder></ReferenceBuyerOrder>
|
<ReferenceBuyerOrder></ReferenceBuyerOrder>
|
||||||
|
<!-- One unique SGTIN-96 EPC per unit (LFIMG actual qty) when test mode is active
|
||||||
|
and no E1EPC03 URN is present. Counter appended to POSNR makes
|
||||||
|
each serial unique: MD5(DOCNUM + POSNR-1), MD5(DOCNUM + POSNR-2) … -->
|
||||||
|
<xsl:if test="$testMode and not($hasEpc)">
|
||||||
|
<xsl:for-each select="1 to $qty">
|
||||||
|
<XMLEPC>
|
||||||
|
<EPC>
|
||||||
|
<xsl:value-of select="gs1:encodeSgtin96FromIdoc(
|
||||||
|
$gtin14,
|
||||||
|
$docnum,
|
||||||
|
concat($posnr, '-', string(.)),
|
||||||
|
xs:integer(1),
|
||||||
|
xs:integer(7)
|
||||||
|
)"/>
|
||||||
|
</EPC>
|
||||||
|
</XMLEPC>
|
||||||
|
</xsl:for-each>
|
||||||
|
</xsl:if>
|
||||||
</XMLITEMS>
|
</XMLITEMS>
|
||||||
</xsl:for-each>
|
</xsl:for-each>
|
||||||
</XMLSSCCGROUP>
|
</XMLSSCCGROUP>
|
||||||
|
|||||||
Reference in New Issue
Block a user