Skip to main content
InSource Solutions

Writing XML Transaction Files with App. Server Scripts

Overview

There are occasions where other system many need to pick up transaction information executed by App Server in XML format. This is a how-to example where a App Server passed transaction information to a third party system using XML files.

Resolution

In a template object create UDA's for the following, and script as below. Note: if you XML nomenclature is different then modify as needed.

UDAs


All below are String data type UDA's except for the Trigger (boolean)

Plant
WONumber
LotNumber
Product
Operator
QtyPrimary
QtySecondary
XMLPath

TrigXMLWriter

Script

 

Me.TrigXMLWriter = false;
Dim tw As System.Xml.XmlTextWriter;
Dim en As System.Text.UTF8Encoding;
' Set XML writer ... Me.XMLPath is a path to your file location
' Network (UNC) or local (C:\...)

en = New System.Text.UTF8Encoding();
tw = new System.Xml.XmlTextWriter(Me.XMLPath + "\" + Me.LotNumber + ".xml", en);
tw.Formatting = System.Xml.Formatting.Indented;
tw.Indentation = 4;
' Write out Item information
tw.WriteStartDocument();
tw.WriteComment("Produced on " + Now());
tw.WriteStartElement("Root");
tw.WriteAttributeString("TransactionType", "LotStart");
' Write Content
tw.WriteStartElement("UnitStart");
tw.WriteElementString("Plant", Me.Plant);
tw.WriteElementString("WONumber", Me.WONumber);
tw.WriteElementString("Container", Me.LotNumber);
tw.WriteElementString("Product", Me.Product);
tw.WriteElementString("Operator", Me.Operator);
tw.WriteElementString("Qty", Me.QtyPrimary);
tw.WriteElementString("Qty2", Me.QtySecondary);
' Close elements
tw.WriteEndElement();
tw.WriteEndElement();
tw.WriteEndDocument();
' Close the files
tw.Flush();
tw.Close();

         

 

Resulting file content

<?xml version="1.0" encoding="utf-8"?>
<!--Produced on 2/17/2009 11:32:38.540 AM-->
<Root TransactionType="LotStart">
    <UnitStart>
        <Plant>APS</Plant>
        <WONumber>98765</WONumber>
        <Container>12345</Container>
        <Product>XYZ</Product>
        <Operator>JBT</Operator>
        <Qty>2</Qty>
        <Qty2>3</Qty2>
    </UnitStart>
</Root>

 

J.B.T.