AX Tables: Copy all table data to another table
Sometimes there is a need to copy the data that is in one table into a new table. This can be due to synchronization issues where the data in a table may be lost, just wanting to tinker with the data, or whatever other reason you want. Here is a basic way to do this.
- In the development workspace, right click on the table (we will call this KTable) and select 'Duplicate'. This will create a new table. We will rename this table KTable_Copy
- Copy, paste, and run the below code into an AX job
// Copy data from one dropped table to another
static void daxCopyTableData(Args _args)
{
KTable KTable;
KTable_Copy KTable_Copy;
;
ttsBegin;
// Clear the data from the copy table
delete_from KTable_Copy;
while select KTable
{
buf2Buf(KTable, KTable_Copy);
KTable_Copy.insert();
}
ttsCommit;
}
No comments:
Post a Comment