Monday 29 October 2012

AX 2012 Setup - Hyper V on Virtual Box (Step by Step)



Download virtual box and the extension pack.


 2. Once you have installed, create a new virtual machine.


3. Select Windows 2008 64bit

4. Allocate a good portion of memory (4GB recommended)

6. Un-tick the boot Hard Disk. Add disks manual after the wizard is finished.

7. Click on your new virtual image settings

8. Navigate to Storage
Add hard disks by clicking the disk icon – then “Choose existing disk”
Repeat this step for all 3 vhd files.
·         AX5-W8R2-01.vhd
·         AX5-W8R2-01_DB.vhd
·         AX5-W8R2-01_PF.vhd

9. After you have finished. Settings should look like this:
10. Start your image

Configure sharepoint 
After you have managed to get it to start, there are a couple other things to be aware of:
1. Start the AOS by going to the windows services and start manually
2. All seems to work except for Enterprise Portal
To fix this modify your hosts file “C:\Windows\System32\drivers\etc\Hosts”
Open this file with notepad and add in the line
                127.0.0.1              Sharepoint
                127.0.0.1              dynamicsax.contoso.com
It should look like this:
3.  When you run a report - it will be slow on first run. Don't kill it; leave it for a few minutes. Mine took ~4minutes to run first time. After that, it is very responsive. Standard SSRS caching.

Importing Products into AX 2012


Distinct Product Import


Microsoft Dynamics AX is shipped with many standard document services that support common business processes. By using the capabilities that AIF provides, you can also customize existing document services or create your own document services.

We have had several questions on how to import items/products into AX 2012.  Hope this helps!



Inbound port of the Product service

To call the service, you need to expose the service on a new inbound port in Microsoft Dynamics AX.

1. Click System administration >Setup > Services and Application Integration Framework > Inbound ports, and then click New.
2. Give the new port a name, such as Product Data Import Services.
3. Enter a description.
4. Under Service Contract Customizations, click Service Operations. The Select service operations form opens.
5. Select the all the product related operations, move them to the Selected operations pane, and then click Close.
6. In the Inbound ports form, click Activate.

 
You can now access the service externally by using the WSDL URI

Select the service Operations: 




After Selection of the services, activate the Port: 





Set up the Product data import service reference in Microsoft Visual Studio 

1. Open Microsoft Visual Studio®, and create a new project. 
2. Add a new service reference by using the WSDL URI for the product data import service from the Inbound ports form. 
3. Add a Using statement for the service reference. 




You are now ready to start coding against the Distinct Product service.

code to import Distinct products from a .csv file by using a Visual Studio service reference 

This section provides the code that shows the correct order of operations to create a new products in Microsoft Dynamics AX 2012.



using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ProductsImport.ProductDataImportService;
using System.IO;
using System.Text.RegularExpressions;
namespace ProductsImport
{
    public partial class Product : Form
    {
        internal static int ProdNumber = 0;
        internal static int Searchname = 1;
        internal static int ProdName = 2;
        internal static int StorageDimGroup = 3;
        internal static int SerialNumGroup = 4;
        internal static int InventUnitID = 5;
        internal static int PurchUnitID = 6;
        internal static int SalesUnitID = 7;
        internal static int ProdCompanyID = 8;
        internal static int ItemGroup = 9;
        internal static int ItemType = 10;
        internal static int InventoryModelGroup = 11;
        internal static int Baseprice = 12;
        internal static int Itemsalestaxgroup_PO = 13;
        internal static int Itemsalestaxgroup_sales = 14;
        internal static int Priceunit_purch = 15;
        internal static int Dateofprice_purch = 16;
        internal static int Totaldiscount_purch = 17;
        internal static int Priceunit_inv = 18;
        internal static int Dateofprice_inv = 19;
        internal static int Priceunit_sales = 20;
        internal static int Dateofprice_sales = 21;
        internal static int Totaldiscount_sales = 22;
        internal static int TrackingDimGroup = 23;
       
