static void PBU_DEV_001(Args _args)
{
System.Data.DataTable _C_CustTable = new System.Data.DataTable("CustTable");
System.Data.DataColumnCollection _C_Columns = _C_CustTable.get_Columns();
System.Data.DataColumn _C_CustAccount;
System.Data.DataColumn _C_CustName;
System.Data.DataRow _C_Row;
System.Data.DataRowCollection _C_Rows = _C_CustTable.get_Rows();
int _i;
int _RowCount;
CustTable _CustTable;
AccountNum _CustAccount;
Name _CustName;
_C_CustAccount = new System.Data.DataColumn("CustAccount", System.Type::GetType("System.String"));
_C_CustName = new System.Data.DataColumn("CustName", System.Type::GetType("System.String"));
_C_Columns.Add(_C_CustAccount);
_C_Columns.Add(_C_CustName);
while
select firstOnly100 _CustTable
{
_C_Row = _C_CustTable.NewRow();
_C_Row.set_Item("CustAccount", _CustTable.AccountNum);
_C_Row.set_Item("CustName", _CustTable.name());
_C_Rows.Add(_C_Row);
}
_RowCount = _C_Rows.get_Count();
for (_i = 0; _i <= _RowCount; _i++)
{
_C_Row = _C_Rows.get_Item(_i);
_CustAccount = _C_Row.get_Item(_C_CustAccount);
_CustName = _C_Row.get_Item(_C_CustName);
info(strFmt("%1,%2", _CustAccount, _CustName));
}
}
PBU's notes
Jul 17, 2019
Mar 19, 2019
How to extract the object list from project in X++
ProjectListNode _ProjectListNode = infolog.projectRootNode().AOTfindChild("Private");
ProjectNode _ProjectNode = _ProjectListNode.AOTfindChild("Your project name");
PBU_ProjectManagementTmp _ProjectManagementTmp;
str _ObjectPath = "";
str _ObjectType = "";
void searchAllObj(projectNode _rootNode)
{
#TreeNodeSysNodeType
TreeNode _childNode;
TreeNodeIterator _rootNodeIterator;
if (_rootNode)
{
_rootNodeIterator = _rootNode.AOTiterator();
_childNode = _rootNodeIterator.next();
while (_childnode)
{
if (_childNode.treeNodeType().id() == #NT_PROJECT_GROUP)
{
searchAllObj(_childNode);
}
else
{
/*
//Path
_childNode.treeNodePath();
//Object type (AOT)
PBU_ProjectHelper::Get_ProjectObjectNameViaPath(subStr(strReplace(_childNode.treeNodePath(),_childNode.AOTname(),""),1,strLen(strReplace(_childNode.treeNodePath(),_childNode.AOTname(),""))-1));
//Object name (AOT)
_childNode.AOTname();
*/
}
_childNode = _rootNodeIterator.next();
}
}
}
if (_ProjectNode)
{
searchAllObj(_ProjectNode.loadForInspection());
}
ProjectNode _ProjectNode = _ProjectListNode.AOTfindChild("Your project name");
PBU_ProjectManagementTmp _ProjectManagementTmp;
str _ObjectPath = "";
str _ObjectType = "";
void searchAllObj(projectNode _rootNode)
{
#TreeNodeSysNodeType
TreeNode _childNode;
TreeNodeIterator _rootNodeIterator;
if (_rootNode)
{
_rootNodeIterator = _rootNode.AOTiterator();
_childNode = _rootNodeIterator.next();
while (_childnode)
{
if (_childNode.treeNodeType().id() == #NT_PROJECT_GROUP)
{
searchAllObj(_childNode);
}
else
{
/*
//Path
_childNode.treeNodePath();
//Object type (AOT)
PBU_ProjectHelper::Get_ProjectObjectNameViaPath(subStr(strReplace(_childNode.treeNodePath(),_childNode.AOTname(),""),1,strLen(strReplace(_childNode.treeNodePath(),_childNode.AOTname(),""))-1));
//Object name (AOT)
_childNode.AOTname();
*/
}
_childNode = _rootNodeIterator.next();
}
}
}
if (_ProjectNode)
{
searchAllObj(_ProjectNode.loadForInspection());
}
DataSource field allowEdit in X++
LedgerJournalTrans_ds.object(fieldNum(LedgerJournalTrans, AccountType)).allowEdit(false);
Mar 17, 2019
Get size of all tables in database
SELECT
T.NAME AS TABLENAME,
S.NAME AS SCHEMANAME,
P.ROWS AS ROWCOUNTS,
SUM(A.TOTAL_PAGES) * 8 AS TOTALSPACEKB,
CAST(ROUND(((SUM(A.TOTAL_PAGES) * 8) / 1024.00), 2) AS NUMERIC(36, 2)) AS TOTALSPACEMB,
SUM(A.USED_PAGES) * 8 AS USEDSPACEKB,
CAST(ROUND(((SUM(A.USED_PAGES) * 8) / 1024.00), 2) AS NUMERIC(36, 2)) AS USEDSPACEMB,
(SUM(A.TOTAL_PAGES) - SUM(A.USED_PAGES)) * 8 AS UNUSEDSPACEKB,
CAST(ROUND(((SUM(A.TOTAL_PAGES) - SUM(A.USED_PAGES)) * 8) / 1024.00, 2) AS NUMERIC(36, 2)) AS UNUSEDSPACEMB
FROM
SYS.TABLES T
INNER JOIN
SYS.INDEXES I ON T.OBJECT_ID = I.OBJECT_ID
INNER JOIN
SYS.PARTITIONS P ON I.OBJECT_ID = P.OBJECT_ID AND I.INDEX_ID = P.INDEX_ID
INNER JOIN
SYS.ALLOCATION_UNITS A ON P.PARTITION_ID = A.CONTAINER_ID
LEFT OUTER JOIN
SYS.SCHEMAS S ON T.SCHEMA_ID = S.SCHEMA_ID
WHERE
T.NAME NOT LIKE 'DT%'
AND T.IS_MS_SHIPPED = 0
AND I.OBJECT_ID > 255
GROUP BY
T.NAME, S.NAME, P.ROWS
ORDER BY
T.NAME
https://stackoverflow.com/questions/7892334/get-size-of-all-tables-in-database
T.NAME AS TABLENAME,
S.NAME AS SCHEMANAME,
P.ROWS AS ROWCOUNTS,
SUM(A.TOTAL_PAGES) * 8 AS TOTALSPACEKB,
CAST(ROUND(((SUM(A.TOTAL_PAGES) * 8) / 1024.00), 2) AS NUMERIC(36, 2)) AS TOTALSPACEMB,
SUM(A.USED_PAGES) * 8 AS USEDSPACEKB,
CAST(ROUND(((SUM(A.USED_PAGES) * 8) / 1024.00), 2) AS NUMERIC(36, 2)) AS USEDSPACEMB,
(SUM(A.TOTAL_PAGES) - SUM(A.USED_PAGES)) * 8 AS UNUSEDSPACEKB,
CAST(ROUND(((SUM(A.TOTAL_PAGES) - SUM(A.USED_PAGES)) * 8) / 1024.00, 2) AS NUMERIC(36, 2)) AS UNUSEDSPACEMB
FROM
SYS.TABLES T
INNER JOIN
SYS.INDEXES I ON T.OBJECT_ID = I.OBJECT_ID
INNER JOIN
SYS.PARTITIONS P ON I.OBJECT_ID = P.OBJECT_ID AND I.INDEX_ID = P.INDEX_ID
INNER JOIN
SYS.ALLOCATION_UNITS A ON P.PARTITION_ID = A.CONTAINER_ID
LEFT OUTER JOIN
SYS.SCHEMAS S ON T.SCHEMA_ID = S.SCHEMA_ID
WHERE
T.NAME NOT LIKE 'DT%'
AND T.IS_MS_SHIPPED = 0
AND I.OBJECT_ID > 255
GROUP BY
T.NAME, S.NAME, P.ROWS
ORDER BY
T.NAME
https://stackoverflow.com/questions/7892334/get-size-of-all-tables-in-database
Subscribe to:
Posts (Atom)