Sunday, January 1, 2017

How to find BOM Unit and Inventory Unit for item in Ax 2012

To find BOM Unit and Inventory Unit for item you can get idea from below code sample.This code you can try in your job code editor in axapta.

 InventTable     inventTable;  
   InventUnitId    inventoryUnit,BOMUnit;  
   BOM         bom;  
   ItemId       curItem;  
   while select BOM  
     order by itemid  
     where BOM.BOMQty  
     if(curItem != BOM.ItemId)  
       curItem = BOM.ItemId;  
       inventTable = InventTable::find(bom.ItemId);  
       inventoryUnit = inventTable.InventUnitId();  
       BOMUnit = bom.UnitId;  
         if(inventoryUnit != BOMUnit)  
           info(strFmt("item %1 has bom unit %2, inventory unit %3",inventTable.itemId,BOMUnit,inventoryUnit));  

Wednesday, December 28, 2016

Steps to Create cube through Axapta

->First step is you need to Create a perspective for a cube

a)A perspective is a collection of tables and views that is used to identify the tables and views that contain measures and dimension attributes for a cube. After you create a perspective, you can use it to generate an Analysis Services cube through SQL Analysis Wizard.

b) Specify measures and attributes in Perspective and Set required properties for Perspective.

c) Generate and deploy the Analysis Services project using Perspective.

d) View cube objects in the generated project and see dimension relationship is ok or not. If not then you need to rework with your perspective and deployment.

e)Deploy you cube then you can see your cube in SQL analysis connect.

e) Process cube.

Wednesday, December 21, 2016

Code to get Invoice settlement data for customer in ax 2012

This is simple Code to get Invoice settlement amount data for customer payment in ax 2012. This data is after posting of data.

  select sum(SettleAmountCur) from custSettlement where  
           custSettlement.TransRecId == custtrans.RecId  

If you want get settlement amount before posting than you can refer spectrans table.The table SpecTrans contains all the transactions marked for settlement for payment journal.

 while select spectrans  
 join custtransopen  
 join custtrans  
 where spectrans.SpecCompany == ledgerjournaltrans.DataAreaId &&  
 spectrans.SpecTableId == ledgerjournaltrans.TableId &&  
 spectrans.SpecRecId == ledgerjournaltrans.RecId &&  
 spectrans.RefCompany == custtranssopen.DataAreaId &&  
 spectrans.RefTableId == custtranssopen.TableId &&  
 spectrans.RefRecId == custtranssopen.RecId &&  
custtransopen.RefRecId == custtrans.RecId &&  
 custtransopen.AccountNum == custtrans.AccountNum  
 info(strFmt('%1', custtrans.Invoice));  

Thursday, December 15, 2016

Ternary Operator Example in Axapta

This is Ternary Operator Example in Axapta. Its same as below if else condition results.

 str result;  
   result = (custTable::find("US-027").RecId) ? "found" : "not found";  
   // Same as   

     resut= "found";  
     resut= "not found";