AXForum  
Вернуться   AXForum > Microsoft Dynamics AX > DAX Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 17.10.2012, 21:12   #1  
Blog bot is offline
Blog bot
Участник
 
25,491 / 846 (79) +++++++
Регистрация: 28.10.2006
ax-erp: Ax2012 Import Items from CSV file
Источник: http://microsoft-dynamics-ax-erp.blo...-csv-file.html
==============

I am posting only the method where the Input was Container.

Before using this code write your logic to read the CSV file using COMMAIO and get the container and pass to the below method.
And I created the Macro with the position numbers that i used in the below code.
I am using the AX classes to save the records into the Tables.
In AX2012 we have to create the Records for ECOResProduct.

ECOResProduct is the abstract Table and the following tables are inherited from this.
ECORESProductMaster,EcoResdistinctProduct.
When we are creating the new product in form if you select the productsubtype as productMaster then we have to insert into the ECORESProductMaster and we have to pass this recid into the inventTable.

When the productSubtype is Products then we have to use EcoResdistinctProduct and pass the recid to inventTable.
Below I am using the Products.

Macro:-
//InventTable

#define.InventTable_ItemId_ColumnNum(1)
#define.InventTable_PrimaryVendorId_ColumnNum(2)
#define.InventTable_NetWeight_ColumnNum(3)
#define.InventTable_UnitVolume_ColumnNum(4)
#define.InventTable_AltItemId_ColumnNum(5)
#define.InventTable_Intracode_ColumnNum(6)
#define.InventTable_ABCRevenue_ColumnNum(7)
#define.InventTable_NameAlias_ColumnNum(8)
#define.InventTable_Classification_ColumnNum(9)
#define.InventTable_Integration_ColumnNum(10)

//InventItemLocation columns
#define.InventItemLocation_ItemId_ColumnNum(11)


//Invent GroupItem
#define.InventItemGroupItem_ItemId_ColumnNum(12)
#define.InventItemGroupItem_ItemGroupId_ColumnNum(13)


//InventModelGroupItem
#define.InventModelGroupItem_ItemId_ColumnNum(14)


//ECOResProduct translation for english
#define.EcoResProductTranslationENG_Description_ColumnNum(15)
#define.EcoResProductTranslationENG_Name_ColumnNum(16)


//InventItemPurchSetup for default order settings
#define.InventItemPurch_ItemId_ColumnNum(17)


//inventItemInventSetup for Default order settings
#define.InventItemInvent_ItemId_ColumnNum(18)
#define.InventItemInvent_LowestQty_ColumnNum(19)
#define.InventItemInvent_HighestQty_ColumnNum(20)
#define.InventItemInvent_StandardQty_ColumnNum(21)


//InventItemSupplySetup
#define.InventItemSetupSupplytype_ItemId_ColumnNum(22)






Public class Krishh_ImportItem
{
//Macro which contains the column positions.
#ItemImport

AxInventTable axInventTable;
AxInventItemGroupItem axInventGroupItem;
AxInventModelGroupItem axInventModelGroupItem;
AxEcoResProductTranslation axProductTranslation;
AxInventItemInventSetup axInventItemInventSetup;
AxInventItemPurchSetup axInventItemPurchSetup;
InventItemSetupSupplyType inventItemSetupSupplyType;
EcoResDistinctProduct ecoResDistictProduct;
}



