Skip to content

Filtering

Tracelake supports two levels of filtering to reduce data scope and improve validation performance:

Global Client Filtering

Client filtering applies to all tables in a validation plan that have SAP client fields (MANDT, RCLNT, or CLNT).

You can setup a client filter in the Plan settings.

For example, if you are only replicating data from client 100, you can setup the client filter as follows:

Client filter

Table-Level Filtering

Table-level filters allow you to specify custom WHERE clause conditions for individual tables. This is particularly useful for:

  • Large table optimization: Limit validation to recent or relevant data
  • Cost reduction: Process fewer rows to reduce usage billing
  • Performance improvement: Faster execution with smaller datasets
  • Targeted validation: Focus on specific business scenarios

Configuring Table Filters

  1. Navigate to your validation plan
  2. Go to the Tables tab
  3. Click Manage Tables
  4. In the Filter Conditions column, enter your WHERE clause condition
  5. Save your changes

Filter Examples

Time-Based Filtering (Common for SAP)

-- Fiscal year filtering
GJAHR >= '2023'
GJAHR = '2024'
CALYEAR >= '2023' AND CALYEAR <= '2024'
-- Date-based filtering
CREATED_DATE > '2024-01-01'
POSTING_DATE >= '2023-01-01'

Organizational Filtering

-- Company code filtering
BUKRS = 'US01'
BUKRS IN ('US01', 'DE01', 'UK01')
RBUKRS = '1000'
-- Plant or location filtering
WERKS = '1000'
LGORT IN ('0001', '0002')

Document-Specific Filtering

-- Specific document types
DOCTYP = 'SA'
BSTAT = 'REL'
-- Document number ranges
BELNR LIKE 'SA%'
VBELN >= '0000100000'

Complex Conditions

-- Multiple criteria
GJAHR >= '2023' AND BUKRS = 'US01'
(CALYEAR >= '2023' OR PRIORITY = 'HIGH') AND STATUS = 'ACTIVE'
-- Exclude certain values
BUKRS != 'TEST' AND GJAHR >= '2023'
DOCTYP NOT IN ('TEST', 'TEMP')

Security and Validation

Tracelake automatically validates filter conditions for security:

  • SQL injection prevention: Dangerous keywords (DROP, DELETE, etc.) are blocked
  • Syntax validation: Checks for balanced parentheses and proper formatting
  • No WHERE keyword: Don’t include “WHERE” - it’s added automatically
  • Semicolon protection: Multiple statements are prevented

How Filters Work

When validation runs, filters are combined using AND logic:

-- Example with both global client filter and table filter
WHERE MANDT = '100' AND (GJAHR >= '2023' AND BUKRS = 'US01')

Performance Benefits

Table filtering provides significant benefits:

  • Reduced data volume: Only relevant records are processed
  • Lower costs: Fewer rows counted toward usage billing
  • Faster execution: Smaller result sets improve speed
  • Network efficiency: Less data transfer between databases

Best Practices

  1. Start broad, then narrow: Begin with time-based filters like fiscal year
  2. Test filters: Verify your filter logic returns expected data
  3. Document filters: Note why specific filters were applied
  4. Monitor performance: Track validation duration improvements
  5. Update regularly: Adjust time-based filters as needed (e.g., new fiscal years)

Legacy Compatibility

Existing validation plans continue to work without changes. Table filters are optional and can be added gradually to optimize specific tables as needed.