December 29, 2012

Import Opening Stock Balance into Dynamics AX

Import Opening Stock Balance into Dynamics AX

When we import opening stock balance into inventory journal using the standard import/export functionality, the most common problem is dealing with Inventory Dimension id (InventDimId). We might know the warehouse and batch, but we do not know what is the InventDimId that represents the combination of these two inventory dimension.
One way to do this is to lookup the InventDimId value manually before performing the import. This is only possible if very few inventory dimensions are used.


An alternative is using the Custom import functionality to import stock balance CSV file into Tag counting journal.
There is a conversion functionality in the Custom import, where you can write a little X++ code to find the InventDimId using the inventory dimensions.
Here is an example of finding the InventDimId using Site and Warehouse dimension.




You must select Run conversion checkbox to activate the conversion. You may also use the compile icon (on the right hand) to validate the X++ code.
The purpose to use Tag counting journal instead of Movement/Counting journal is we let the system to create the Lot ID when we post the Tag counting journal into Counting journal.


- Harry

December 07, 2012

Change company from the current company in X++ code

Change company from the current company in X++ code

If in any point you need to change change company during the code, This example will helps you to change the company from current company in x++ code.

static void main()
{
  CustTable custTable;
  ;
  //Assume that you are running in company 'DAT'.
  changeCompany('DAT1') //Default company is now 'DAT1'.
  {
    custTable = null;
    while select custTable
    {
       //custTable is now selected in company 'DAT1'.
    }
  }
 //Default company is again set back to 'DAT'.
 changeCompany('DAT2') //Default company is now 'DAT2'.
 {
   //Clear custTable to let the select work
   //on the new default company.
   custTable = null;
   while select custTable
    {
      //custTable is now selected in company 'DAT2'.
    }
 }
//Default company is again 'DAT'.

}

-Harry.