Synchronization forcefully DB through X++
here is the code for synchronization DB in X++.
static void DBSync(Args _args )
{
Dictionary dict;
int idx,lastIdx,totalTables;
TableId tableId;
Application application;
SysOperationProgress progress;
StackBase errorStack;
ErrorTxt errorTxt;
application = new Application();
dict = new Dictionary();
totalTables = dict.tableCnt();
progress = new SysOperationProgress();
progress.setTotal(TotalTables);
progress.setCaption("TEst");
errorStack = new StackBase(Types::String);
lastIdx = 0;
try
{
for (idx = lastIdx + 1; idx <= totalTables ; idx++)
{
tableId = dict.tableCnt2Id(idx);
progress.setText(dict.tableName(tableId));
lastIdx = idx;
application.dbSynchronize(tableId,false,true,false);
progress.incCount();
}
}
catch(Exception::Error)
{
errorTxt = strFmt("Error in table '%1 (%2)'",tableId,dict.tableName(tableId));
errorStack.push(errorTxt);
retry;
}
setPrefix('Test2');
errorTxt = errorStack.pop();
while (errorTxt)
{
error(errorTxt);
errorTxt = errorStack.pop();
}
}
now run job.
No comments:
Post a Comment