You are on page 1of 17

Anand S asked a question on 29 Apr 2015 8:47 AM

Hi All,
My task is to import items through Data import export framework in AX 2012 R3.
Please give me the clarification with entity to be used, necessary fields to be
selected in staging and the other(?) things should be considered while importing
items. Thanks in Advance.
Tags: Microsoft Dynamics AX 2012: Development / Customization / SDK AX
Reply
All Responses (8)
Only Answers

Andr Arnaud de Calavon


Works For Kaya Consulting in Netherlands
@dynamicsaxgeek
LinkedIn
Google+
YouTube
Blog
Website
My Badges

Verified Answer
Andr Arnaud de Calavon responded on 29 Apr 2015 9:03 AM
Hi Anand,

To import items you can use the Items entity. Which fields to use depends on your
setup, and some reporting requirements. At least you need to have an ItemId,
Name, Item group, Item model group, product+inventory+tracking dimension
groups.
Reply
2 Likes

Baber Owais
Works For Intergen in New Zealand
LinkedIn
Blog
My Badges

Verified Answer
Baber Owais responded on 29 Apr 2015 6:39 PM
Hi Anand,
As Andre mentioned, you need to use the Items entity. You can get the list of fields
for import by creating a processing group based on Items entity and then click on
Generate source file button which will show you the file with the columns from
staging table.
Please let me know if you have further queries.
Thanks,
Baber.
Reply
1 Likes

Guy Terry
Works For IBRL in the U.K.
@guyterry
LinkedIn
Blog
My Badges

Guy Terry responded on 30 Apr 2015 4:28 PM


Hi,
The Items Entity doesn't appear to import anything into the EcoRes tables. Does
that mean it can only be used to import Released products, where the (unreleased)
Product already exists?
Reply

Baber Owais
Works For Intergen in New Zealand
LinkedIn
Blog
My Badges

Verified Answer

Baber Owais responded on 30 Apr 2015 5:23 PM


Hi Guy,
The Item impot DIXF entity only import the Items which exist as a Product in EcoRes
tables. If a product exist and it is not released, the import routine will release the
Item using EcoResProductReleaseManager class. If an Item you are trying to import
does not exist in EcoResProduct table, then the following error will be thrown:
Item %1 cannot be imported, as product %2 does not exist.
Thanks,
Baber.
Reply
1 Likes

Guy Terry
Works For IBRL in the U.K.
@guyterry
LinkedIn
Blog
My Badges

Verified Answer
Guy Terry responded on 1 May 2015 3:06 AM
Thanks Baber - excellent explanation!
@ Anand - I think you might also need to consider the entity called 'Product'. It will
create Products, and release them to the company you are in when you do the
import. i.e. this is the same as clicking 'New' -> 'Product' on the 'Released products'
list page.
If using this entity, as a minimum you'll want to be thinking about the following
fields:

ItemID - Item number