        public static List<string[]> ParseCSVFile(string path, Boolean hasHeaders)
        {
            List<string[]> CSVRows = new List<string[]>();
            int rowNumber = 0;
            using (StreamReader inputFile = new StreamReader(path))
            {
                string line;
                string[] line1;
                while ((line = inputFile.ReadLine()) != null)
                {
                    String pattern = ",(?=(?:[^\"]*\"[^\"]*\")*(?![^\"]*\"))";
                    Regex r = new Regex(pattern);
                    line1 = r.Split(line);
                    if (hasHeaders != true || rowNumber != 0)
                    {
                        CSVRows.Add(line1);
                    }
                    rowNumber++;
                }
            }
            return CSVRows;
        }
        public Product()
        {
            InitializeComponent();
        }
        //                          //
        //Create a distinct product //
        //                          //
        static void createDistinctProduct(string[] _product)
        {
            AxdEntity_Product_EcoResDistinctProduct distinctProduct = new AxdEntity_Product_EcoResDistinctProduct()
            {
                DisplayProductNumber = _product[ProdNumber], //"Bulb60W",
                ProductType = (AxdEnum_EcoResProductType)Enum.Parse(typeof(AxdEnum_EcoResProductType), _product[ItemType]),//AxdEnum_EcoResProductType.Item,               
                SearchName = _product[Searchname] //"Bulb60W"
            };
            distinctProduct.Translation = new AxdEntity_Translation[1];
            distinctProduct.Translation[0] = new AxdEntity_Translation()
            {
                LanguageId = "en-us",
                Name = _product[ProdName] //"Transparent Bulb 60W"
            };
            distinctProduct.Identifier = new AxdEntity_Identifier[1];
            distinctProduct.Identifier[0] = new AxdEntity_Identifier()
            {
                ProductNumber = _product[ProdNumber] //"Bulb60W"
            };
            distinctProduct.StorageDimGroup = new AxdEntity_StorageDimGroup[1];
            distinctProduct.StorageDimGroup[0] = new AxdEntity_StorageDimGroup()
            {
                Product = _product[ProdNumber], //"Bulb60W",
                StorageDimensionGroup = _product[StorageDimGroup] //"Std-Dim"
            };
            distinctProduct.TrackingDimGroup = new AxdEntity_TrackingDimGroup[1];
            distinctProduct.TrackingDimGroup[0] = new AxdEntity_TrackingDimGroup()
            {
                Product = _product[ProdNumber], //"Bulb60W",
                TrackingDimensionGroup = _product[TrackingDimGroup] //"Std-Dim"
            };
            AxdEcoResProduct axdProduct = new AxdEcoResProduct()
            {
                Product = new AxdEntity_Product_EcoResProduct[1]
                {
                    distinctProduct
                }
            };
            CallContext ctx = new CallContext();
            EcoResProductServiceClient service = new EcoResProductServiceClient();
            try
            {
                service.create(ctx, axdProduct);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
                // System.Console.ReadKey();
            }
        }
       
