Wednesday, May 21, 2014

Job to Create N number of companys and import the data in it.


//Job to Create N number of companys and import the data in it.

static void CreateCompanies(Args _args)
{
DataArea dataarea;
counter i;
CompanyDomainList companyDomainList;
CompanyDomainList cCompanyDomainList;
sysdataImport sysDataimport;
Application gappl = new Application();
filename filename;
;
filename = "D:\\Computer\\0";

for(i=1 ; i<301 ; i++)
{
DataArea.clear();
DataArea.Id = 'C' + int2str(i);
DataArea.name = 'Company' + int2str(i);
DataArea.insert();
xDataArea::insertPost(dataArea);

while select * from companyDomainList where companyDomainList.CompanyId == DataArea.Id
{
select firstonly cCompanyDomainList
where cCompanyDomainList.CompanyId == DataArea.Id &&
cCompanyDomainList.DomainId == companyDomainList.DomainId;

if (!cCompanyDomainList)
{
cCompanyDomainList.data(companyDomainList.data());
cCompanyDomainList.CompanyId = DataArea.Id;
cCompanyDomainList.insert();
}

//create the default company
gappl.setDefaultCompany(DataArea.Id,false);
syssecurity::reload(false);
InfoLog.navPane().loadStartupButtons();
Infolog.navPane().refreshFavorites(infolog.navPane().selectedFavoriteGroup(),xInfo::currentWorkspaceNum());

sysDataImport = new sysDataImport();
sysDataImport.parmDropCompany(true);
sysdataimport.parmDeleteTables(connull());
sysDataImport.parmSilent(true);
sysdataImport.parmFilename(filename);
sysDataImport.parmServerAccess(Noyes::Yes);
sysdataImport.run(false);
//sysDataImport::importFile("D:\\MyShare\\Data\\5.0SP1\\ExtendedData\\40ExtendedData1380.dat",FileType::Binary);
}

if(i==14 || i==25 || i==40 || i==60 || i==75 || i== 90 || i== 110 || i== 130 ||
i==150 || i==170 || i==190 || i==220 || i==240 || i==270)
infolog.clearBrowser();

}
}

No comments:

Post a Comment

Convert Call stack to readable format in D365FO X++

//Input --container _xppCallStack = xSession::xppCallStack();  Public static str POL_formatXppCallStack(container _xppCallStack, int _skipFr...