TN MES109 Example API Call to Read Lot Attribute Data in MES
Description
This article from InSource Provides an example script to read a Lot Attributes data in Wonderware MES using the Stateless API.
- Author: Michael Walker
- Published: 09/25/2015
- Applies to: Wonderware MES 2014 and Later
Details
Below is the example script. Note the To Do comments to make the script functional.
try;
''declarations
dim oResult as aaMES.Result;
dim ItemID as string;
dim LotNo as string;
dim Attr as string;
dim oDS as System.Data.DataTable;
dim oDR as System.Data.DataRow;
''To Do - Set ItemID, Attr and LotNo strings here!
oResult = aaMES.Prod.aaLotAttr.GetAttrs(ItemID,LotNo,"Admin");
if (oResult.Success == true) then
oDS = oResult.DataSet_Value.Tables(0);
if oDS.Rows.Count > 0 then
for each oDR in oDS.Rows();
if oDR["attr_desc"] == Attr then
logmessage( oDR["attr_value"].ToString());
''To Do - Set Object Attibute or other data here to return from API Call!
endif;
next;
else
endif;
else
endif;
catch;
LogError(error.Message.ToString());
LogError(error.InnerException.Message.ToString());
endtry;