hey all tell me where i m wrong in this code i want to copy the table data from one company to anoter company using the table variable in ax 2009 pls help.
below is code for the job pls correct my error
static void CompanyCopyTable(Args _args)
{
Dialog dialog;
DialogField field,field1,field2;
str cname,cname1;
common c;
CustoTable custTable1;
CustoTable custTable2,custTable3;
int cid,cgrp;
str bl,name,pl,dl;
Args args = new Args();
;
dialog = new Dialog("CompanyCross");
dialog.addText("Select the source company:");
field = dialog.addField(typeid(dataAreaId));
dialog.addText("Select the destination company:");
field1 = dialog.addField(typeid(dataAreaId));
dialog.run();
if(dialog.closedOk() == true)
{
cname = field.value();
info(cname);
cname1 = field1.value();
info(cname1);
changecompany(cname1)
{
while select custTable2
{
ttsbegin;
select forupdate custTable2;
if(custTable2.validateDelete())
custTable2.delete();
ttscommit;
}
}
changecompany(cname)
{
while select custTable1
{
custTable3.data(custTable1);
changecompany(cname1)
{
ttsbegin;
//uf2buf(custTable1, custTable2);
custTable2.data(custTable3);
if (!custTable2.validateWrite())
{
throw Exception::Error;
}
custTable2.insert();
ttscommit;
}
}
}
}
}