EcoResProductTranslation_Name - Product name
ItemGroupID - Item group
DisplayProductNumber - Product number
BOMUnitID - BOM Unit of Measure
InventTableModuleSales_UnitID - Sales order Unit of Measure
InventTableModuleInvent_UnitID - Inventory Unit of Measure
InventTableModulePurch_UnitID - Purchase order Unit of Measure
ProductType - Product type
ProductSubType - Product subtype
EcoResProductTranslation_LanguageID - Language of Product name
ModelGroupID - Item model group
EcoResStorageDimensionGroup_Name - Storage dimension group
PmfProductType - Production type (0 = None)
EcoResTrackingDimensionGroup_Name - Tracking dimension group
There are also some hotfixes available for the Products entity:
KB3019584 - Support for WHS fields (I've not tried it, but I hope it adds 'Reservation
hierarchy' and 'Unit sequence group ID'!)
KB3047371 - Fix for Default Order Settings (guyterry.wordpress.com/.../missingdefault-order-settings-with-dixf-products-import)
Reply
2 Likes

Hatem Bouhdida
Works For Africa Solutions in Tunisia
Hatem Bouhdida responded on 4 May 2015 9:59 AM
I the Item Id is generated by the system, Is it mandatory to put it in the import file ?

It's the first time I perform this task.


Thx
Reply

Baber Owais
Works For Intergen in New Zealand
LinkedIn
Blog
My Badges

Verified Answer
Baber Owais responded on 4 May 2015 4:41 PM
Hi Hatem,
It depends what you are trying to import. If you are importing Items, then the Items
you are providing in the import file must be there as a Product or Product master.
See my last comment for further details.
For importing Products, I think you need to provide the Item or Product number in
the import file as mentioned by Guy terry in his last comment.
Please let me know if you have further queries.
Thanks,
Baber.
Reply
1 Likes

Sabih Khan
Works For Arabic Computer Systems in KSA
LinkedIn
Blog
Suggested Answer
Sabih Khan responded on 28 Sep 2015 3:32 AM
Following tutorial made me start using import Export Framework,
https://www.youtube.com/watch?v=vbMrqE7sZAs

Ax2012 Import Items from CSV file


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_Column
Num));
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_Colu
mnNum));
axInventItemInventSetup.parmHighestQty(this.getLineValue(_conLine,#InventItemInvent_HighestQty_Col
umnNum));
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_C
olumnNum));
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_Des
cription_ColumnNum));
axProductTranslation.parmName(this.getLineValue(_conLine,#EcoResProductTranslationENG_Name_C
olumnNum));
axProductTranslation.parmProduct(ecoResDistictProduct.RecId);
axProductTranslation.save();
//InventItemSetupSupplyType
inventItemSetupSupplyType.clear();
inventItemSetupSupplyType.initValue();
inventItemSetupSupplyType.DefaultOrderType=ReqPOType::Purch;
inventItemSetupSupplyType.ItemId=itemId;
inventItemSetupSupplyType.ItemDataAreaId=curext();
inventItemSetupSupplyType.insert();
}
}

Posted by Krishna Reddy at 10:15 AM


Email ThisBlogThis!Share to TwitterShare to FacebookShare to Pinterest

19 comments:
1.

Anonymous6/19/2012 4:40 AM
I would like to insert AgreementLine which is abstract table. I tried to insert derived tables and the
agreementLine but still didn't work out is there any other way or is there any class.
Reply
Replies

1.
Krishna Reddy6/19/2012 7:38 AM
Hi,
You cannot insert into the agreementLine Table, Its abstract class, you have to
insert into the derivice tables like-AgreementLineQuantityCommitment or
AgreementLineVolumeCommitment
These
two
will
be
differentiated
by
purchAgreementForm.parmDefaultCommitmentType()
==
CommitmentType::ProductQuantity
or
volume.
I

hope

this

will

help

you

to

solve

your

problem.

Thanks,
Krishna.
Reply
2.
Anonymous6/19/2012 11:08 AM
Yes i had inserted now in AgreementLineQuantityCommitment but after insertion.
Records
are
not
showing
up
in
PurchAgreement
Form.
Yet if i refresh the PurchAgreementListpage iam able to get those records in that form.
I checked table both agreementLine and agreementQuantinty are inserted properly but recVersion
was
1
in
agreementLine
how
do
i
correct
this.
why
the
records
or
not
showing
up?
in
purchAgreement
Form.
Reply
Replies

1.
Krishna Reddy6/19/2012 11:40 AM
I dont think Recversion have an issue, It will create as version 1 only.May be you
are missing the InstanceRelationType field in the AgreementLine table where you
have
to
fill
in
the
tableid
of AgreementLineQuantityCommitment.
as well you have to fill the agreement header recid in the Agreement field of
AgreementLine table. then it will show the data when you open the agreement
form.

Hope

this

will

help

you.

