Provide Mapping Details

About this task

If you want to send work order, process order, or material details in a B2MML or an XML file, 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

  1. Create an XSL file.
    Tip: Create the XSL file based on the standard B2MML or XML file that you want to create. You can also refer to the sample files in the Reference section.
  2. 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
      
  3. Run the script.

Results

When you send a B2MML or XML file, it is converted to a JSON file by the ERP Transformation service using the mapping you have specified, and then imported to Plant Applications.