        //                          //
        ////Release a distinct product //
        //                          //
        private static void releaseDistinctProduct(string[] _product)
        {
            /*if (_product[Dateofprice_inv].ToString() == "")
                datetime;*/
            AxdEntity_InventTable inventTable = new AxdEntity_InventTable()
            {
                ItemId = _product[ProdNumber], //"Bulb60W",
                Product = _product[ProdNumber], //"Bulb60W",
                SalesPriceModelBasic = (AxdEnum_SalesPriceModelBasic)Enum.Parse(typeof(AxdEnum_SalesPriceModelBasic), _product[Baseprice]),//_product[Baseprice],
                SerialNumGroupId = _product[SerialNumGroup],
                Invent = new AxdEntity_Invent[1]
                {
                    new AxdEntity_Invent()
                    {
                        ItemId = _product[ProdNumber], //"Bulb60W",
                        UnitId = _product[InventUnitID]
                        , //"Box"                        
                        PriceUnit = decimal.Parse(_product[Priceunit_inv]),                   
                        PriceDate = DateTime.Parse(_product[Dateofprice_inv])
                    }                    
                },
                Purch = new AxdEntity_Purch[1]
                {
                    new AxdEntity_Purch()
                    {
                        ItemId = _product[ProdNumber], //"Bulb60W",
                        UnitId = _product[PurchUnitID], //"Box"                          
                        TaxItemGroupId = _product[Itemsalestaxgroup_PO],
                        PriceUnit = decimal.Parse(_product[Priceunit_purch]),
                        //if(_product[Dateofprice_purch].ToString() != "")
                        PriceDate = DateTime.Parse(_product[Dateofprice_purch]),
                        EndDisc = (AxdEnum_NoYes)Enum.Parse(typeof(AxdEnum_NoYes), _product[Totaldiscount_purch])
                    }
                },
                Sales = new AxdEntity_Sales[1]
                {
                    new AxdEntity_Sales()
                    {
                        ItemId = _product[ProdNumber], //"Bulb60W",
                        UnitId = _product[SalesUnitID], //"Pcs"                        
                        TaxItemGroupId = _product[Itemsalestaxgroup_sales],
                        PriceUnit = decimal.Parse(_product[Priceunit_sales]),
                        PriceDate = DateTime.Parse(_product[Dateofprice_sales]),
                        EndDisc = (AxdEnum_NoYes)Enum.Parse(typeof(AxdEnum_NoYes), _product[Totaldiscount_sales])
                    }
                }
                ,
                /* Invent = new AxdEntity_Invent[1] { new AxdEntity_Invent() { ItemId = _product[ProdNumber], UnitId = _product[InventUnitID] } },
                 Purch = new AxdEntity_Purch[1] { new AxdEntity_Purch() { ItemId = _product[ProdNumber], UnitId = _product[PurchUnitID] } },
                 Sales = new AxdEntity_Sales[1] { new AxdEntity_Sales() { ItemId = _product[ProdNumber], UnitId = _product[SalesUnitID] } },
                */
                InventModelGroupItem = new AxdEntity_InventModelGroupItem[1]
                {
                    new AxdEntity_InventModelGroupItem()
                    {                       
                        ModelGroupId = _product[InventoryModelGroup]
                    }
                },
                InventItemGroupItem = new AxdEntity_InventItemGroupItem[1]
                {
                    new AxdEntity_InventItemGroupItem()
                    {
                        ItemGroupId = _product[ItemGroup]
                    }
                }
            };
            AxdItem item = new AxdItem()
            {
                InventTable = new AxdEntity_InventTable[1]
                {
                    inventTable
                }
            };
            CallContext ctx = new CallContext()
            {
                Company = "CEU"
            };
            ItemServiceClient itemService = new ItemServiceClient();
            try
            {
                itemService.create(ctx, item);
            }
            catch (Exception e) { System.Console.WriteLine(e.Message); System.Console.ReadKey(); }
        }
        private void DistiunctProducts_Click(object sender, EventArgs e)
        {
            List<string[]> ProdData = ParseCSVFile("E:\\Products.csv", true);
            //Create a Product for each row in the .csv file
            foreach (string[] DistinctProduct in ProdData)
            {
                createDistinctProduct(DistinctProduct);
                releaseDistinctProduct(DistinctProduct);//distinct products
            }
        }
       
    }
}

Sample CSV:



Header Record
ProductNumber DAX2012BOM21
Searchname MS Dynamics AX 2012
ProdName MS Dynamics AX 2012
StorageDimGroup STD-DIM
SerialNumGroup CSIG
InventUnitID GM
PurchUnitID GM
SalesUnitID GM
ProdCompanyID CEU
ItemGroup CDS
ItemType Item
InventoryModelGroup STD
Base price PurchPrice
Item sales tax group(PO)
Item sales tax group(sales )
Price unit(purch) 1
Date of price(purch) 1/1/1900
Total discount(purch) Yes
Price unit(inv) 1
Date of price(inv) 1/1/1900
Price unit(sales) 1
Date of price(sales) 1/1/1900
Total discount(sales) Yes






Create a product master and a related product variant

To create a product master, use the EcoResProductService.create operation. Then use the EcoResProductMasterDimValue.create operation to associate product dimension values with the product master. Finally, use the EcoResProductService.create operation again, this time to create a product variant.
 The code to create a product master is similar to the code that creates a distinct product. The primary difference is the code that associates the product master with a product dimension group (Size-Dim is given in below code).
Release products
A product must be released to a company before it can be used in that company. The ItemService and InventDimCombinationService services serve this purpose. The former can be used to release distinct products and product masters. The latter can be used to release product variants. A product master must be released before any of its product variants can be released.
Release product master
The only information required to release a product to a company is the ID of the product and the ID by which it will be represented in the company (ItemId). It is possible to add information to the ItemService service. In the following example, information about the units used for storage, purchasing, and selling is provided.
Release a product variant
A product variant can be released after a related product master has been released. When you release a product variant to a company, the product variant can be identified in two different ways:
•             Use the product number of the product variant.
•             Use the ID of the associated product master in the company (ItemId) and the InventDim structure, with the relevant fields set to the dimension values for the variant (the ItemId/InventDim approach).


