Import Fixed Assets into AX

ahaag
Member Posts: 7
Hello,
When importing fixed assets into Dynamics AX 2009 I have a problem with creating records for the AssetBook table.
After the AssetTable is created, apparently automatically an AssetBook record is also created. However this record cannot be found or even seen within the job I have created for importing the fixed assets.
The structure is as next:
static void ImportVa(Args _args)
{
// Variables
FileName filename = 'C:\\Temp\\VaTest1.csv';
CommaIO commaIO;
container readCon;
int i;
int level;
// declare columns within CSV-file
str column1; // FA-id
str column2; // FA-description
str column3; // FA-Groupd
str column4; // FA-Group description
.....
AssetTable assetTable;
AssetTrans assetTrans;
AssetBook assetBook;
;
// Initialisatie
commaIO = new CommaIO(filename, 'r');
commaIO.inFieldDelimiter(';'); // Delimiter
if (commaIO)
{
// Begin loop
while (commaIO.status() == IO_Status::Ok)
{
// Read line
readCon = commaIO.read();
// Overnemen inhoud
column1 = conPeek(readCon, 1);
column2 = conPeek(readCon, 2);
column3 = conPeek(readCon, 3);
.....
// Toon kolommen
if (column1 != '0' && column1 != '' )
{
// Check if FA already exists
assetTable = AssetTable::find(column1);
if (assetTable.RecId == 0)
{
ttsBegin;
// Create VA
assetTable.clear();
assetTable.initValue();
assetTable.AssetId = column1;
assetTable.Name = column2;
assetTable.NameAlias = column2;
assetTable.AssetGroup = column3;
assetTable.initFromAssetGroupId(column3);
assetTable.Quantity = 1;
assetTable.insert();
assetBook::Find(column1,'Tst-Akh',true); // Mark for update
if (assetBook.RecId == 0)
{
// Aanmaken Waardemodel
assetBook.clear();
assetBook.initValue();
assetBook.AssetId = column1;
assetBook.AssetGroup = column3;
assetBook.BookId = 'Tst-Akh';
....
// Zet status op open
assetBook.Status = AssetStatus::Open;
assetBook.insert();
}
ttsCommit;
}
}
}
}
}
Does anyone have an idea how to fix this?
When importing fixed assets into Dynamics AX 2009 I have a problem with creating records for the AssetBook table.
After the AssetTable is created, apparently automatically an AssetBook record is also created. However this record cannot be found or even seen within the job I have created for importing the fixed assets.
The structure is as next:
static void ImportVa(Args _args)
{
// Variables
FileName filename = 'C:\\Temp\\VaTest1.csv';
CommaIO commaIO;
container readCon;
int i;
int level;
// declare columns within CSV-file
str column1; // FA-id
str column2; // FA-description
str column3; // FA-Groupd
str column4; // FA-Group description
.....
AssetTable assetTable;
AssetTrans assetTrans;
AssetBook assetBook;
;
// Initialisatie
commaIO = new CommaIO(filename, 'r');
commaIO.inFieldDelimiter(';'); // Delimiter
if (commaIO)
{
// Begin loop
while (commaIO.status() == IO_Status::Ok)
{
// Read line
readCon = commaIO.read();
// Overnemen inhoud
column1 = conPeek(readCon, 1);
column2 = conPeek(readCon, 2);
column3 = conPeek(readCon, 3);
.....
// Toon kolommen
if (column1 != '0' && column1 != '' )
{
// Check if FA already exists
assetTable = AssetTable::find(column1);
if (assetTable.RecId == 0)
{
ttsBegin;
// Create VA
assetTable.clear();
assetTable.initValue();
assetTable.AssetId = column1;
assetTable.Name = column2;
assetTable.NameAlias = column2;
assetTable.AssetGroup = column3;
assetTable.initFromAssetGroupId(column3);
assetTable.Quantity = 1;
assetTable.insert();
assetBook::Find(column1,'Tst-Akh',true); // Mark for update
if (assetBook.RecId == 0)
{
// Aanmaken Waardemodel
assetBook.clear();
assetBook.initValue();
assetBook.AssetId = column1;
assetBook.AssetGroup = column3;
assetBook.BookId = 'Tst-Akh';
....
// Zet status op open
assetBook.Status = AssetStatus::Open;
assetBook.insert();
}
ttsCommit;
}
}
}
}
}
Does anyone have an idea how to fix this?
0
Comments
-
assetBook::Find(column1,'Tst-Akh',true); // Mark for update
You don't need this forUpdate flag in this case, but I don't think this will cause your problem, thought. I can't find any problem in your code, aparently, this is all ok :-k[Dynamics AX developer]
http://www.jaestevan.com (AX Dev Blog)
http://twitter.com/jaestevan (follow me!)0 -
I think you are missing one table here.
table - AssetBookTable
Try to insert into the above table also.Kranthi0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions