static void RenamePrimaryKey(Args _args)
{
LedgerTable ledgerTable;
;
select firstonly ledgerTable
where ledgerTable.AccountNum == '01010';
if(ledgerTable.RecId)
{
ledgerTable.AccountNum = 'K' + ledgerTable.AccountNum;
ledgerTable.renamePrimaryKey();
}
info(ledgerTable.AccountNum);
}
Tuesday, August 31, 2010
Sunday, August 22, 2010
Creating the Table and table fields in AOT through code
static void CreatingTable(Args _args)
{
TreeNode treeNode;
AOTTableFieldList fieldList;
AccountNum AccountNum;
int field;
;
//Finding the path for tables from the Data Dictionary...
treeNode = TreeNode::findNode(@'\Data Dictionary\Tables\');
treeNode.AOTfindChild('Tables');
//Adding the new table...
treeNode.AOTadd('Axapta');
//Finding the new table which added in the above code...
treeNode.AOTfindChild('Axapta');
//adding the fields in the new created table...
for(field = 1 ; field <= 10 ; field++)
{
fieldList = treeNode.AOTfindChild('Axapta').AOTfindChild('fields');
fieldList.addString('field');
}
}
{
TreeNode treeNode;
AOTTableFieldList fieldList;
AccountNum AccountNum;
int field;
;
//Finding the path for tables from the Data Dictionary...
treeNode = TreeNode::findNode(@'\Data Dictionary\Tables\');
treeNode.AOTfindChild('Tables');
//Adding the new table...
treeNode.AOTadd('Axapta');
//Finding the new table which added in the above code...
treeNode.AOTfindChild('Axapta');
//adding the fields in the new created table...
for(field = 1 ; field <= 10 ; field++)
{
fieldList = treeNode.AOTfindChild('Axapta').AOTfindChild('fields');
fieldList.addString('field');
}
}
Sunday, August 15, 2010
Saturday, August 14, 2010
Link the two Data Source by using Query...
static void Query(Args _args)
{
Query q;
QueryRun qr;
QueryBuildDataSource custDataSource,transDataSource;
QueryBuildRange qbr;
QueryBuildLink qbl;
CustTable custTable;
CustTrans custTrans;
;
q = new Query();
//Adding the parent DataSource
custDataSource = q.addDataSource(tablenum(CustTable));
//Adding the range
qbr = custDataSource.addRange(fieldnum(CustTable,AccountNum));
custDataSource.addSortField(fieldnum(CustTable,AccountNum));
transDataSource = custDataSource.addDataSource(tablenum(custTrans));
//Adding the Inner join for the two tables CustTable and CustTrans
transDataSource.joinMode(JoinMode::InnerJoin);
//Adding the relation for the two tables
//If the realtion doesn't exists
qbl =
transDataSource.addLink(fieldnum(CustTable,AccountNum),fieldnum(CustTrans,Accountnum));
//If the relation already exists for the two tables in the table level...
//Then we can use the following one...
transDataSource.relations(true);
qr = new QueryRun(q);
while(qr.next())
{
//Logic to print the data from query..
}
}
{
Query q;
QueryRun qr;
QueryBuildDataSource custDataSource,transDataSource;
QueryBuildRange qbr;
QueryBuildLink qbl;
CustTable custTable;
CustTrans custTrans;
;
q = new Query();
//Adding the parent DataSource
custDataSource = q.addDataSource(tablenum(CustTable));
//Adding the range
qbr = custDataSource.addRange(fieldnum(CustTable,AccountNum));
custDataSource.addSortField(fieldnum(CustTable,AccountNum));
transDataSource = custDataSource.addDataSource(tablenum(custTrans));
//Adding the Inner join for the two tables CustTable and CustTrans
transDataSource.joinMode(JoinMode::InnerJoin);
//Adding the relation for the two tables
//If the realtion doesn't exists
qbl =
transDataSource.addLink(fieldnum(CustTable,AccountNum),fieldnum(CustTrans,Accountnum));
//If the relation already exists for the two tables in the table level...
//Then we can use the following one...
transDataSource.relations(true);
qr = new QueryRun(q);
while(qr.next())
{
//Logic to print the data from query..
}
}
Exporting the data to doc format
static void exportToFile(Args _args)
{
CommaIO myFile;
SqlDictionary sqlDictionary;
TableName tableName;
LedgerTable ledgerTable;
Container con;
;
tablename = "ledgerTable";
select * from sqlDictionary where tablename2id(tablename) == sqlDictionary.tabId;
if(sqlDictionary.RecId > 0)
{
myfile = new CommaIO("C:\\LedgerData.doc","w");
myfile.outFieldDelimiter("\t"); //Leave spaces for each column
while select ledgerTable
{
con = [ledgerTable.AccountNum,ledgerTable.AccountName];
myFile.writeExp(con);
}
}
}
{
CommaIO myFile;
SqlDictionary sqlDictionary;
TableName tableName;
LedgerTable ledgerTable;
Container con;
;
tablename = "ledgerTable";
select * from sqlDictionary where tablename2id(tablename) == sqlDictionary.tabId;
if(sqlDictionary.RecId > 0)
{
myfile = new CommaIO("C:\\LedgerData.doc","w");
myfile.outFieldDelimiter("\t"); //Leave spaces for each column
while select ledgerTable
{
con = [ledgerTable.AccountNum,ledgerTable.AccountName];
myFile.writeExp(con);
}
}
}
Subscribe to:
Posts (Atom)