Leer Tipo de dirección – AX2012

  1. public static LogisticsPostalAddress getPostalAddressByType(DirPartyRecId _party, LogisticsLocationRoleType _type)
  2.  
  3. {
  4.  
  5.     DirPartyLocation        partyLocation;
  6.  
  7.     DirPartyLocationRole    partyLocationRole;
  8.  
  9.     LogisticsLocation       location;
  10.  
  11.     LogisticsLocationRole   locationRole;
  12.  
  13.     LogisticsPostalAddress  postalAddress;
  14.  
  15.  
  16.     select firstonly postalAddress
  17.  
  18.         exists join location
  19.  
  20.             where location.RecId == postalAddress.Location
  21.  
  22.         exists join locationRole
  23.  
  24.             where locationRole.Type  == _type
  25.  
  26.         exists join partyLocation
  27.  
  28.             where 
  29.  
  30.                 partyLocation.Location == location.RecId &&
  31.  
  32.                 partyLocation.Party == _party
  33.  
  34.         exists join partyLocationRole
  35.  
  36.             where partyLocationRole.PartyLocation == partyLocation.RecId &&
  37.  
  38.                 partyLocationRole.LocationRole == locationRole.RecId;
  39.  
  40.  
  41.     return postalAddress;
  42.  
  43. }

Query inventario a fecha

  1. static void TIDF_getInventPhysicalbyDate(Args _args)
  2. {
  3.     InventDimParm inventDimParmCrit;
  4.     InventSumDateDim inventSumDateDim;
  5.     InventDim inventDim = InventDim::find('AllBlank');
  6.     InventQty inventQty;
  7.     ;
  8.  
  9.     // Set the dimensions
  10.     inventDimParmCrit.initFromInventDim(inventDim);
  11.     inventSumDateDim = inventSumDateDim::newParameters(today(), '010410003', inventDim, inventDimParmCrit);
  12.     inventQty =  inventSumDateDim.receivedQty()-InventSumDateDim.deductedQty()+InventSumDateDim.postedQty();
  13.  
  14.     info(strFmt("%1",inventQty));
  15. }

Test DataProvider de SSRS

  1. static void Job3(Args _args)
  2. {
  3. 	TmpABC tempTable;
  4. 	InventABCDP dataProvider = new InventABCDP();
  5. 	InventABCContract contract = new InventABCContract();
  6. 	contract.parmABCModel(ABCModel::Link);
  7. 	contract.parmCategoryA(10);
  8. 	contract.parmCategoryC(20);
  9. 	contract.parmCategoryB(70);
  10. 	contract.parmInterest(2.5);
  11.  
  12. 	dataProvider.parmDataContract(contract);
  13. 	dataProvider.processReport();
  14. 	tempTable = dataProvider.getTmpABC();
  15.  
  16. 	while select tempTable
  17. 	{
  18. 		info(tempTable.ItemName);
  19. 	}
  20. }

Ver fragmentación de indices de tablas

https://blogs.msdn.microsoft.com/dynamics_latam/2010/09/27/cmo-conocer-el-porcentaje-de-fragmentacin-para-los-ndices-en-tablas-de-microsoft-dynamics-ax/

  1. SELECT  t4.name AS [schema_name]
  2.    ,       t3.name AS TABLE_NAME
  3.    ,       t2.name AS index_name
  4.    ,  t1.object_id
  5.    ,  t1.index_id
  6.    ,  t1.partition_number
  7.    ,  t1.index_type_desc
  8.    ,  t1.avg_fragmentation_in_percent
  9.    ,  t1.avg_fragment_size_in_pages
  10.    ,  t1.page_count
  11.    FROM sys.dm_db_index_physical_stats(db_id(),NULL,NULL,NULL,'LIMITED' ) t1
  12.    INNER JOIN sys.objects t3 ON (t1.object_id = t3.object_id)
  13.    INNER JOIN sys.schemas t4 ON (t3.schema_id = t4.schema_id)
  14.    INNER JOIN sys.indexes t2 ON (t1.object_id = t2.object_id AND  t1.index_id = t2.index_id )
  15.    WHERE index_type_desc <> 'HEAP'
  16.    ORDER BY t4.name,t3.name,t2.name,partition_number