Import Items into Ax with X++ Code

I was importing items into Microsoft Dynamics AX 2009 using the following job


static void ItemsImport(Args _args)

{

InventTable InventTable;

container c;

TextIo io;

str 130 fileName;

TextBuffer b;

integer inc;

ItemId ItemId;

AxInventTable axInventTable;

;

fileName = @“C:\Users\mom\Desktop\Items.csv”;

b = new Textbuffer();

io = SysLicenseCodeReadFile::openFile(fileName,‘r’);

if (!io)

throw error(strfmt("@SYS18678",fileName));

io.inFieldDelimiter(";");

c = io.read();

b = new Textbuffer();

ttsbegin;

while (io.status() == IO_Status::Ok)

{

c = io.read();

inc++;

if (io.status() != IO_Status::Ok)

break;

ItemId = conpeek(c,1);

select InventTable

where InventTable.ItemId == ItemId;

axInventTable = new axInventTable();

axInventTable.parmItemId(conPeek(c, 1));

axInventTable.parmItemName(conPeek(c, 2));

axInventTable.parmNameAlias(conPeek(c, 3));

axInventTable.parmItemGroupId(“PRD_CHF”);

axInventTable.parmModelGroupId(“PMP”);

axInventTable.parmDimGroupId(“Teinture”);

axInventTable.axInventTableModule_Sales().parmUnitId(“Kg”);

axInventTable.axInventTableModule_Purch().parmUnitId(“Kg”);

axInventTable.axInventTableModule_Invent().parmUnitId(“Kg”);

axInventTable.parmBOMUnitId(“g”);

axInventTable.axInventItemInventSetup().axInventDim().parmInventSiteId(“FIMA”);

axInventTable.axInventItemPurchSetup().axInventDim().parmInventSiteId(“FIMA”);

axInventTable.axInventItemInventSetup().axInventDim().parmInventSiteId(“FIMA”);

axInventTable.axInventItemInventSetup().axInventDim().parmInventLocationId(“MG_PRD_CHI”);

axInventTable.axInventItemPurchSetup().axInventDim().parmInventLocationId(“MG_PRD_CHI”);

axInventTable.axInventItemInventSetup().axInventDim().parmInventLocationId(“MG_PRD_CHI”);

axInventTable.save();

}

ttscommit;

pause;

}


The records are created correctly in the table but when I open the default orders settings/Site specific order settings order form for the product,

all fields are still greyed out as if no records exists.

Has anybody faced this problem ? how I can correct the x ++ code ?

Any help would be appreciated.

Thanks,

Hi,

I had the same kind of problem, I think your inventDimIds are not correct, except inventTable, in which tables are you inserting datas ? check InventdimIds in InventTableModule, InventItemInventSetup tables

regards,

Thomas