protected void createInventTable(container _conLine)
{

ItemId itemId;
InventTable inventTable;
InventItemGroupItem inventItemGroupItem;
;

itemId = this.getLineValue(_conLine,#InventTable_ItemId_ColumnNum);
inventTable= InventTable::find(itemId);
if(!inventTable)
{
ecoResDistictProduct.clear();
ecoResDistictProduct.initValue();
ecoResDistictProduct.DisplayProductNumber=itemId;
ecoResDistictProduct.ProductType=ecoResProductType::Item;
ecoResDistictProduct.SearchName=this.getLineValue(_conLine,#InventTable_NameAlias_ColumnNum);
ecoResDistictProduct.insert();

axInventTable=axInventTable::construct();
axInventTable.parmItemId(this.getLineValue(_conLine,#InventTable_ItemId_ColumnNum));
axInventTable.parmItemType(ItemType::Item);

axInventTable.parmPrimaryVendorId(this.getLineValue(_conLine,#InventTable_PrimaryVendorId_ColumnNum));
axInventTable.parmNetWeight(this.getLineValue(_conLine,#InventTable_NetWeight_ColumnNum));
axInventTable.parmProduct(ecoResDistictProduct.RecId);


axInventTable.parmUnitVolume(this.getLineValue(_conLine,#InventTable_UnitVolume_ColumnNum));

axInventTable.parmUseAltItemId(ItemNumAlternative::Always);
axInventTable.parmAltItemId(this.getLineValue(_conLine,#InventTable_AltItemId_ColumnNum));
axInventTable.parmIntracode(this.getLineValue(_conLine,#InventTable_Intracode_ColumnNum));
axInventTable.parmABCRevenue(this.getLineValue(_conLine,#InventTable_ABCRevenue_ColumnNum));
axInventTable.parmNameAlias(this.getLineValue(_conLine,#InventTable_NameAlias_ColumnNum));
axInventTable.parmClassification(this.getLineValue(_conLine,#InventTable_Classification_ColumnNum));

//TODO uncomment once the parm methods where builded
// axInventTable.parmIntegration(this.getLineValue(_conLine,#InventTable_Integration_ColumnNum));
// axInventTable.parmRevisionId(this.getLineValue(_conLine,#InventTable_RevisionId_ColumnNum));

//InventItemInventSetup
axInventItemInventSetup=AxInventItemInventSetup::construct();
axInventItemInventSetup.parmItemId(itemId);
axInventItemInventSetup.parmLowestQty(this.getLineValue(_conLine,#InventItemInvent_LowestQty_ColumnNum));
axInventItemInventSetup.parmHighestQty(this.getLineValue(_conLine,#InventItemInvent_HighestQty_ColumnNum));
axInventItemInventSetup.parmStandardQty(this.getLineValue(_conLine,#InventItemInvent_StandardQty_ColumnNum));
axInventTable.axInventItemInventSetup(axInventItemInventSetup);
//
//////InventPurchSetup
axInventItemPurchSetup=AxInventItemPurchSetup::construct();
axInventItemPurchSetup.parmItemId(itemId);
axInventTable.axInventItemPurchSetup(axInventItemPurchSetup);

axInventTable.save();



//InventGroup Item
axInventGroupItem=AxInventItemGroupItem::construct();
axInventGroupItem.parmItemId(itemId);
axInventGroupItem.parmItemGroupId(this.getLineValue(_conLine,#InventItemGroupItem_ItemGroupId_ColumnNum));
axInventGroupItem.parmItemGroupDataAreaId(curext());
axInventGroupItem.save();

//InventModelGroupItem
axInventModelGroupItem=AxInventModelGroupItem::construct();
axInventModelGroupItem.parmItemId(itemId);
axInventModelGroupItem.parmModelGroupId("Std Cost");
axInventModelGroupItem.parmModelGroupDataAreaId(curext());
axInventModelGroupItem.save();

//Product Translation
axProductTranslation=AxEcoResProductTranslation::construct();
axProductTranslation.parmDescription(this.getLineValue(_conLine,#EcoResProductTranslationENG_Description_ColumnNum));
axProductTranslation.parmName(this.getLineValue(_conLine,#EcoResProductTranslationENG_Name_ColumnNum));
axProductTranslation.parmProduct(ecoResDistictProduct.RecId);
axProductTranslation.save();

//InventItemSetupSupplyType
inventItemSetupSupplyType.clear();
inventItemSetupSupplyType.initValue();
inventItemSetupSupplyType.DefaultOrderType=ReqPOType::Purch;
inventItemSetupSupplyType.ItemId=itemId;
inventItemSetupSupplyType.ItemDataAreaId=curext();
inventItemSetupSupplyType.insert();

}

}



Источник: http://microsoft-dynamics-ax-erp.blo...-csv-file.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
axaptacorner: How to Import CSV files and how make Log files in Ax 2012 through X++ Blog bot DAX Blogs 0 20.09.2012 17:11
ax-erp: Pass Query from dialog to Form and Filter records Blog bot DAX Blogs 0 18.09.2012 18:11
ax-erp: How to get a Common object from a table id? Blog bot DAX Blogs 0 26.04.2012 00:12
dynamics-ax: A Guide to Microsft Dynamics Cloud ERP - Dynamics AX Blog bot DAX Blogs 0 15.04.2011 00:12
dynamic-ax.co.uk: Import Emails from Outlook 2007 into Dynamics AX 2009 Blog bot DAX Blogs 1 03.07.2009 07:17

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 04:12.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.