Thursday, 30 June 2016
How we can find database size in AX 2012 using X++
By using following code, we can find database size in AX using code.
static void dBSize(Args _args)
{
LoginProperty loginProperty;
ODBCConnection odbcConnection;
Resultset resultSet;
Statement statement;
SysSQLSystemInfo systemInfo;
str sqlStatement;
real size;
;
systemInfo = SysSQLSystemInfo::construct();
sqlStatement = strfmt( "SELECT size FROM sys.master_files where name = '%1'",systemInfo.getloginDatabase());
loginProperty = new LoginProperty();
loginProperty.setServer(systemInfo.getLoginServer());
loginProperty.setDatabase(systemInfo.getloginDatabase());
odbcConnection = new ODBCConnection(loginProperty);
statement = odbcConnection.createStatement();
resultSet = statement.executeQuery(sqlStatement);
while (resultSet.next())
{
size = str2int(resultSet.getString(1));
size = size*8 /1024;
info(strfmt("%1 MB",size));
}
}
static void dBSize(Args _args)
{
LoginProperty loginProperty;
ODBCConnection odbcConnection;
Resultset resultSet;
Statement statement;
SysSQLSystemInfo systemInfo;
str sqlStatement;
real size;
;
systemInfo = SysSQLSystemInfo::construct();
sqlStatement = strfmt( "SELECT size FROM sys.master_files where name = '%1'",systemInfo.getloginDatabase());
loginProperty = new LoginProperty();
loginProperty.setServer(systemInfo.getLoginServer());
loginProperty.setDatabase(systemInfo.getloginDatabase());
odbcConnection = new ODBCConnection(loginProperty);
statement = odbcConnection.createStatement();
resultSet = statement.executeQuery(sqlStatement);
while (resultSet.next())
{
size = str2int(resultSet.getString(1));
size = size*8 /1024;
info(strfmt("%1 MB",size));
}
}
Wednesday, 29 June 2016
Create production order in AX using X++
static
void
CreateProductionOrder(Args _args)
{
ProdQty qty = 50;
ItemId item =
'1234'
;
ProdTable prodtable;
InventTable inventTable;
InventDim inventDim;
;
// Initialize InventTable
inventTable = inventTable::find(item);
// Initialize the base values
prodtable.initValue();
prodtable.initFromInventTable(inventTable);
prodtable.ItemId = inventTable.ItemId;
prodtable.DlvDate = today();
prodtable.QtySched = qty;
prodtable.RemainInventPhysical = qty;
// Initialize InventDim (Obrigatory)
inventDim.initValue();
// Set the active BOM and Route
prodtable.BOMId = BOMVersion::findActive(prodtable.ItemId,
prodtable.BOMDate,
prodtable.QtySched,
inventDim).BOMId;
prodtable.RouteId = RouteVersion::findActive(prodtable.ItemId,
prodtable.BOMDate,
prodtable.QtySched,
inventDim).RouteId;
// Initialize BOMVersion
prodtable.initBOMVersion();
// Initialize RouteVersion
prodtable.initRouteVersion();
//Use ProdTableType class to create the production order
prodtable.type().insert();
// Inform Production Order Id
setPrefix(
'Production Order'
);
setPrefix(
'Production Order Number'
);
info(prodtable.ProdId);
}
Subscribe to:
Posts (Atom)