Code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ProcutMasterImport.ProductDataImportService;
using System.IO;
using System.Text.RegularExpressions;
namespace ProcutMasterImport
{
    public partial class Product : Form
    {
        internal static int ProdNumber = 0;
        internal static int Searchname = 1;
        internal static int ProdName = 2;
        internal static int StorageDimGroup = 3;
        internal static int SerialNumGroup = 4;
        internal static int InventUnitID = 5;
        internal static int PurchUnitID = 6;
        internal static int SalesUnitID = 7;
        internal static int ProdCompanyID = 8;
        internal static int ItemGroup = 9;
        internal static int ItemType = 10;
        internal static int InventoryModelGroup = 11;
        internal static int Baseprice = 12;
        //internal static int InventWareHouse   = 13;
        //internal static int PurchWareHouse    = 14;
        //internal static int SalesWareHouse    = 15;
        internal static int Itemsalestaxgroup_PO = 13;
        internal static int Itemsalestaxgroup_sales = 14;
        internal static int Priceunit_purch = 15;
        internal static int Dateofprice_purch = 16;
        internal static int Totaldiscount_purch = 17;
        internal static int Priceunit_inv = 18;
        internal static int Dateofprice_inv = 19;
        internal static int Priceunit_sales = 20;
        internal static int Dateofprice_sales = 21;
        internal static int Totaldiscount_sales = 22;
        //Master Data
        internal static int MasterProdNumber = 0;
        internal static int MasterSearchname = 2;
        internal static int MasterProdName = 3;
        internal static int DefaultColor = 5;
        internal static int DefaultConfig = 6;
        internal static int DefaultSiz = 7;
        internal static int BOMUnitID = 9;
        internal static int InputWeight = 24;
        internal static int ProductInstanceRelationType = 38; 
        internal static int Tareweight = 47;//Column Number in Excel = AV       
        internal static int TrackingDimGroupName = 49;
        internal static int MasterStorageDimGroup = 50;
        internal static int MasterProdDimGroup = 51;
        internal static int MasterLanguage = 52;
        internal static int MasterItemGroup = 53;
        internal static int MasterInventoryModelGroup = 54;
        internal static int MasterPriceunit_purch = 57;
        internal static int MasterPriceunit_sales = 58;
        internal static int MasterPriceunit_inv = 59;
        internal static int MasterItemsalestaxgroup_PO = 60;
        internal static int MasterItemsalestaxgroup_sales = 61;
        internal static int MasterProdCompanyID = 62;
        //Dim Import - Size
        internal static int MasterProdIDSize = 0;
        internal static int MasterProdSize = 1;
        internal static int MasterProdSizeName = 2;
        //Dim Import - Color
        internal static int MasterProdIDColor = 0;
        internal static int MasterProdColor = 1;
        internal static int MasterProdColorName = 2;
        //Dim Import - Config
        internal static int MasterProdIDConfig = 0;
        internal static int MasterProdConfig = 1;
        internal static int MasterProdConfigName = 2;
        //VariantaCreation
        internal static int MasterVariantID = 0;
        internal static int MasterVariantSearchname = 1;
        internal static int MasterVariantProdMaster = 2;
        internal static int MasterVariantName = 3;
        internal static int MasterVariantConfig = 4;
        internal static int MasterVariantSize = 5;
        internal static int MasterVariantColor = 6;
        internal static int MasterVariantCompanyID = 8;
        //internal static int MasterVariantConfigName = 9;
        //internal static int MasterVariantSizeName = 10;
        //internal static int MasterVariantColorName = 11;
        public static List<string[]> ParseCSVFile(string path, Boolean hasHeaders)
        {
            List<string[]> CSVRows = new List<string[]>();
            int rowNumber = 0;
            using (StreamReader inputFile = new StreamReader(path))
            {
                string line;
                string[] line1;
                while ((line = inputFile.ReadLine()) != null)
                {
                    String pattern = ",(?=(?:[^\"]*\"[^\"]*\")*(?![^\"]*\"))";
                    Regex r = new Regex(pattern);
                    line1 = r.Split(line);
                    if (hasHeaders != true || rowNumber != 0)
                    {
                        CSVRows.Add(line1);
                    }
                    rowNumber++;
                }
            }
            return CSVRows;
        }
        public Product()
        {
            InitializeComponent();
        }
     
