i have to import a data from multiple excel from a shared folder in ax 2012 using runbasebatch .
You already have the code.
But you shouldn't use it, because no code is needed. What you want to achieve is already supported by DIXF and there is no point reinventing the wheel and wasting resources to develop it again.
can i get code to loop a folder and get the name of excel file ??
Remember that the best code is the one that you don't have to write, test, debug, document, maintain...
First of all, check if your code runs on the same machine where you have the files. You may have files in client and running code on AOS.
container createListOfFiles()
{
System.Array files;
int fileCount;
int i;
str nextFile;
container listOfFiles;
new InteropPermission(InteropKind::ClrInterop).assert();
info(strfmt('Search in: %1 %2', @"C:\ReadFromExcel", '*.xlxs'));
listOfFiles = connull();
//actIx = 0;
files = System.IO.Directory::GetFiles( @"C:\ReadFromExcel", '*.xlxs');
if (files)
{
fileCount = files.get_Length();
info(strFmt('Number of files in directory: %1', fileCount));
for(i=0; i < fileCount; i++)
{
nextFile = files.GetValue(i);
listOfFiles += nextFile;
}
}
CodeAccessPermission::revertAssert();
info(strFmt('Files count: %1', conlen(listOfFiles)));
return listOfFiles;
}
here--- fileCount = files.get_Length(); is giving me zero even though there are 6 xlxs files in the folder.
It's supported out of the box - you can set "Completed directory" in DIXF setup. See Recurring batch job import in AX 2012 R3 for details.
Ok, sounds that you could do that with DIXF.
Not sure if moving the file to another location is possible. But for that you could have some simple script that copies files from the source folder to DIXF folder AND "processed" folder.
Client will get the data from a thirdparty and they will save those files in a shared folder .they will give us the path to access the folder.they ask us to create a batch job to read multiple excel s and once the excel is read it should move to another folder.
Ok, so I assume you got some business requirement from your customer, and then decided that RunBaseBatch is the best/only way to solve this requirement. Correct?
Just to make sure we can assist you in best possible way, could you share the business requirement?
Often development a customization should be considered only if non-development options were not feasible in fulfilling the business requirement.
Thanks for reply Nikolaos Mäenpää
but the requirment is to read multiple excels from a shared folder and update in Ax Tables using Runbase batch.
DIXIF wont work if you are trying to upload multiple sheets of an excelworkbook into same custom entity.
Something similar is already being discussed here at this thread .
Thanks
Mav
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156