thanks
krishna.
Reply
3.
Anonymous6/19/2012 1:42 PM
I checked DimID,Agreement,InstanceRelationType all are mapped like correctly. In PurchLisPage
they are using Query Parts to Show lines which is able to display all lines.
But in PurchAgreement they are using datasource which is not showing newly created records
through
code.
agreementLineQuantityCommitment.clear();
agreementLineQuantityCommitment.initValue();
agreementLineQuantityCommitment.initFromAgreementHeader(AgreementHeader::find(_purchAgr
eementHeader.RecId));
agreementLineQuantityCommitment.initFromInventTable(InventTable::find(_tmpProductsToAdd.Ite
mId));
agreementLineQuantityCommitment.CommitedQuantity
=
_tmpProductsToAdd.Quantity;
agreementLineQuantityCommitment.ProductUnitOfMeasure
=
InventTable::find(_tmpProductsToAdd.ItemId).purchUnitId();
agreementLineQuantityCommitment.ExpirationDate
=
today();
agreementLineQuantityCommitment.Category
=
EcoResProductCategory::findRetailCategoryByItem(_tmpProductsToAdd.ItemId);
agreementLineQuantityCommitment.ItemId
=
_tmpProductsToAdd.ItemId;
agreementLineQuantityCommitment.setInventDimId(_tmpProductsToAdd.InventDim);
agreementLineQuantityCommitment.Agreement
=
_purchAgreementHeader.RecId;
agreementLineQuantityCommitment.insert();
Still
unable
to
Is there any other table involved.

find

where

the

problem.

Reply
Replies

1.
Krishna Reddy6/19/2012 1:53 PM
Where you are creating this code...in the form do u have any menu item to import
the data...if it is like that then you have to refresh the Listpage datasource...
Otherwise I can see everything is fine in the table fields.
2.
Anonymous12/17/2012 3:46 AM
Hi
Krishna
Reddy,
Im facing with the same as above issue. Did that problem resolved? Please help!

Thank in advance!
3.
Anonymous1/07/2014 7:55 PM
Code

below

will

do

the

"trick"

agreementLineQuantityCommitment.clear();
agreementLineQuantityCommitment.initValue();
agreementLineQuantityCommitment.initFromAgreementHeader(agreementHeader)
;
agreementLineQuantityCommitment.initFromInventTable(InventTable::find(itemId));
agreementLineQuantityCommitment.CommitedQuantity
=
agreementQty;
agreementLineQuantityCommitment.PricePerUnit
=
agreementPurchPrice;
agreementLineQuantityCommitment.ProductUnitOfMeasure
=
UnitOfMeasure::find(purchReqUnitOfMeasure).Symbol;
agreementLineQuantityCommitment.ExpirationDate = agreementExpirationDate;
agreementLineQuantityCommitment.Category
=
EcoResProductCategory::findRetailCategoryByItem(itemId);
agreementLineQuantityCommitment.ItemId
=
itemId;
agreementLineQuantityCommitment.setInventDimId(inventDim.inventDimId);
agreementLineQuantityCommitment.Agreement = agreementHeader.RecId;
agreementLineQuantityCommitment.InventDimDataAreaId
=
agreementLineQuantityCommitment.ItemDataAreaId;
agreementLineQuantityCommitment.insert();
4.
Anonymous1/07/2014 7:56 PM
Also...

in

order

to

create

header

code

below

might

be

used:

transferVendTable
=
VendTable::find(vendAccount);
agreementHeader.initValue();
agreementHeader.initFromAgreementClassification(agreementClassification);
agreementHeader.initFromVendTable(transferVendTable);
agreementHeader.PurchNumberSequence
=
NumberSeq::newGetNum(PurchParameters::numRefPurchAgreementId()).num();
agreementHeader.WorkflowStatus_PSN
=
PurchAgreementWorkflowStatus::Approved;
agreementHeader.AgreementState
=
AgreementState::Effective;
agreementHeader.insert();
purchAgreementHeaderDefault.initFromVendTable(transferVendTable,
agreementHeader.VendAccount);
purchAgreementHeaderDefault.PurchaseAgreementHeader
=
agreementHeader.RecId;
purchAgreementHeaderDefault.insert();
agreementHeaderDefault.initFromVendTable(transferVendTable);
agreementHeaderDefault.AgreementHeader
=
agreementHeader.RecId;
agreementHeaderDefault.insert();
Cheers!
Reply
4.

Anonymous6/19/2012 2:14 PM
Adding
added

Products to
the
code

Purchase Agreement
in
a
class