                //                          //
        //Create a product master and a related product variant //
        //                          //
        static void createMaster(string[] _product)
        {
            //Boolean ismastercreated;
            //master definition
            AxdEntity_Product_EcoResProductMaster productMaster = new AxdEntity_Product_EcoResProductMaster()
            {
                DisplayProductNumber = _product[MasterProdNumber],
                ProductType = AxdEnum_EcoResProductType.Item,
                SearchName = _product[MasterSearchname]
            };
            productMaster.Translation = new AxdEntity_Translation[1];
            productMaster.Translation[0] = new AxdEntity_Translation()
            {
                LanguageId = "en-us",
                Name = _product[MasterProdName]
            };
            productMaster.Identifier = new AxdEntity_Identifier[1];
            productMaster.Identifier[0] = new AxdEntity_Identifier()
            {
                ProductNumber = _product[MasterProdNumber]
            };
            productMaster.ProductDimGroup = new AxdEntity_ProductDimGroup[1];
            productMaster.ProductDimGroup[0] = new AxdEntity_ProductDimGroup()
            {
                Product = _product[MasterProdNumber],
                ProductDimensionGroup = _product[MasterProdDimGroup]
            };
            productMaster.StorageDimGroup = new AxdEntity_StorageDimGroup[1];
            productMaster.StorageDimGroup[0] = new AxdEntity_StorageDimGroup()
            {
                Product = _product[MasterProdNumber], //"Bulb60W",
                StorageDimensionGroup = _product[MasterStorageDimGroup] //"Std-Dim"
            };
            productMaster.VariantConfigurationTechnology = AxdEnum_EcoResVariantConfigurationTechnologyType.PredefinedVariants;
            AxdEcoResProduct axdProduct = new AxdEcoResProduct()
            {
                Product = new AxdEntity_Product_EcoResProduct[1]
                {
                    productMaster
                }
            };
            CallContext ctx = new CallContext();
            EcoResProductServiceClient productService = new EcoResProductServiceClient();
            try
            {
                productService.create(ctx, axdProduct);
            }
            catch (Exception e)
            {
                System.Console.WriteLine(e.Message);
                System.Console.ReadKey();
            }
        }
        //                          //
        ///master dimensions Size //
        //                          //
        static void createMasterDimension_Size(string[] _productDimsSize)
        {
            //master dimensions definition (two sizes, L and M)
            AxdEntity_MasterDim_EcoResProductMasterSize sizeDimensionL = new AxdEntity_MasterDim_EcoResProductMasterSize()
            {
                SizeProductMaster = _productDimsSize[MasterProdIDSize],
                Size = _productDimsSize[MasterProdSize], //"L",
                EcoResSize = new AxdEntity_EcoResSize[1]
                {
                    new AxdEntity_EcoResSize()
                    {
                        Name =  _productDimsSize[MasterProdSize] //"L"
                    }
                },
                Description = _productDimsSize[MasterProdSizeName],
                SizeProductDimensionAttribute = 3173
            };
            AxdEcoResProductMasterDimValue axdDimValue = new AxdEcoResProductMasterDimValue()
            {
                MasterDim = new AxdEntity_MasterDim_EcoResProductMasterDimensionValue[1]
                {
                    sizeDimensionL
                }
            };
            CallContext ctx = new CallContext();
            EcoResProductMasterDimValueServiceClient masterDimensionService = new EcoResProductMasterDimValueServiceClient();
            try
            {
                masterDimensionService.create(ctx, axdDimValue);
            }
            catch (Exception e)
            {
                System.Console.WriteLine(e.Message); System.Console.ReadKey();
            }
        }
        //                          //
        ///master dimensions CONFIG definition (two sizes, L and M) //
        //                          //
        static void createMasterDimension_Config(string[] _productDimsConfig)
        {
            //master dimensions definition (two sizes, L and M)
            AxdEntity_MasterDim_EcoResProductMasterConfiguration ConfigDimensionL = new AxdEntity_MasterDim_EcoResProductMasterConfiguration()
            {
                EcoResConf = new AxdEntity_EcoResConf[1]
                {
                    new AxdEntity_EcoResConf()
                    {                        
                        Name = _productDimsConfig[MasterProdConfig]//_productDimsConfig[MasterProdConfigName]// "L"
                    }
                },
                ConfigProductMaster = _productDimsConfig[MasterProdIDConfig],
                Configuration = _productDimsConfig[MasterProdConfig],  //"L",               
                Description = _productDimsConfig[MasterProdConfigName],
                //AdditionalDescription = _productDimsConfig[MasterProdConfigName],
                ConfigProductDimensionAttribute = 3170
            };
            AxdEcoResProductMasterDimValue axdDimValue = new AxdEcoResProductMasterDimValue()
            {
                //SenderId = "3274",
                MasterDim = new AxdEntity_MasterDim_EcoResProductMasterDimensionValue[1]
                {                   
                    ConfigDimensionL//, ConfigDimensionM
                }
            };
            CallContext ctx = new CallContext();
            EcoResProductMasterDimValueServiceClient masterDimensionService = new EcoResProductMasterDimValueServiceClient();
            try
            {
                masterDimensionService.create(ctx, axdDimValue);
            }
            catch (Exception e)
            {
                System.Console.WriteLine(e.Message); System.Console.ReadKey();
            }
        }
        //                          //
        ///master dimensions Size //
        //                          //
        static void createMasterDimension_Color(string[] _productDimsColor)
        {
            //master dimensions definition (two sizes, L and M)
            AxdEntity_MasterDim_EcoResProductMasterColor colorDimensionL = new AxdEntity_MasterDim_EcoResProductMasterColor()
            {
                ColorProductMaster = _productDimsColor[MasterProdIDColor],
                Color = _productDimsColor[MasterProdColor], //"L",
                EcoResColor = new AxdEntity_EcoResColor[1]
                {
                    new AxdEntity_EcoResColor()
                    {
                        Name =  _productDimsColor[MasterProdColor] //"L"
                    }
                },
                Description = _productDimsColor[MasterProdSizeName],
                ColorProductDimensionAttribute = 3169
            };
            AxdEcoResProductMasterDimValue axdDimValue = new AxdEcoResProductMasterDimValue()
            {
                MasterDim = new AxdEntity_MasterDim_EcoResProductMasterDimensionValue[1]
                {
                    colorDimensionL
                }
            };
            CallContext ctx = new CallContext();
            EcoResProductMasterDimValueServiceClient masterDimensionService = new EcoResProductMasterDimValueServiceClient();
            try
            {
                masterDimensionService.create(ctx, axdDimValue);
            }
            catch (Exception e)
            {
                System.Console.WriteLine(e.Message); System.Console.ReadKey();
            }
        }
        //                          //
        ////product variant definition//
        //                          //
        static void createVariant(string[] _productVariant)
        {
            //product variant definition
            AxdEntity_Product_EcoResDistinctProductVariant productVariant = new AxdEntity_Product_EcoResDistinctProductVariant()
            {
                DisplayProductNumber = _productVariant[MasterVariantID], //"RunningShoeL",
                ProductType = AxdEnum_EcoResProductType.Item,
                SearchName = _productVariant[MasterVariantSearchname], //"RunningShoeL",
                ProductMaster = _productVariant[MasterVariantProdMaster] //"RunningShoe"
            };
            productVariant.Translation = new AxdEntity_Translation[1];
            productVariant.Translation[0] = new AxdEntity_Translation()
            {
                LanguageId = "en-us",
                Name = _productVariant[MasterVariantName] //"Comfortable running shoe L size"
            };
            productVariant.VariantDimValue = new AxdEntity_VariantDimValue_EcoResProductVariantDimensionValue[3];
            if (_productVariant[MasterVariantSize].ToString() != "")
            {
                productVariant.VariantDimValue[0] = new AxdEntity_VariantDimValue_EcoResProductVariantSize()
                {
                    DistinctProductVariant = _productVariant[MasterVariantID], //"RunningShoeL",
                    ProductDimensionAttribute = 3173,//The ID of the EcoResSize table
                    Size = _productVariant[MasterVariantSize], //"L",
                    EcoResSize = new AxdEntity_EcoResSize1[1]
                    {
                        new AxdEntity_EcoResSize1()
                        {
                            Name = _productVariant[MasterVariantSize] //"L"
                        }
                    }
                };
            }
            //added by imthiyaz - Color
            if (_productVariant[MasterVariantColor] != "")
            {
                productVariant.VariantDimValue[1] = new AxdEntity_VariantDimValue_EcoResProductVariantColor()
                {
                    DistinctProductVariant = _productVariant[MasterVariantID],
                    ProductDimensionAttribute = 3169,
                    Color = _productVariant[MasterVariantColor], //"L",
                    EcoResColor = new AxdEntity_EcoResColor1[1]
                {
                    new AxdEntity_EcoResColor1()
                    {
                        Name = _productVariant[MasterVariantColor]
                    }
                }
                };
            }
            //added by imthiyaz - Config
            if (_productVariant[MasterVariantConfig] != "")
            {
                productVariant.VariantDimValue[2] = new AxdEntity_VariantDimValue_EcoResProductVariantConfiguration()
                {
                    DistinctProductVariant = _productVariant[MasterVariantID],
                    ProductDimensionAttribute = 3170,
                    Configuration = _productVariant[MasterVariantConfig], //"L",
                    EcoResConf = new AxdEntity_EcoResConf1[1]
                {
                    new AxdEntity_EcoResConf1()
                    {
                        Name = _productVariant[MasterVariantConfig]
                    }
                }
                };
            }
            AxdEcoResProduct axdProduct = new AxdEcoResProduct()
            {
                Product = new AxdEntity_Product_EcoResProduct[1]
                {
                    productVariant
                }
            };
            CallContext ctx = new CallContext();
            EcoResProductServiceClient productService = new EcoResProductServiceClient();
            try
            {
                productService.create(ctx, axdProduct);
            }
            catch (Exception e)
            {
                System.Console.WriteLine(e.Message); System.Console.ReadKey();
            }
        }
      
