DELETE FROM tbl_IMPORT_RebateContracts WHERE processDate < DATEADD (m , -6 , getDate() ) UPDATE tbl_IMPORT_RebateContracts SET ClaimID = , ImportAction = WHERE eai_batchID =

Step 1

Created batch #variables.operator_batchId#: BASE_OPERATORS_TXT

Step 1

Rebate Contracts to be loaded next.
UPDATE stage SET stage.fseOperatorid = stage2.fseOperatorid FROM tbl_IMPORT_RebateContracts stage INNER JOIN tbl_IMPORT_Operators stage2 ON (stage.eai_LineNumber = stage2.eai_LineNumber) WHERE stage.eai_batchid = AND stage2.eai_batchid = UPDATE stage SET stage.fseOperatorid = stage2.fseOperatorid FROM tbl_IMPORT_RebateContracts stage INNER JOIN tbl_IMPORT_Operators stage2 ON (stage.UnitName = stage2.Company_Name AND stage.UnitAddress = stage2.Company_Address1 AND stage.UnitCity = stage2.Company_City) WHERE stage.eai_batchid = AND stage2.eai_batchid = AND stage.fseOperatorID IS NULL AND stage2.fseOperatorID IS NOT NULL #_resultsText#

Step 2

Batch #qry_getBatchIDs.cycle_batchID_1#: BASE_OPERATORS_TXT Completed
UPDATE tbl_IMPORT_RebateContracts SET saletransactionDate = null WHERE eai_batchid = AND saletransactionDate = '1900-01-01 00:00:00.000' SELECT Skulength FROM tbl_PRD_Settings WHERE OwnerID = AND FSL_TableCode = ; UPDATE tbl_IMPORT_RebateContracts SET productCode = rtrim(ltrim(productCode)), productDescription = rtrim(ltrim(productDescription)) WHERE eai_batchid = UPDATE stage SET stage.productCode = s.sku FROM tbl_IMPORT_RebateContracts stage INNER JOIN tbl_PRD_Packaging p ON (stage.scc14 = p.scc14) INNER JOIN tbl_PRD_Skus s ON (s.skuid = p.linkid AND p.linkType = 'SKU') WHERE stage.eai_batchid = AND nullif(stage.productCode,'') IS NULL AND nullif(p.scc14,'') IS NOT NULL AND p.OwnerID = AND p.FSL_TableCode = ; UPDATE tbl_IMPORT_RebateContracts SET productCode = REPLICATE ( '0' , #val(qmd_getSkuLength.skulength)# - DATALENGTH(productCode)) + productCode WHERE eai_batchid = AND nullif(productCode,'') IS NOT NULL and DATALENGTH(productCode) < UPDATE tbl_IMPORT_RebateContracts SET productCode = distributorsku WHERE eai_batchid = AND nullif(productCode,'') IS NULL AND nullif(scc14,'') IS NULL AND nullif(distributorsku,'') IS NOT NULL select eai_lineNumber, claimid, productCode, productdescription, rate, totalDollars, fseOperatorID, unitName, quantity, unitSector1, unitSector2, unitOfMeasure, unitPrice, fsl_distributorID, distributorID, distributor, unitID, distributorBranch, distributorSku, scc14, TerritoryCode, SaleTransactionDate, UnitAddress2, distributorParentID, cdr_recordID from tbl_IMPORT_RebateContracts where eai_batchid = and ( nullif(productCode,'') IS NOT NULL or nullif(scc14,'') IS NOT NULL) UPDATE tbl_TBA_Claims SET UnitLevelData = WHERE OwnerID = AND FSL_TableCode = AND ClaimID = ; select * from qry_RebateAllowances where skuCode = select * from qry_RebateAllowances where SubmittedSkuCode = and SubmittedSkuDesc = UPDATE tbl_IMPORT_RebateContracts SET ProductCode = , ProductDescription = , SubmittedProductCode = , SubmittedProductDesc = FROM tbl_IMPORT_RebateContracts WHERE eai_batchid = AND eai_lineNumber =

Step 3

Batch #attributes.batchId#: Rebate Products Load Completed
SELECT stage.MFR_dstid, stage.claimID, stage.Distributor, stage.DistributorBranch, stage.ProductCode, stage.productdescription, sum(stage.Quantity) AS Quantity, sum(stage.TotalDollars) AS TotalDollars , max(stage.Rate) rate, stage.Validated, stage.CHO_dstid, stage.FSL_dstid, stage.MFR_dstid, stage.scc14, COALESCE(cdr.cdr_dstname, stage.DistributorBranch) cdr_dstname FROM tbl_IMPORT_RebateContracts stage LEFT OUTER JOIN tbl_CDR_Distributors cdr ON (stage.MFR_dstid = cdr.cdr_recordID) WHERE eai_batchiD = GROUP BY stage.claimID, stage.Distributor, stage.ProductCode, stage.Quantity, stage.TotalDollars, stage.Validated, stage.CHO_dstid , stage.FSL_dstid, stage.MFR_dstid, stage.scc14, stage.Rate, cdr.cdr_dstname, stage.DistributorBranch, stage.productdescription ORDER BY DistributorBranch, ProductCode SELECT RowID, Quantity, dst_Dataid FROM tbl_TBA_DistributorData WHERE ClaimID = AND ProductCode = AND dst_dataID = ; UPDATE dstData SET dstData.Validated = 1 FROM tbl_TBA_DistributorData dstData INNER JOIN tbl_PRD_Skus s ON s.sku = dstData.productCode WHERE dstData.claimID = AND s.ownerid = AND s.fsl_tableCode =

Step 4

Batch #attributes.batchId#: Rebate Distributor Data Load Completed
#_resultsText#

#dspOperatorAddResults#

#dspDistributorResults#
UPDATE stage SET stage.skuid = s.skuid, stage.prodid = s.prodid FROM tbl_IMPORT_RebateContracts stage INNER JOIN tbl_PRD_Skus s ON rtrim(s.sku) = rtrim(stage.productcode) WHERE stage.eai_batchid = AND s.ownerid = AND s.fsl_tableCode = AND s.mfrid = UPDATE tbl_TBA_Claims SET OUASent = 1, OUASentDate = getDate() WHERE claimID =

Step 5

Batch #attributes.batchId#: Operator Unit Data (GPO Activity) Complete
#processorOutput#