Some content on this site is available only to logged-in subscribers. Contact Us for information on becoming a subscriber.

InSource.Solutions | InSource Training | InSource Client Portal
InSource Solutions Logo
Log In Sign Up
InSource.Solutions InSource Training InSource Client Portal Log In Sign Up
  • Home
  • AVEVA Application Server
  • AVEVA Application Server Tech Notes

Writing XML Transaction Files with App. Server Scripts

Last updated: March 6th, 2025

Description

  • Author: Brian Schneider
  • Published: March 6th, 2025

Details:

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.

xml scripts
Give feedback about this article

Recommended articles

TN - 1240 Creating a Watchlist Using an Import File

Read More
Support Icon

CONTACT SUPPORT

How to reach us

10800 Midlothian Turnpike Tpke, Suite 209, Richmond, VA 23235

1.877.INSOURCE

Technical Support - 1.888.691.3858

Contact Us

  • InSource Solutions
  • InSource Training
  • InSource Client Portal
  • Log In
InSource Solutions Logo

© 2025 InSource Solutions. All Rights Reserved.

Knowledge Base Software powered by Helpjuice

Expand