        //                          //
        ////Release a product master//
        //                          //
        private static void releaseMasterProduct(string[] _productRelease)
        {
            AxdEntity_InventTable inventTable = new AxdEntity_InventTable()
            {
                ItemId = _productRelease[MasterProdNumber], //"Bulb60W",
                Product = _productRelease[MasterProdNumber], //"Bulb60W",
                SalesPriceModelBasic = AxdEnum_SalesPriceModelBasic.PurchPrice, //(AxdEnum_SalesPriceModelBasic)Enum.Parse(typeof(AxdEnum_SalesPriceModelBasic), _productRelease[Baseprice]),//_product[Baseprice],
                //SerialNumGroupId = _productRelease[SerialNumGroup],
                Invent = new AxdEntity_Invent[1]
                {
                    new AxdEntity_Invent()
                    {
                        ItemId = _productRelease[MasterProdNumber], //"Bulb60W",
                        UnitId = _productRelease[MasterPriceunit_inv] //"Box"
                    }
                },
                Purch = new AxdEntity_Purch[1]
                {
                    new AxdEntity_Purch()
                    {
                        ItemId = _productRelease[MasterProdNumber], //"Bulb60W",
                        UnitId = _productRelease[MasterPriceunit_purch] //"Box"
                    }
                },
                Sales = new AxdEntity_Sales[1]
                {
                    new AxdEntity_Sales()
                    {
                        ItemId = _productRelease[MasterProdNumber], //"Bulb60W",
                        UnitId = _productRelease[MasterPriceunit_sales] //"Pcs"
                    }
                },
                InventModelGroupItem = new AxdEntity_InventModelGroupItem[1]
                {
                    new AxdEntity_InventModelGroupItem()
                    {                       
                        ModelGroupId = _productRelease[MasterInventoryModelGroup]
                    }
                },
                InventItemGroupItem = new AxdEntity_InventItemGroupItem[1]
                {
                    new AxdEntity_InventItemGroupItem()
                    {
                        ItemGroupId = _productRelease[MasterItemGroup]
                    }
                }
            };
           
            /*inventTable.StandardInventColorId = _productRelease[DefaultColor];
            inventTable.StandardConfigId = _productRelease[DefaultConfig];
            inventTable.StandardInventSizeId = _productRelease[DefaultSiz];*/
            //default size, color, config cvon't be aasuigned here
            inventTable.BOMUnitId = _productRelease[BOMUnitID];
            inventTable.NetWeight = Decimal.Parse(_productRelease[InputWeight]);
            inventTable.TaraWeightSpecified = true;
            inventTable.MetalTypeSpecified = true;
            inventTable.TaraWeight = Decimal.Parse(_productRelease[Tareweight]);
         
            AxdItem item = new AxdItem()
            {
                InventTable = new AxdEntity_InventTable[1]
                {
                    inventTable
                }
            };
            CallContext ctx = new CallContext()
            {
                Company = _productRelease[MasterProdCompanyID] //"DMO"
            };
            ItemServiceClient itemService = new ItemServiceClient();
            try
            {
                itemService.create(ctx, item);
            }
            catch (Exception e)
            {
                System.Console.WriteLine(e.Message); System.Console.ReadKey();
            }
        }
        //                          //
        ///Use the ItemId/InventDim approach//
        //                          //      
        private static void releaseProductVariants2(string[] _productVariantRelease)
        {
            AxdEntity_InventDimCombination releasedVariant = new AxdEntity_InventDimCombination()
            {
                DistinctProductVariant = "",
                ItemId = _productVariantRelease[MasterVariantProdMaster],// "RunningShoe",
                InventDimId = "",
                InventDim = new AxdEntity_InventDim[1]
                {
                    new AxdEntity_InventDim()
                    {
                        InventSizeId = _productVariantRelease[MasterVariantSize], //"M",
                        InventColorId = _productVariantRelease[MasterVariantColor],
                        ConfigId = _productVariantRelease[MasterVariantConfig]
                    }
                }
            };
            AxdInventDimCombination inventDimCombination = new AxdInventDimCombination()
            {
                InventDimCombination = new AxdEntity_InventDimCombination[1]
                {
                    releasedVariant
                }
            };
            CallContext ctx = new CallContext()
            {
                Company = _productVariantRelease[MasterVariantCompanyID] //"DMO"
            };
            InventDimCombinationServiceClient inventDimCombinationService = new InventDimCombinationServiceClient();
            try
            {
                inventDimCombinationService.create(ctx, inventDimCombination);
            }
            catch (Exception e)
            {
                System.Console.WriteLine(e.Message); System.Console.ReadKey();
            }
        }
        private void ProductMaster_Click(object sender, EventArgs e)
        {
            List<string[]> ProdData = ParseCSVFile("D:\\ProductMasters.csv", true);
            foreach (string[] ProdMasterData in ProdData)
            {
                createMaster(ProdMasterData);
            }
        }
      