Lines like Purchase Orders Lines.


RetailCreateLinesFromProductsToAdd

Refresh list page its showing correctly in ListPage and Data gets inserted agreementLine and
agreementLineQuantityCommitment
tables
properly
with
agreement
recid.
But

still

its

not

showing

in

Purch

agreement

Warm
Ramanan - Ramanan2k10@gmail.com

form.
Regards

Reply

5.
Krishna Reddy6/20/2012 8:34 AM
could
you
send
me
your
XPO,
mail id:-krishna.dynamics@gmail.com

will

import

and

Check

the

code....

Reply

6.
Ambanna Yatnal7/09/2012 12:53 PM
Hi

Krishna,

Article
was
really
helpful
in
order
to
create
products.
And I need a help on attaching prodcut, storage and tracking dimension group to the newly created
product
throuhg
code.
Please could you provide the sample code if you have for the same.
Thanks,
Ambanna Yatnal
Reply
Replies

1.
Krishna Reddy7/09/2012 2:33 PM
Hi
Ambanna,
I have posted the Part 2 with all the functionality for creating the product.
you

can

see

in

the

following

post

http://krishhdax.blogspot.dk/2012/07/ax2012-import-items-from-csv-part-2.html
Regards,
krishna.
Reply
7.
Ashish Mullapudi8/06/2012 7:55 AM
Hi,
I am using AX 2012 Data Migration Framework(Beta) for Products import. when I import the
products from the demo files given with the framework installation, the imported items are getting
released. My actual requirement is to import the products into product master only, they should not
be shown in released products. How to take the field mapping or any other way to achieve this??
Thanks.
Reply
Replies

1.
Krishna Reddy8/06/2012 8:11 AM
Hi
Ashish,
You have to map the fields respectively to the table fields and you have to update
the Entity class for your functionality. you can customize that entity class for your
functionality
if
your
required.
If you remove mapping for standard entity I think this will validate before importing
into the target, so you have to update the entity class for doing your custom import
Regards,
krishna.
Reply

8.
Manickam Ramasamy1/08/2013 10:40 AM
Hi
I
need
upload
please help me.
Reply
9.

Krishana,
customer

data

from

csv

file

using

X++

Anonymous2/13/2013 3:10 AM
After I insert reqItemTable using X++ and open the table or form I get this error:
You cannot specify inventory dimension 'Site' for item coverage settings. You must set all coverage
planned dimensions before you can define minimum and maximum inventory.
Here's

my

code

Select
forupdate
ReqItemTable;
reqItemTable.clear();
reqItemTable.initValue();
reqItemTable.initFromInventTable(inventTable::find(newPartEntry.ItemId));
reqItemTable.ItemId
=
newPartEntry.ItemId;
reqItemTable.covRule
=
reqcovtype::MinMax;
reqItemTable.CovPeriod
=
1;
reqItemTable.MinInventOnhand
=
newPartEntry.MinInventOnHand;
reqItemTable.MaxInventOnhand
=
newPartEntry.MaxInventOnHand;
//
reqItemTable.reqGroupId
reqItemTable.CovInventDimId
=
'000001';
reqItemTable.insert();
Note inventDimId '000001' has only one dimension SiteId
Reply
Replies

1.
Anonymous2/13/2013 4:56 PM
Resolved: Discovered (InventTable).DimGroupId value was invalid. Once
(InventTable).DimGroupId was corrected to a valid value the error disappeared and
Item coverage (reqItemTable) is working. Thought I'd post this solution in case
someone else has a similar issue.
Reply
10.
Anonymous6/25/2013 1:05 PM
Hi.

Cannot

get

this

create

error
record

when
in

Reply
Add comment
Load more...
Thanks for visiting my blog,
I will reply for your comment within 48 hours.

to

import

(InventItemSetupSupplyType).

Is this cause I've uncommented


axInventTable.parmIntegration
or
because
it's
on
Thor

trying

the
&
a

a
The

record
record

from

csv.

already

axInventTable.parmClassification together
axInventTable.parmRevisionId
AX
2012
r2
system?

exists.
with

Thanks,
krishna.

You might also like