giovedì 10 settembre 2020

AX2012 - How to extract TMSCarrier addresses and addresses roles

 If you need to extract from an AX2012 R3 the full list of addresses and their roles you can use the following job.


 static void A_GiaImportCarrierAddresses(Args _args)  
 {  
      TMSCarrier             TMSCarrier;  
      LogisticsPostalAddress       LogisticsPostalAddress;  
      Tmscarrierlogisticslocation     TMScarrierlogisticslocation;  
      TMSCarrierLogisticsLocationRole   TMSCarrierLogisticsLocationRole;  
      LogisticsLocation          LogisticsLocation;  
      LogisticsLocationRole        logisticslocationrole;  
   
      while select TMScarrier  
           join TMScarrierlogisticslocation  
           where TMSCarrier.recid == TMScarrierlogisticslocation.Carrier  
           join LogisticsPostalAddress  
           where LogisticsPostalAddress.Location == TMScarrierlogisticslocation.Location  
           join LogisticsLocation  
           where LogisticsLocation.recid == LogisticsPostalAddress.Location  
           join TMSCarrierLogisticsLocationRole  
           where TMSCarrierLogisticsLocationRole.LocationLogisticsLocation == TMScarrierlogisticslocation.recid  
           join LogisticsLocationRole  
           where logisticslocationrole.RecId == TMSCarrierLogisticsLocationRole.LocationRole  
   {  
     info( strFmt("%1; %2; %3; %4; %5; %6",LogisticsPostalAddress.street,  
                                                         LogisticsPostalAddress.ZipCode,  
                                                         LogisticsPostalAddress.City,  
                                                         LogisticsPostalAddress.CountryRegionId,   
                                                         LogisticsLocation.Description,  
                                                         logisticslocationrole.Name));  
   }  
 }  


The result will be the following one.