Friday, 4 May 2018

AX 2012 R3 - Retail POS - Clear all existing transactions from the POS DB/CDX Server/CDX Client

When reloading environments sometimes it is necessary to reset the retail pos, cdx server, cdx client and back office databases to show none of the previous transactions that once existed within the system.


In order to clear it out we need to do the following (with CDX server + client services offline)


POSDB - AXRetailPOS
--current transactions within the pos system
truncate table ax.RetailPosBatchAccountTrans
truncate table ax.RetailPosBatchTable
truncate table ax.RetailPosBatchTenderTrans
truncate table ax.RetailTransactionBankedTenderTrans
truncate table ax.RetailTransactionTenderDeclarationTrans
truncate table ax.RetailTransactionDiscountTrans
truncate table ax.RetailTransactionIncomeExpenseTrans
truncate table ax.RetailTransactionInfocodeTrans
truncate table ax.RetailTransactionLoyaltyRewardPointTrans
truncate table ax.RetailTransactionOrderInvoiceTrans
truncate table ax.RetailTransactionPaymentTrans
truncate table ax.RetailTransactionSafeTenderTrans
truncate table ax.RetailTransactionSalesTrans
truncate table ax.RetailTransactionTable
truncate table ax.RetailTransactionTaxTrans

CDX_AsyncClient DB
--clear previous syncs
truncate table dbo.datastore
truncate table dbo.downloadsession
truncate table dbo.downloadsessionLog
truncate table dbo.offlinedataexportlog

CDX_AsyncServer DB
--clear previous syncs
truncate table dbo.UPLOADSESSIONLOG
truncate table dbo.UPLOADSESSION
truncate table dbo.DOWNLOADSESSIONDATASTORELOG
truncate table dbo.DOWNLOADSESSIONDATASTORE
truncate table dbo.DOWNLOADSESSION


--clear base info (optional)
truncate table dbo.FILESTORAGEPROVIDER
truncate table dbo.JOB
truncate table dbo.SCHEDULERINTERVAL
truncate table dbo.SCHEDULEPARAMETER
truncate table dbo.SCHEDULEJOB
truncate table dbo.SCHEDULEDATAGROUP
truncate table dbo.DATASTOREHEARTBEATLOG
truncate table dbo.DATASTORE
truncate table dbo.DATAGROUP
truncate table dbo.AUTHENTICATIONLOG



If there are transaction with the back office AX then you may need to do the following

Company/Retail/Journals/Open statements > remove all statements that pertain to the pos system

Then run the following job

static void ClearRetailTransactions(Args _args)
{
    RETAILTRANSACTIONBANKEDTENDERTRANS retailTable1;
    RETAILTRANSACTIONTENDERDECLARATIONTRANS retailTable2;
    RETAILTRANSACTIONDISCOUNTTRANS retailTable3;
    RETAILTRANSACTIONINCOMEEXPENSETRANS retailTable4;
    RETAILTRANSACTIONINFOCODETRANS retailTable5;
    RETAILTRANSACTIONLOYALTYREWARDPOINTTRANS retailTable6;
    RETAILTRANSACTIONORDERINVOICETRANS retailTable7;
    RETAILTRANSACTIONPAYMENTTRANS retailTable8;
    RETAILTRANSACTIONSALESTRANS retailTable9;
    RETAILTRANSACTIONTABLE retailTable10;
    RETAILTRANSACTIONTAXTRANS retailTable11;
    
    ttsbegin;
    delete_from retailTable1;
    delete_from retailTable2;
    delete_from retailTable3;
    delete_from retailTable4;
    delete_from retailTable5;
    delete_from retailTable6;
    delete_from retailTable7;
    delete_from retailTable8;
    delete_from retailTable9;
    delete_from retailTable10;
    delete_from retailTable11;
    ttscommit;

    info('done');
}



Finally you will want to remove all of the previous cdx sync files located in 
Company/Retail/Setup/Retail scheduler/Channel integration/working folders


Once this is completed you should follow the normal store setup if it is not already done.

Note: if you run the sql under --clear base info (optional) you will need to run the sync metadata function (button) that is located @
Company/Retail/Setup/Parameters/Retail scheduler parameters

Update: depending on if you are transferring data from one environment to the next  you may run into an issue where the data will download but wont upload you may need to clear out/update the following tables depending on what you are trying to do.

Clearing these tables will force a complete refresh of all pos transactions into the back office.

POSDB - AXRetailPOS:
truncate table [crt].[TABLEREPLICATIONLOG]
truncate table [crt].[UPLOADSESSION]

No comments:

Post a Comment