Files
syspro/syspro/mapping/DELIVERY/DELIVERY.xsl
T
Jeremiah Blunser 606bade556 Update mapping
2024-03-12 16:28:38 +01:00

242 lines
7.5 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<!-- 22.12.2023 DEV-8311 SAP sends delivery advices to stores MAPPING: SOURCE
- SAP ZFSHDLV TARGET - syspro internal Format -->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs">
<xsl:output method="xml" omit-xml-declaration="no"
indent="yes" />
<xsl:strip-space elements="*" />
<xsl:template match="/" name="DELIVERY">
<Message>
<xsl:apply-templates />
</Message>
</xsl:template>
<xsl:template match="/ZFSHDLV/IDOC">
<xsl:if test="./E1EDL20/E1EDL37">
<xsl:call-template name="HandlingUnit" />
</xsl:if>
<xsl:if test="not(./E1EDL20/E1EDL37)">
<xsl:call-template name="WithOutHandlingUnits" />
</xsl:if>
</xsl:template>
<xsl:template name="Message">
<xsl:param name="CASE" />
<xsl:param name="ID" />
<xsl:param name="SSCCID" />
<xsl:param name="POSITIONS" />
<!-- START: local variable declaration -->
<xsl:variable name="PackageCode">
<xsl:copy>
33E
</xsl:copy>
</xsl:variable>
<xsl:variable name="PackageType">
<xsl:copy>
BJ
</xsl:copy>
</xsl:variable>
<!-- END: local variable declaration -->
<XMLDESADV>
<XMLDESADVHEADER>
<DocumentId>
<xsl:value-of select="$ID" />
</DocumentId>
<DeliveryNote>
<xsl:value-of select="../VBELN" />
</DeliveryNote>
<DocumentType>
<xsl:call-template name="DocumentType">
<xsl:with-param name="DocumentType">
<xsl:copy>
DEV-8311
</xsl:copy>
</xsl:with-param>
</xsl:call-template>
</DocumentType>
<DocumentSubType>
<xsl:call-template name="DocumentSubType">
<xsl:with-param name="LFART">
<xsl:value-of select="../E1EDL21/LFART" />
</xsl:with-param>
</xsl:call-template>
</DocumentSubType>
<DocumentDate>
<xsl:value-of
select="format-dateTime(adjust-dateTime-to-timezone(xs:dateTime(concat(
substring(/ZFSHDLV/IDOC/E1EDL20/E1EDT13[QUALF='015']/NTANF,1,4),
'-',
substring(/ZFSHDLV/IDOC/E1EDL20/E1EDT13[QUALF='015']/NTANF,5,2),
'-',
substring(/ZFSHDLV/IDOC/E1EDL20/E1EDT13[QUALF='015']/NTANF,7,2),
'T',
substring(/ZFSHDLV/IDOC/E1EDL20/E1EDT13[QUALF='015']/NTANZ,1,2),
':',
substring(/ZFSHDLV/IDOC/E1EDL20/E1EDT13[QUALF='015']/NTANZ,3,2),
':',
substring(/ZFSHDLV/IDOC/E1EDL20/E1EDT13[QUALF='015']/NTANZ,5,2)))),
'[Y0000]-[M00]-[D00]T[H00]:[m00]:[s00].[f0000000][Z]')" />
</DocumentDate>
<DeliveryDate>
<xsl:value-of
select="format-dateTime(adjust-dateTime-to-timezone(xs:dateTime(concat(
substring(/ZFSHDLV/IDOC/E1EDL20/E1EDT13[QUALF='007']/NTANF,1,4),
'-',
substring(/ZFSHDLV/IDOC/E1EDL20/E1EDT13[QUALF='007']/NTANF,5,2),
'-',
substring(/ZFSHDLV/IDOC/E1EDL20/E1EDT13[QUALF='007']/NTANF,7,2),
'T',
substring(/ZFSHDLV/IDOC/E1EDL20/E1EDT13[QUALF='007']/NTANZ,1,2),
':',
substring(/ZFSHDLV/IDOC/E1EDL20/E1EDT13[QUALF='007']/NTANZ,3,2),
':',
substring(/ZFSHDLV/IDOC/E1EDL20/E1EDT13[QUALF='007']/NTANZ,5,2)))),
'[Y0000]-[M00]-[D00]T[H00]:[m00]:[s00].[f0000000][Z]')" />
</DeliveryDate>
<ReferenceSupplierOrder />
<ReferenceBuyerOrder />
<ReferenceDocument>
<xsl:value-of select="$ID" />
</ReferenceDocument>
<AllocationReference />
<SenderGLN></SenderGLN>
<ReceipientGLN></ReceipientGLN>
<SupplierGLN></SupplierGLN>
<BuyerGLN></BuyerGLN>
<DeliveryPartyGLN></DeliveryPartyGLN>
<UltimateConsignyGLN></UltimateConsignyGLN>
<ReturnGLN />
<SendFromGLN />
<SendToGLN />
<DeliveryCurrency></DeliveryCurrency>
</XMLDESADVHEADER>
<XMLDESADV>
</XMLDESADV>
<XMLPACKAGEGROUP>
<NumberOfPackages>
<xsl:choose>
<xsl:when
test="format-number(/ZFSHDLV/IDOC/E1EDL20/ANZPK,'#') > 0 ">
<xsl:value-of
select="format-number(/ZFSHDLV/IDOC/E1EDL20/ANZPK,'#')" />
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="1" />
</xsl:otherwise>
</xsl:choose>
</NumberOfPackages>
<PackageCode>
<xsl:value-of select="$PackageCode" />
</PackageCode>
</XMLPACKAGEGROUP>
<XMLSSCCGROUP>
<SSCC>
<xsl:value-of select="$SSCCID" />
</SSCC>
<PackageCode>
<xsl:value-of select="$PackageCode" />
</PackageCode>
<PackageType>
<xsl:value-of select="$PackageType" />
</PackageType>
<xsl:copy-of select="$POSITIONS" />
</XMLSSCCGROUP>
</XMLDESADV>
</xsl:template>
<xsl:template name="WithOutHandlingUnits">
<xsl:variable name="POSITIONS">
<xsl:for-each select="./E1EDL20/E1EDL24">
<XMLITEMS>
<PositionNumber>
<xsl:value-of select="./POSNR" />
</PositionNumber>
<GTIN>
<xsl:value-of select="./EAN11" />
</GTIN>
<DeliveredQuantity>
<xsl:value-of select="./LGMNG" />
</DeliveredQuantity>
<QuantityQualifier>
<xsl:call-template name="QuantityQualifier">
<xsl:with-param name="UoM">
<xsl:value-of select="./MEINS" />
</xsl:with-param>
</xsl:call-template>
</QuantityQualifier>
<DeliveryPrice></DeliveryPrice>
<ReferenceSupplierOrder>
<xsl:value-of select="./VGBEL" />
</ReferenceSupplierOrder>
<ReferenceBuyerOrder />
</XMLITEMS>
</xsl:for-each>
</xsl:variable>
<xsl:call-template name="Message">
<xsl:with-param name="CASE" select="'NoHandlingUnit'" />
<xsl:with-param name="ID" select="./E1EDL20/VBELN" />
<xsl:with-param name="SSCCID" select="./E1EDL20/VBELN" />
<xsl:with-param name="POSITIONS" select="$POSITIONS" />
</xsl:call-template>
</xsl:template>
<xsl:template name="HandlingUnit">
<xsl:for-each select="./E1EDL20/E1EDL37"> <!-- Looping over all E1EDL37 segments and create a new message -->
<xsl:variable name="POSITIONS">
<xsl:for-each select="./E1EDL44">
<xsl:variable name="position" select="./POSNR" />
<XMLITEMS>
<PositionNumber>
<xsl:value-of select="$position" />
</PositionNumber>
<GTIN>
<xsl:value-of
select="../../E1EDL24[POSNR = $position]/EAN11" />
</GTIN>
<DeliveredQuantity>
<xsl:value-of
select="../../E1EDL24[POSNR = $position]/LGMNG" />
</DeliveredQuantity>
<QuantityQualifier>
<xsl:call-template name="QuantityQualifier">
<xsl:with-param name="UoM">
<xsl:value-of
select="../../E1EDL24[POSNR = $position]/MEINS" />
</xsl:with-param>
</xsl:call-template>
</QuantityQualifier>
<DeliveryPrice></DeliveryPrice>
<ReferenceSupplierOrder>
<xsl:value-of
select="../../E1EDL24[POSNR = $position]/VGBEL" />
</ReferenceSupplierOrder>
<ReferenceBuyerOrder />
<xsl:if test="exists(./E1EPC03)">
<xsl:for-each select="./E1EPC03">
<XMLEPC>
<EPC>
<xsl:value-of select="./EPC" />
</EPC>
</XMLEPC>
</xsl:for-each>
</xsl:if>
</XMLITEMS>
</xsl:for-each>
</xsl:variable>
<xsl:call-template name="Message">
<xsl:with-param name="CASE" select="'HandlingUnit'" />
<xsl:with-param name="ID"
select="concat(../VBELN,'_',./EXIDV)" />
<xsl:with-param name="SSCCID"
select="format-number(./EXIDV,'#')" />
<xsl:with-param name="POSITIONS" select="$POSITIONS" />
</xsl:call-template>
</xsl:for-each>
</xsl:template>
<xsl:include href="./valueMaps2.xsl" />
</xsl:stylesheet>