Provide Mapping Details
About this task
If you want to send work order, process order, material, or material lot details in a custom or standard B2MML format, you must map the fields using an XSL document. When you install Plant Applications, a default XSL file is provided. The supported XSL version is 1.0.
Procedure
- Create an XSL file.Tip: Create the XSL file based on the standard or custom B2MML file that you want to create. You can also refer to the sample files in the Reference section.
- Access the [erp].[MappingSpecification] table of the Microsoft SQL database, and perform the following steps as applicable:
- If you want to provide the mapping details for a work order, replace the following xml code with the xml code from the XSL file that you have created.
IF EXISTS (Select 1 from [erp].[MappingSpecification] where Resource_Type = 'WorkOrder') BEGIN UPDATE [erp].[MappingSpecification] SET Specification = '<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:template match="@* | node()"> <xsl:copy> <xsl:apply-templates select="@* | node()"/> </xsl:copy> </xsl:template> </xsl:stylesheet>' where Resource_Type = 'WorkOrder' END ELSE BEGIN INSERT INTO [erp].[MappingSpecification] (Specification, Resource_Type) VALUES ('<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:template match="@* | node()"> <xsl:copy> <xsl:apply-templates select="@* | node()"/> </xsl:copy> </xsl:template> </xsl:stylesheet>', 'WorkOrder') END
- If you want to provide the mapping details for a process order, replace the following xml code with the xml code from the XSL file that you have created.
IF EXISTS (Select 1 from [erp].[MappingSpecification] where Resource_Type = 'ProcessOrder') BEGIN UPDATE [erp].[MappingSpecification] SET Specification = '<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:template match="@* | node()"> <xsl:copy> <xsl:apply-templates select="@* | node()"/> </xsl:copy> </xsl:template> </xsl:stylesheet>' where Resource_Type = 'ProcessOrder' END ELSE BEGIN INSERT INTO [erp].[MappingSpecification] (Specification, Resource_Type) VALUES ('<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:template match="@* | node()"> <xsl:copy> <xsl:apply-templates select="@* | node()"/> </xsl:copy> </xsl:template> </xsl:stylesheet>', 'ProcessOrder') END
- If you want to provide the mapping details for a material, replace the following xml code with the xml code from the XSL file that you have created.
IF EXISTS (Select 1 from [erp].[MappingSpecification] where Resource_Type = 'Material') BEGIN UPDATE [erp].[MappingSpecification] SET Specification = '<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:template match="@* | node()"> <xsl:copy> <xsl:apply-templates select="@* | node()"/> </xsl:copy> </xsl:template> </xsl:stylesheet>' where Resource_Type = 'Material' END ELSE BEGIN INSERT INTO [erp].[MappingSpecification] (Specification, Resource_Type) VALUES ('<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:template match="@* | node()"> <xsl:copy> <xsl:apply-templates select="@* | node()"/> </xsl:copy> </xsl:template> </xsl:stylesheet>', 'Material') END
- If you want to provide the mapping details for a work order, replace the following xml code with the xml code from the XSL file that you have created.
- Run the script.