Wednesday, February 4, 2009

Extracting data from Ax3.0 to Xml

Sample code to get XML from table:
============ ========= ==
static XML getAllDlvMode( )
{
DlvMode dlvMode;
XML xml;
;
xml = '';
while select Code, txt
from dlvMode
where dlvMode.dataAreaId == 'dat'
{
xml += dlvmode.xml( );
}
xml += '
';
return xml;
}
============ ========= ========= =======

Sample code to load and parse XML file:
============ ========= ========= =======
XMLDocument XMLDOM;
XMLNodeList XMLNodes_ItemOut;
TextBuffer tbPurchOrder;
boolean blnXMLLoaded;
str nodeText;
;
XMLDOM = new XMLDocument( ) ;
XMLDOM.async( false);
XMLDOM.setProperty( "ServerHTTPReque st", true);
strUNCFileName_ reg = strfmt("%1", _strFileName) ;
tbPurchOrder = new TextBuffer() ;
tbPurchOrder. fromFile( strRTrim( strLTrim( strUNCFileName_ reg)));
temp = tbPurchOrder. getText() ;
blnXMLLoaded = XMLDOM.loadXML( temp);

if(blnXMLLoaded)
{
//parse the XMLDOM
nodeText = strXMLDOM.selectSin gleNode(" path/nodeName" ).text
();
}

============ ========= ========= ========= ========= =========


Sample code to write a file
============ ========= ========= ========= ========= ========= =========
AsciiIo oAsciiIo;
str strFilePath, strMode, strLog;
;
//oAsciiIo = new AsciiIo(strFileName , "A");
oAsciiIo = new AsciiIo(strFilePath , strMode);
oAsciiIo.write( strLog);
/*
You may use WinAPI static methods to create and manage folders.
e.g.: if (!WinAPI::folderExi sts(strFolderPat h)) 
WinAPI::createDirec tory(strFolderPa th);
*/

============ ========= ========= ========= ========= ========= ========

No comments:

How to identify the user that was used to change an object from AOT in AX2012

Get the object name for which we need to track these (user and date&time) information's. Login to SQL Server Management Studio an...