Data Upgrade Manual Bulk Copy and generation of Direct SQL Scripts using X++ Job

  • During data upgrade often it comes a requirement to run Bulk Copy for some tables which were unable to be Bulk Copied Before due to any reason (which could be table / field mapping issue etc..)
  • Now if the particular tables were unable to be Bulk copied from source to target since there Direct Sql Script was not generated which is stored in ReleaseUpdateBulkCopyTable in AX 2012 in Field named 'DirectSQl' :
  • To generate that DirectSQL script to perform Bulk Copy follow the following procedure:
    • The class which handles the Bulk Copy process is 'ReleaseUpdateBulkCopyDB', few thing we will need prior to execute the below script is to Obtain the Source and Target connection string which could be obtaine from table 'RELEASEUPDATEBULKCOPYPARAMETERS',
    •  Use the following SQL Script to fetch this information : 
      • Select * from RELEASEUPDATEBULKCOPYPARAMETERS
    • Copy the SourceConnectionString and TargetConnectionString and update the below X++ job :
static void BulkCopy(Args _args)
{
ReleaseUpdateBulkCopyTable ReleaseUpdateBulkCopyTable;
ReleaseUpdateBulkCopyDB BC = new ReleaseUpdateBulkCopyDB();
BC.setSourceConnection('<SourceConnectionString >');
BC.setTargetConnection('<TargetConnectionString>');
BC.initConnections();
while select ReleaseUpdateBulkCopyTable
where ReleaseUpdateBulkCopyTable.oldtablename== <tableName>
{
BC.bulkCopyTable(ReleaseUpdateBulkCopyTable);
}
}

Execute this Job with the Condition as per requirenment  , this will generate the DirectSql and perform the Bulk Copy of Data from Source to target.



Comments

Popular posts from this blog

D365: SSRS Report Development/ Customization

D365: X++ code to add custom lookup on worker to show specific workers team workers only

Error message when you log on to a Microsoft Dynamics AX 4.0 client: "You are not a recognized user of Microsoft Dynamics AX"