---
title: Retrieve print-control batches pending processing
summary: Loads print-control batch headers that are either explicitly unprocessed or stale, for cleanup or reprocessing.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-07-30
library: SAIF.Services.Printing.Remote
reference_type: package
operation_id: OP-004
trigger: A batch or cleanup job calls clsXPrintControlCollection.GetXprintControlCollection with a processed-date cutoff
---

# Retrieve print-control batches pending processing

This operation loads the set of print-control batch headers that still need attention: those not yet marked processed by a given cutoff date, or those that have simply gone stale regardless of processed status. It is the collection-level counterpart to the single-header retrieval in [Print-control batch header lifecycle](print-control-batch-header-lifecycle.md).

| Field | Value |
| --- | --- |
| **Operation ID** | OP-004 |
| **Trigger** | Caller invokes `clsXPrintControlCollection.GetXprintControlCollection(inProcessedDate)` |
| **Inputs** | Processed-date cutoff |
| **Outputs** | Collection of `clsXPrintControl` matching the pending/stale criteria |
| **Primary components** | `clsXPrintControlCollection.BeforeRetrieve`, `clsXPrintControlCollection.AfterRetrieve` |
| **Entry point** | `Services\SAIF.Services.Printing.Remote\clsXPrintControlCollection.vb` |

## Steps

1. **Set up the retrieval criteria.** Caller invokes `GetXprintControlCollection(inDataportal, inProcessedDate)`. `Criteria.New` sets `ProcessedDate` from the argument and computes `ThirtyDaysAgoDate = Today.AddDays(-30)`.
2. **Bind and execute the query.** `BeforeRetrieve` binds both `:ProcessedDate` and `:ThirtyDaysAgoDate` and executes [SQL-014](../sql/SQL-014-saif-services-printing-remote.md) (`SELECT ... FROM XPRINT_CONTROL WHERE PROCESSED_DATE < :ProcessedDate OR CREATE_DATE < :ThirtyDaysAgoDate`, [XPRINT_CONTROL](../database-tables.md#xprint_control)) — a batch is included when it is explicitly unprocessed by the supplied cutoff, or when it is simply stale by create date regardless of processed status ([BR-003](../business-rules.md#br-003-print-control-batch-staleness-rule)).
3. **Load the matching rows.** `AfterRetrieve` iterates the `IDataReader`, constructing a `clsXPrintControl` per row via `Load()`/`Fill()` and adding each to the collection.

## Process flow

The following diagram visualizes the pending/stale batch retrieval.

```mermaid
flowchart TD
	Start([Caller supplies ProcessedDate cutoff]) --> Calc[Compute ThirtyDaysAgoDate<br>= Today - 30 days]
	Calc --> Query[Query XPRINT_CONTROL WHERE<br>ProcessedDate < cutoff<br>OR CreateDate < 30 days ago]
	Query --> Load[Load each matching row<br>into the collection]
	Load --> End([Collection returned to caller])
```

## Failure and edge-case behavior

- A batch that has never been processed and is also older than 30 days matches both conditions in the `OR` clause, but is only returned once (no duplicate rows).
- A recently created but already-processed batch (processed date on or after the cutoff, and created within 30 days) is correctly excluded from the pending set.
- The 30-day staleness window is a hard-coded default (`Today.AddDays(-30)`) with no caller override, unlike the processed-date cutoff which is caller-supplied.

## Related documentation
- [Operations and processes](../operations-processes.md)
- [Business rules](../business-rules.md)
- [SQL catalog](../sql/index.md)
- [Database tables](../database-tables.md)

## Sources
- `Services\SAIF.Services.Printing.Remote\clsXPrintControlCollection.vb`