         private void CreateDims_Click(object sender, EventArgs e)
        {
            List<string[]> ProdDims_Size = ParseCSVFile("D:\\MasterDimSize.csv", true);
            foreach (string[] MasterDimensions_Size in ProdDims_Size)
            {
                createMasterDimension_Size(MasterDimensions_Size);
            }
            List<string[]> ProdDims_Color = ParseCSVFile("D:\\MasterDimsColor.csv", true);
            foreach (string[] MasterDimensions_Color in ProdDims_Color)
            {
                createMasterDimension_Color(MasterDimensions_Color);
            }
            List<string[]> ProdData_Config = ParseCSVFile("D:\\MasterDimConfig.csv", true);
            foreach (string[] MasterDimensions_Config in ProdData_Config)
            {
                createMasterDimension_Config(MasterDimensions_Config);
            }
        }
        private void CreateVariants_Click(object sender, EventArgs e)
        {
            List<string[]> ProdData_Variants = ParseCSVFile("D:\\ProductMasterVariants.csv", true);
            foreach (string[] ProdMasterData_Variants in ProdData_Variants)
            {
                createVariant(ProdMasterData_Variants);
            }
        }
        private void ReleaseAll_Click(object sender, EventArgs e)
        {
            List<string[]> ProdMasterData_Rel = ParseCSVFile("D:\\ProductMasters.csv", true);
            foreach (string[] ProdMasterDataRelease in ProdMasterData_Rel)
            {
                releaseMasterProduct(ProdMasterDataRelease);//master products              
            }
        }
        private void ReleaseVariants_Click_1(object sender, EventArgs e)
        {
            List<string[]> ProdData_VariantsRel = ParseCSVFile("D:\\ProductMasterVariants.csv", true);
            foreach (string[] ProdMasterData_VariantsRel in ProdData_VariantsRel)
            {
                releaseProductVariants2(ProdMasterData_VariantsRel);
            }
        }
    }
}


Sample CSV: