AX2009: Need help combining 2 jobs to list tables and fields

Hi,

I’m relatively new to X++ and need some help.

I have 2 axapta jobs I found, one lists all tables in the system (Findtables),
the other (job68) lists all fields belonging to a hardcoded table. Below are the jobs,
their output, and the output I would like.

Basically I would like to run an AX job that loops thru all the tables and then all the
fields for that table and produces a output of the table and field name by row, table
name repeating. Example at bottom.

I was trying to combine the 2 jobs but no success so far.
Thanks
Kevin

//=========================================================================findtables
static void findTables(Args _args)
{
Dictionary dictionary;
TableId tableId;
tableName tableName;
;

dictionary = new Dictionary();

tableId = dictionary.tableNext(0);
tableName = dictionary.tableName(tableId);

while (tableId)
{
info(strfmt("%1 - %2",int2str(tableId), tableName));

tableId = dictionary.tableNext(tableId);
tableName = dictionary.tableName(tableId);
}
}

//=========================================================================findtables output

Info Message (12:54:18 pm) 1 - Address
Info Message (12:54:18 pm) 2 - AddressFormatHeading
Info Message (12:54:18 pm) 3 - AddressFormatLines
Info Message (12:54:18 pm) 4 - PurchRFQLineMap
Info Message (12:54:18 pm) 5 - BankGroup
Info Message (12:54:18 pm) 6 - RFIDProcessStructureTmp
Info Message (12:54:18 pm) 7 - BankAccountTable
Info Message (12:54:18 pm) 8 - BankAccountTrans
Info Message (12:54:18 pm) 9 - BankChequeLayout
Info Message (12:54:18 pm) 10 - BankChequeTable
Info Message (12:54:18 pm) 11 - BankDeposit
Info Message (12:54:18 pm) 12 - BankTransType
Info Message (12:54:18 pm) 13 - DEL_Batch
Info Message (12:54:18 pm) 14 - DEL_BatchGroup

etc etc.

//=========================================================================job68
static void Job68(Args _args)
{

TreeNode node = TreeNode::findNode(@’\Data dictionary\Tables\PBATable\Fields’);
TreeNode childNode;
TreeNodeIterator nodeIT;

tab
nodeIt = node.AOTiterator();

childNode = nodeIt.next();

while(childNode)
{
info(strfmt(“PBATable %1”, childNode.treeNodeName()));
childNode = nodeIt.next();
}
}

//=========================================================================job68 output

Info Message (12:56:37 pm) PBATable PBAId
Info Message (12:56:37 pm) PBATable Name
Info Message (12:56:37 pm) PBATable ItemGroupId
Info Message (12:56:37 pm) PBATable ApprovedBy
Info Message (12:56:37 pm) PBATable Approved
Info Message (12:56:37 pm) PBATable CodeUpdated
Info Message (12:56:37 pm) PBATable DEL_Code
Info Message (12:56:37 pm) PBATable ItemRouteId
Info Message (12:56:37 pm) PBATable ItemBOMId
Info Message (12:56:37 pm) PBATable RulesChecked
Info Message (12:56:37 pm) PBATable InventTransId

//=========================================================================output I want

Info Message (12:58:21 pm) Address AddrTableId
Info Message (12:58:21 pm) Address AddrRecId
Info Message (12:58:21 pm) Address LineNum
Info Message (12:58:21 pm) Address type
Info Message (12:58:21 pm) Address Name
Info Message (12:58:21 pm) Address Address
Info Message (12:58:21 pm) Address Phone
Info Message (12:58:21 pm) Address TeleFax
Info Message (12:58:21 pm) Address CountryRegionId
Info Message (12:58:21 pm) Address ZipCode
Info Message (12:58:21 pm) Address State
Info Message (12:58:21 pm) Address County
Info Message (12:58:21 pm) Address Telex
Info Message (12:58:21 pm) Address URL
Info Message (12:58:21 pm) Address PhoneLocal
Info Message (12:58:21 pm) Address CellularPhone
Info Message (12:58:21 pm) Address Email
Info Message (12:58:21 pm) Address TaxGroup
Info Message (12:58:21 pm) Address City
Info Message (12:58:21 pm) Address Street
Info Message (12:58:21 pm) Address Pager
Info Message (12:58:21 pm) Address SMS
Info Message (12:58:21 pm) Address DEL_RefZipCode
Info Message (12:58:21 pm) Address Latitude
Info Message (12:58:21 pm) Address Longitude
Info Message (12:58:21 pm) Address SalesCalendarId
Info Message (12:58:21 pm) Address FRCARAddressing
Info Message (12:58:21 pm) Address TimeZone
Info Message (12:58:21 pm) Address IsPrimary
Info Message (12:58:21 pm) Address DlvTerm
Info Message (12:58:21 pm) Address DlvMode
Info Message (12:58:21 pm) Address ShipCarrierId
Info Message (12:58:21 pm) Address ShipCarrierBlindShipment
Info Message (12:58:21 pm) Address ShipCarrierAccount
Info Message (12:58:21 pm) Address ShipCarrierAccountCode
Info Message (12:58:21 pm) Address ShipCarrierResidential

Info Message (12:59:02 pm) AddressFormatHeading AddrFormat
Info Message (12:59:02 pm) AddressFormatHeading Name

Info Message (12:59:45 pm) AddressFormatLines AddrFormat
Info Message (12:59:45 pm) AddressFormatLines InActive
Info Message (12:59:45 pm) AddressFormatLines Separator
Info Message (12:59:45 pm) AddressFormatLines Element
Info Message (12:59:45 pm) AddressFormatLines SeparatorCrLf
Info Message (12:59:45 pm) AddressFormatLines Expand
Info Message (12:59:45 pm) AddressFormatLines LineNum
Info Message (12:59:45 pm) AddressFormatLines Special
Info Message (12:59:45 pm) AddressFormatLines NumOfSpaces

etc etc

Hi kevin,

This job will work!

static void findTables(Args _args)
{
Dictionary dictionary;
TableId tableId;
tableName tableName;
fieldid fieldid;
DictTable dicttable;

;

dictionary = new Dictionary();

tableId = dictionary.tableNext(0);
tableName = dictionary.tableName(tableId);

while (tableId)
{
info(strfmt("%1 - %2",int2str(tableId), tableName));

dicttable=new DictTable(tableid);

fieldid=dicttable.fieldNext(0);

while(fieldid)
{
info(strfmt("%1-%2",tableName,dicttable.fieldName(fieldid)));
fieldid=dicttable.fieldNext(fieldid);
}

tableId = dictionary.tableNext(tableId);
tableName = dictionary.tableName(tableId);
}
}

Meanwhile take a nap…[:D] and be back…

Narayan PS

this post is to be moved to AX forum!!!

Narayan,

It worked great! Except…:slight_smile:

I got the following message…

Warning Message (12:28:18 pm) The number of messages exceeds the limit of the Infolog (10000.)

So I didn’t get all the database tables, so my idea about outputting to the infolog is flawed, unless the limit can be bumped. It’s probably

a better idea to write to a local file, my editor can handle unlimited rows. If you have a quick solution let me know, otherwise I’ll go off and try to figure it,

thanks again

Kevin

p.s I’m in AX2009…if this is the wrong forum my apologies.

Refer this to write to a file.It works out!

http://dynamicsuser.net/forums/p/16784/78934.aspx#78934

regards,

narayan ps

Hi Kevin,

Hope this helps - http://harish-m.livejournal.com/3514.html?thread=72122

Regards,

Regarding limit of infolog - this limit is defined as a macro (MaxErrors) under ‘AOT → Classes → Info → viewBuild’

In theory this limit can be increased. However this is not advisable as there could be significant performance implications.