Skip to main content

Route drains

Warden ships four route drain batches. Each one raises approval work items that Warden owes but was not allowed to raise at the moment it held the document. This page describes what the four have in common once, then each drain under the standard process headings.

DrainClassRaises the approval owed for
Delta route drainMGCWardenDeltaRouteDrainBatchPurchase order changes held for delta or excluded-class re-approval
Firming route drainMGCWardenFirmingRouteDrainBatchPlanned-order firmings held for firming approval
Trade agreement route drainMGCWardenTARouteDrainBatchClassic trade agreement journals gated for price governance approval
Journal route drainMGCWardenJournalRouteDrainBatchInventory journals that meet a banded review

The scheduling instruction for customers is in Getting started. How Warden batches work in general is in Warden batch framework.


Shared behaviour​

Why the drains exist​

Warden places its holds inside the transaction of the native action that it governs: the purchase line update, the firming transaction, the trade agreement journal write or posting, the inventory journal posting. The hold commits or rolls back with that action, so the document is gated the moment the action lands.

Workflow activation cannot safely happen inside that transaction. Inside a transaction, a catch naming UpdateConflict or DuplicateKeyException runs and every other catch does not, so a failed activation there would either refuse the user's action or go unrecorded. So the seam places the hold, leaves a record that an approval is owed, and stops. The drain is the transaction-free process that later raises the approval. A batch task starts outside any transaction, so the drains' own catch blocks run.

Without a scheduled drain, a document that was held and then left alone stays held with no work item, and nobody can release it.

native action (inside its own transaction) route drain (no transaction)
------------------------------------------- -----------------------------
Warden seam places hold --------+ finds owed records
Warden writes owed record | commits asks the workflow runtime: route exists?
(diff set Pending, firming +--------------> no -> claims the record
request PendingApproval, submits the approval workflow
gate state Gated, ...) announces the deferred HoldPlaced event
yes -> settles, raises nothing

How they are built​

  • Each drain is a RunBaseBatch class with no dialog fields. pack() returns conNull() and unpack() accepts anything, so there is nothing to configure and nothing a stored batch task can lose.
  • main() is prompt() then runOperation(). canRunInNewSession() returns true, so an interactive run from the menu goes through the platform's operation sandbox and the client shows a progress form.
  • Each run writes one summary line to the infolog (and so to the batch task's log). The wording is quoted under each drain below.
  • None implements BatchRetryable.

Nothing schedules them​

No Warden code creates a batch job for any drain. Each ships inert until an administrator gives it a recurrence. The decision is recorded in the class summaries and on MGCWardenSetupGapCheck::routeDrainGap: the interval is the control's latency, and a job that appears because metadata was installed has no owner, company, batch group or chosen interval.

Instead, Warden setup gaps (System administration → Setup → Warden setup gaps) raises three rules per drain, twelve in total:

RuleFires whenConditioned on the area being in use?
*DrainOwedNo recurring job for the drain in this company, and at least one owed record exists. The row names the count.No. An owed record is its own evidence.
*DrainNotScheduledNo recurring job for the drain in this company.Yes (see each drain).
*DrainStaleA recurring job exists, and the oldest owed record is at least 4 hours old (#DrainStaleHours).No.

The rule names are DeltaDrain*, FirmingDrain*, TaDrain* and JournalDrain*; the area codes on the page are ROUTEDRAIN, FIRMDRAIN, TADRAIN and JOURNALDRAIN.

How the page decides that a drain is scheduled:

  • It reads the platform Batch and BatchJob tables for a task of the drain's class whose Batch.Company is the current company. A drain scheduled in another legal entity does not count, because each drain reads only the company it runs in.
  • The job must be Waiting, Ready or Executing.
  • The job must carry recurrence data. A one-off run is not a schedule.

The page is computed per company, so a multi-company deployment sees one row for each company whose drain is unscheduled.

The Stranded hold rule (StrandedHold, 4 hours, #StrandedHoldHours) is a separate, wider monitor over every Warden hold. It catches held documents that no drain, retry or lever will route.

Exactly one work item per document​

The drains must not raise a second approval for a document that already has one. They rely on three things rather than on the overlap guard:

  • The workflow runtime is asked. Each drain asks MGCWardenRouteExistenceCheck whether an approval exists before it raises one, and asks again after it has taken its claim. A workflow that stopped with an error and that the runtime still holds counts as a route, so no second one is raised beside it.
  • A claim. The delta drain moves the diff set to Claimed. The other three stamp a claim time on their own record (RouteClaimedDateTime on MGCWardenFirmingRequest, MGCWardenTAGateState and MGCWardenJournalGovState). A claim younger than 60 minutes blocks every other raiser; an older one is treated as abandoned (MGCWardenStaleClaimPolicy, #StaleClaimMinutes = 60, a constant and not a parameter).
  • One pass, one record at a time. Each drain first reads the RecIds of its candidates, then re-reads each record before acting on it.

Because of these, two runs of the same drain at the same time do not duplicate work, and MGCWardenBatchOverlapGuard does not cover the drains. The MGCWardenBatchService summary records this.

Give-up rules​

Two rules stop a drain from retrying the same failure for ever.

RuleApplies toCountsOutcome
Lost-activation boundFirming, trade agreement, journalActivations the runtime accepted and then lost (canceled, given up, or faulted and released) for one document. #MaxLostActivations = 3 in each class.The drain stops re-raising that document and files one Critical execution exception for it, with a Retry lever. Counted in the tally as escalated.
Written-off workflow typeAll fourActivation failures of one workflow type, on one execution exception row (MGCWardenExecutionExceptionManager::causeIsExhausted). The type is written off when the row has at least 10 occurrences (#MinCauseFailures) spread over at least 15 minutes (#MinCauseFailureSpanSeconds = 900).The drain does not attempt that workflow type. Counted as not attempted because the approval workflow has been written off (firming, trade agreement, journal).

Resolving or dismissing the execution exception row re-arms the drain. The next pass attempts the activation again. The Retry lever on the workbench is not bound by either rule, so it is the way to test a configuration fix.

Failure handling common to all four​

  • run() never lets an exception out. An unexpected failure of the whole pass is caught and recorded as one Error-severity execution exception with no record reference. The batch task itself ends normally, so batch job history does not show a failed drain. Look at Execution exceptions (System administration → Setup → Execution exceptions).
  • Each document is processed in its own failure region. One document that cannot be routed does not stop the rest.
  • A per-document activation failure releases the claim and files one execution exception per workflow type, counted up on each further failure (createDeduped). The row names the first document affected and carries the family's Retry handler.

Who the approval is raised by​

The drain submits the workflow as the user the run executes as. A scheduled run stamps the account the batch job runs as; Run now from the menu and the API stamp the person who pressed it. The MGCWardenBatchService summary records this. Choose the batch job's account with that in mind, because it becomes the originator of every approval the drain raises.

The deferred HoldPlaced business event​

A hold placed inside a native transaction does not announce itself, because the transaction could still roll back. The drains are where the MGCWardenHoldPlaced business event is emitted later:

  • the delta drain announces after it submits (MGCWardenHoldManager::emitDeferredHoldPlaced);
  • the firming, trade agreement and journal drains announce the hold first, before any route question, through MGCWardenHoldManager::emitDeferredHoldPlacedForType. Each hold is announced at most once.

An integration that listens for HoldPlaced therefore hears about firming, trade agreement and journal holds only when the corresponding drain runs.

The cancel dialog reads the schedule​

When a user cancels a firming, trade agreement or banded journal review approval from the workflow history, the cancel dialog says whether the drain will raise a fresh one, how often, and how many cancellations are left before it stops (MGCWardenCancelWarning, MGCWardenTACancelWarning). The interval it quotes is read from the drain's batch job in that company. With no schedule, the dialog says nothing unattended will raise it.

Choosing an interval​

Only the delta drain has a stated recurrence: every 5 minutes, a service-level promise. For the other three you choose. What the choice trades:

  • The interval is the longest time a held document waits with nobody asked to decide it.
  • The pass cost on a healthy system is small for the delta, firming and trade agreement drains (an indexed read of a small owed set). The journal drain reads every unposted inventory journal in the company on each pass, so its cost grows with the number of open journals.
  • An interval close to 4 hours lets the stale rule fire on a working schedule, because the rule fires whenever a record has been owed for 4 hours despite a recurrence.

Warden defines no batch group for any drain. Use whichever batch group your batch servers serve.


Delta route drain​

At a glance​

Batch classMGCWardenDeltaRouteDrainBatch
Menu itemMGCWardenDeltaRouteDrainMenuItem, label Warden delta route drain
Menu pathSystem administration → Setup → Warden delta route drain
Who may run itMGCWardenPolicyAuthorPriv (Update) → MGCWardenPolicyAuthoringDuty → Warden guard administrator (MGCWardenGuardAdministrator). The API operation MGCWardenBatchService.runDeltaRouteDrain checks the same menu item.
Feature toggleNone. It runs with Warden Order Guard off, because the purchase gates refuse a held order whether the toggle is on or off.
Company scopePer legal entity. Reads MGCWardenDiffSet in the company the task runs in.
Scheduled by defaultNo.
RecurrenceEvery 5 minutes. A service-level promise, not a parameter.
Setup-gap rulesDeltaDrainOwed, DeltaDrainNotScheduled, DeltaDrainStale (area ROUTEDRAIN); StrandedHold.

Purpose and business justification​

PurchTable.update and PurchLine.update always run inside a transaction, so MGCWardenChangeInterceptor classifies every purchase edit inside one. It places the hold and marks the diff set Pending, and the approval is raised later. The first transaction-free point is the purchase posting gate: when anyone attempts a governed purchase status (confirmation, confirmation request, receipts list, product receipt, vendor invoice, invoice approval journal), MGCWardenPurchFormLetter_Extension and MGCWardenPurchPostingGate drain that document's owed routes.

The drain covers the case where nobody attempts a posting. Without it, an order edited and then left alone stays held with no work item. With it, the approval appears at most one interval late. Nothing escapes governance in the gap, because the hold already stands.

The same class drains both purchase change routes: the delta approval (standard purchase orders) and the excluded-class approval (direct delivery, intercompany and TMS orders). The process from edit to approval is described in Purchase order change and delta re-approval.

How and when it is triggered​

  • By a batch job with a recurrence that an administrator creates from the menu item's batch dialog.
  • By Run now from the menu item.
  • By MGCWardenBatchService.runDeltaRouteDrain over the API.

The posting gate's per-document drain (MGCWardenChangeInterceptor::drainPendingRoutes) is a separate entry point that serves one document at a time. It is not this batch.

Configuration and scheduling options​

There are no dialog fields and no parameters. Schedule every 5 minutes in each legal entity that governs purchase changes. Warden setup gaps raises DeltaDrainNotScheduled when an Active policy would hold and route a purchase change, delta or excluded class (MGCWardenSetupGapCheck::changeGovernanceInUse).

What it does​

  1. Reaps stale claims (reapStaleClaims). It reads every diff set in Claimed. For each one still Claimed whose claim is at least 60 minutes old, or has no claim time, it asks the workflow runtime whether an approval exists.
    • If one exists, the diff set is settled to Routed, the workflow correlation is recovered from the runtime's tracking row, and an event-log row (DiffRecorded) says so.
    • If none exists, the claim is released to Pending and an event-log row says so. The sweep below routes it in the same pass.
    • The reaper runs in its own failure region. If it fails, a Warning-severity execution exception is filed and the sweep continues.
  2. Snapshots the RecIds of every diff set with RoutingState = Pending.
  3. Completes each route through MGCWardenChangeInterceptor::completePendingRoute(diffSet, true). The true marks the call as unattended, so the give-up rule applies.
    1. Before any transaction, it asks whether the delta and the excluded-class approval workflow types have been written off.
    2. In one transaction it locks the document's change-route hold (MGCWardenSubmitGuard::lockChangeRouteHold), reads it, and claims the diff set (Pending → Claimed) unless that hold's workflow type is written off. Hold first, then diff set: the lock order every writer of the two rows uses.
    3. If there is no active change-route hold, the hold was released after the edit (approved, break-glass or canceled). The diff set goes to NotRequired and the event log records that the route was abandoned. When another Warden control still holds the order, the row says so.
    4. If it did not win the claim, it stops. Another drain point has the route, or the type is written off.
    5. If the runtime already has an approval, it settles the diff set to Routed without submitting again.
    6. Otherwise it submits MGCWardenExcludedClassApprovalSubmitManager or MGCWardenDeltaApprovalSubmitManager (chosen by the hold type), stamps Routed, and emits the deferred HoldPlaced event.
    7. On failure it releases the claim back to Pending, files a Critical execution exception keyed on the workflow type with the MGCWardenDeltaRouteRetry handler, and writes an ungoverned-action event-log row.
  4. Writes the summary line: Warden delta route drain: N pending approval route(s) processed. When the reaper acted, a second line: Warden stale-claim reaper: N stranded claim(s) released for routing, M settled as already routed.

Transaction boundaries. The claim is one short transaction per diff set. The workflow submission happens after that transaction commits. The claim is committed before the submission, so a hold released in the instant between the two can still meet a raised approval. That window was accepted on 2026-10-07 : it can produce one unnecessary work item, never a document let through.

Concurrency and idempotency. Only Pending and stale Claimed rows are touched. A run with nothing owed reads an empty set and does nothing. Running it twice, or alongside a posting attempt on the same order, raises at most one approval per diff set.

Dependencies and prerequisites​

  • An active Warden delta approval workflow (MGCWardenDeltaApprovalTemplate) and, if you govern direct delivery, intercompany or TMS orders, an active Warden excluded-class change approval workflow (MGCWardenExcludedClassApprovalTemplate). See Getting started.
  • Active purchase guard policies. With none, nothing is ever Pending.

Inputs and outputs​

ReadsWrites
MGCWardenDiffSet (Pending, Claimed)MGCWardenDiffSet routing state, claim, workflow correlation (the diff itself is never modified)
MGCWardenHold (the change-route hold, locked)MGCWardenHold workflow correlation
Workflow tracking (through MGCWardenRouteExistenceCheck, MGCWardenRouteCorrelation)Workflow instances (delta or excluded-class approval), with work items for the approvers
MGCWardenExecutionException (give-up rule)MGCWardenEventLog (DiffRecorded, ungoverned action)
MGCWardenExecutionException (reaper Warning, per-type Critical, batch Error)
MGCWardenHoldPlaced business event

Logging and monitoring​

  • Batch task log: the summary line(s) above.
  • Change diff sets (System administration → Setup → Change diff sets): the routing state of each diff set.
  • Governance event log (System administration → Setup → Governance event log): the reaper, settle and abandon rows.
  • Execution exceptions: activation failures (Critical, one row per workflow type) and a failed pass (Error, on MGCWardenDiffSet with no record).
  • Warden setup gaps: the three DeltaDrain* rules and StrandedHold.

Errors, recovery and troubleshooting​

SymptomCauseWhat to do
DeltaDrainOwed on the setup-gap pageNo recurring job in this company, routes owedSchedule the drain every 5 minutes in this company. The next pass raises the owed approvals.
DeltaDrainStaleScheduled, but a route has been owed for 4 hours or moreOpen the batch job: is it held, failing, or on a long interval? Then check Execution exceptions for a written-off workflow type.
Critical row Deferred routing failed: the … workflow could not be activatedThe workflow type is not configured or not activeConfigure and activate the workflow. Press Retry on the row to test the fix, then resolve the row so the drain re-arms.
Error row Delta route drain batch failedThe whole pass failedRead the batch task log for the cause. Run it again; it is safe to re-run.
A held order whose approval was canceledA canceled delta approval leaves the diff set Routed, which the drain does not scanRe-raise it with Submit on Change diff sets. Warden setup gaps lists it as a stranded hold after 4 hours.

Re-running is always safe.

Impact on other functionality​

  • While the drain does not run, held purchase orders stay unconfirmable and unreceivable with no approver asked. Nothing else is blocked: users can keep editing, and each edit is governed as it lands.
  • Approvers see delta work items up to one interval after the edit. With the promised 5-minute interval this is the latency described in Getting started.
  • It takes a row lock on one hold and one diff set at a time, for the duration of the claim transaction. A release of the same hold waits for it.

Firming route drain​

At a glance​

Batch classMGCWardenFirmingRouteDrainBatch
Menu itemMGCWardenFirmingRouteDrainMenuItem, label Warden firming route drain
Menu pathSystem administration → Setup → Warden firming route drain
Who may run itMGCWardenPolicyAuthorPriv (Update) → MGCWardenPolicyAuthoringDuty → Warden guard administrator. API: MGCWardenBatchService.runFirmingRouteDrain.
Feature toggleNone. It runs with Warden Order Guard off.
Company scopePer legal entity. Reads MGCWardenFirmingRequest in the task's company.
Scheduled by defaultNo. The same sweep also runs at the end of every firming run (see below).
RecurrenceYou choose. No interval is stated in code or docs.
Setup-gap rulesFirmingDrainOwed, FirmingDrainNotScheduled, FirmingDrainStale (area FIRMDRAIN); StrandedHold.

Purpose and business justification​

When a planned order is firmed over a policy threshold, MGCWardenFirmingGate holds the new purchase order and writes a firming request in PendingApproval inside the firming transaction. The gate does not activate the workflow inside that transaction, because a failed activation there aborted the firming and, with Abort if errors set, the whole run. So an over-threshold firming commits its hold and request and leaves the approval owed.

The same happens when firming adds planned orders to a purchase order it created earlier. The gate measures the whole order each time (decided 2026-11-16): an order that passed through and now needs approval, or an approved order that has grown, gets a new hold, its request goes back to PendingApproval, and the new approval is owed to this drain. A request can therefore carry more than one approval over its life. The drain, the retry and Submit ask only about the current one: the approvals raised since the request's current hold was placed (MGCWardenFirmingRequest::episodeStart), so the completed approval of an earlier hold does not count as this one's route.

The drain raises those owed approvals. It also recovers approvals the runtime accepted and then lost, including a canceled approval: canceling leaves the request PendingApproval with its hold standing, so the drain raises a fresh one.

How and when it is triggered​

  • At the end of every firming run. MGCWardenReqTransPoMarkFirm_Extension calls MGCWardenFirmingRouteDrainBatch::drainDeferredRoutes. It runs only outside a transaction and writes a line only when it raised, escalated or suppressed something. This covers most firmings without a schedule. See Standard batch and periodic processes with Warden installed.
  • By a scheduled batch job, Run now, or MGCWardenBatchService.runFirmingRouteDrain. This is the backstop for what the end-of-run point misses: a run that dies after its commit, a nested firming, or a firming path that does not go through ReqTransPoMarkFirm.run().

Configuration and scheduling options​

No dialog fields and no parameters. FirmingDrainNotScheduled fires only when an Active policy would route a firming approval (firmingGovernanceInUse). Its text says that most firmings complete through the end-of-run point, and that the batch is still needed for the rest.

What it does​

  1. Snapshots every MGCWardenFirmingRequest in PendingApproval.
  2. For each (drainOne), in this order:
    1. Re-reads the request. Not PendingApproval any more: skipped.
    2. Announces the order's Firming hold if it has not been announced (HoldPlaced).
    3. Asks the runtime whether an approval exists. Yes: already routed.
    4. Checks that the order still carries an active Firming hold (by type). No: skipped. The request is left in PendingApproval; the drain does not change the business status.
    5. Lost activations for this request at or above 3: escalates (one Critical execution exception per order, Retry MGCWardenFirmingRouteRetry, filed only if no open one exists).
    6. Firming approval workflow type written off: not attempted.
    7. Takes the claim (MGCWardenFirmingRequest::claimRoute). Lost: skipped; a Retry or the manual Submit on the firming queue has it.
    8. Asks the runtime again under the claim. If an approval now exists, releases the claim: already routed.
    9. Submits MGCWardenFirmingApprovalSubmitManager::submit, releases the claim, and writes a FirmingRequested event-log row: raised.
    10. On failure: releases the claim and files one Error execution exception per workflow type, counted up (Retry MGCWardenFirmingRouteRetry): escalated.
  3. Writes: Warden firming route drain: N firming approval(s) raised, N already routed, N escalated to the exception workbench, N left alone, N not attempted because the approval workflow has been written off.

The claim is released on success as well as failure (MGCWardenFirmingRequest::releaseRoute). The request has no "routed" status to move to, and a lost activation must be re-raisable at once.

Dependencies and prerequisites​

  • An active Warden firming approval workflow (MGCWardenFirmingApprovalTemplate).
  • An Active planned-order firming policy.

Inputs and outputs​

ReadsWrites
MGCWardenFirmingRequest (PendingApproval)MGCWardenFirmingRequest.RouteClaimedDateTime (set and cleared)
MGCWardenHold (Firming hold on the PurchTable record)Workflow instances (firming approval)
Workflow tracking (route exists, lost-activation count)MGCWardenEventLog (FirmingRequested)
MGCWardenExecutionException (give-up rule, open escalation)MGCWardenExecutionException; MGCWardenHoldPlaced business event

Logging and monitoring​

  • Batch task log and, for the end-of-run point, the firming run's infolog.
  • Firming approval queue (System administration → Setup → Firming approval queue).
  • Execution exceptions, Governance event log, Warden setup gaps (FirmingDrain*, StrandedHold).

Errors, recovery and troubleshooting​

SymptomWhat to do
FirmingDrainOwed or FirmingDrainStaleSchedule the drain in this company, or check the batch job and the workbench for a written-off workflow type.
Critical row … accepted and then lost every activation raised for itThe drain has stopped re-raising that order. Fix the workflow configuration, then press Retry.
Error row The firming route drain could not activate the Firming approval workflowConfigure and activate the workflow, Retry the row, then resolve it.
Error row The end-of-run firming route drain failedThe orders are already in the batch drain's population. Let the scheduled drain pick them up, or run it.

Impact on other functionality​

  • An owed firming leaves the purchase order held: confirmation, receipt and invoice are refused, and master planning still treats it as supply (class summary).
  • Canceling a firming approval does not stop it. The drain raises a fresh one until three activations have been lost.
  • The end-of-run point adds a short sweep to each firming run. It is silent when it moves nothing.

Trade agreement route drain​

At a glance​

Batch classMGCWardenTARouteDrainBatch
Menu itemMGCWardenTARouteDrainMenuItem, label Warden trade agreement route drain
Menu pathSystem administration → Setup → Warden trade agreement route drain
Who may run itMGCWardenPolicyAuthorPriv (Update) → MGCWardenPolicyAuthoringDuty → Warden guard administrator. API: MGCWardenBatchService.runTARouteDrain.
Feature toggleWarden Trade Agreement Governance (MGCWardenTradeAgreementGovFeature, on by default). Stands down when it is off.
Company scopePer legal entity. Reads MGCWardenTAGateState in the task's company.
Scheduled by defaultNo.
RecurrenceYou choose. No interval is stated.
Setup-gap rulesTaDrainOwed, TaDrainNotScheduled, TaDrainStale (area TADRAIN); StrandedHold.

Purpose and business justification​

A gated classic trade agreement journal can be neither posted nor edited: the posting seam (MGCWardenPriceDiscAdmCheckPost_Extension) and the write seam (MGCWardenPriceDiscAdmTable_Extension) both refuse it. If the approval activation fails, or the runtime later loses the approval, the journal stays gated with nobody asked to decide it.

Every other recovery for this route is attended: Retry on the workbench, Submit for approval, and the Critical workbench row. The trade agreement route has no end-of-run drain point. So without this batch, a journal gated on a Friday stays blocked until somebody reads the workbench.

How and when it is triggered​

By a scheduled batch job, Run now, or MGCWardenBatchService.runTARouteDrain. Nothing else calls it.

Configuration and scheduling options​

No dialog fields and no parameters. TaDrainNotScheduled fires only when trade agreement governance is in use: the feature is on and an effective Active price-guard policy would gate a journal (tradeAgreementGovernanceInUse).

What it does​

  1. If MGCWardenTradeAgreementGovFeature::isOn() is false, writes Warden trade agreement route drain: Trade Agreement Governance is off; nothing to route. and stops. With the toggle off nothing refuses a gated journal, so raising an approval would ask somebody to decide a journal nobody is stopping.
  2. Snapshots every MGCWardenTAGateState with RefTableId = PriceDiscAdmTable and Gated = Yes. Unified pricing management agreements are out of scope: nothing in that module enforces the gate.
  3. For each (drainOne):
    1. Re-reads the row. No longer gated: skipped.
    2. Announces the journal's TradeAgreement hold if not yet announced.
    3. Route exists in the current gating episode (MGCWardenTAGateState::routeExists): already routed.
    4. Journal deleted or posted: skipped.
    5. Lost activations in this episode at or above 3: escalates (one Critical row per journal, Retry MGCWardenTARouteRetry).
    6. Trade agreement approval workflow type written off: not attempted.
    7. Takes the claim (MGCWardenTAGateState::claimRoute). Lost: skipped.
    8. Route exists now: releases the claim, already routed.
    9. Submits MGCWardenTAApprovalSubmitManager::submit(state), releases the claim, writes a DeltaRequested event-log row: raised.
    10. On failure: releases the claim, files one Error row per workflow type, counted up (Retry MGCWardenTARouteRetry): escalated.
  4. Writes: Warden trade agreement route drain: N price governance approval(s) raised, N already routed, N escalated to the exception workbench, N left alone, N not attempted because the approval workflow has been written off.

Two rules specific to this drain:

  • It does not re-measure the journal. The approval step (RequiredStepTag) stamped when the journal was gated is what the workflow's step conditions read. The drain re-raises that route; it never re-runs the effective-date check against today's date, which could downgrade the required approver.
  • It does not ask whether the journal is still held. Gated is what the seams enforce. A journal whose hold was released by break-glass while Gated stayed Yes is still refused, so it is still drained.

Dependencies and prerequisites​

  • Warden Trade Agreement Governance switched on.
  • An active Warden trade agreement approval workflow (MGCWardenTAApprovalTemplate).
  • An Active price-guard policy.

Inputs and outputs​

ReadsWrites
MGCWardenTAGateState (Gated)MGCWardenTAGateState.RouteClaimedDateTime
PriceDiscAdmTable (exists, Posted)Workflow instances (trade agreement approval)
Workflow tracking (episode-scoped)MGCWardenEventLog (DeltaRequested)
MGCWardenExecutionExceptionMGCWardenExecutionException; MGCWardenHoldPlaced business event

Logging and monitoring​

  • Batch task log.
  • Trade agreement gated journals (System administration → Setup → Trade agreement gated journals).
  • Execution exceptions, Governance event log, Warden setup gaps (TaDrain*, StrandedHold).

Errors, recovery and troubleshooting​

SymptomWhat to do
Run log says Trade Agreement Governance is offExpected when the toggle is off. Gated journals are not refused while it is off.
TaDrainOwedSchedule the drain in this company.
TaDrainStaleCheck the batch job, then the workbench. A written-off workflow makes the drain suppress, which also leaves journals owed.
Critical row … accepted and then lost every activation raised for itNothing will recover the journal unattended. Fix the workflow, then Retry.

A deleted gated journal is not re-raised by the drain. See the cancellation notes in User guide.

Impact on other functionality​

  • While the drain does not run, a gated journal with no route blocks the pricing desk: it cannot be posted or edited.
  • Canceling a trade agreement approval does not stop it; the drain raises a fresh one until three have been lost.

Journal route drain​

At a glance​

Batch classMGCWardenJournalRouteDrainBatch
Menu itemMGCWardenJournalRouteDrainMenuItem, label Warden journal route drain
Menu pathSystem administration → Setup → Warden journal route drain
Who may run itMGCWardenPolicyAuthorPriv (Update) → MGCWardenPolicyAuthoringDuty → Warden guard administrator. API: MGCWardenBatchService.runJournalRouteDrain.
Feature toggleWarden Journal Governance (MGCWardenJournalGovFeature). Stands down when it is off.
Company scopePer legal entity. Reads InventJournalTable and MGCWardenJournalGovState in the task's company.
Scheduled by defaultNo.
RecurrenceYou choose. No interval is stated.
Setup-gap rulesJournalDrainOwed, JournalDrainNotScheduled, JournalDrainStale (area JOURNALDRAIN); StrandedHold.

Purpose and business justification​

Journal governance routes a banded review before native posting opens its transaction (MGCWardenInventJournalRoute_Extension). That works when the journal is posted from the journal form. Most other inventory journal posting paths run inside a caller's transaction: warehouse mobile counting, ITM over/under, Rental transfers, BOM report-finish, retail kit assembly and field service work orders (the class summary's census: 26 of 30 shipping call sites). On those paths Warden must not route, because the caller could roll the work back. The posting is refused, because the band was really crossed, and no approver is asked. This drain is the only thing that raises those reviews.

It also re-raises a review that was raised and then lost: the review is Pending, the hold stands, and the runtime has no approval.

How and when it is triggered​

By a scheduled batch job, Run now, or MGCWardenBatchService.runJournalRouteDrain. There is no end-of-run point (class summary, "No second entry point").

Configuration and scheduling options​

No dialog fields and no parameters. JournalDrainNotScheduled fires only when banded review is in use: the feature is on and an effective Active journal policy has at least one band whose step is not None (bandedReviewGovernanceInUse).

What it does​

  1. If MGCWardenJournalGovFeature::isOn() is false, writes Warden journal route drain: journal governance is off; nothing to route. and stops.
  2. If called inside a transaction, returns without doing anything.
  3. If no journal policy is Active and in its effective window, returns with every count at zero. The summary line still prints.
  4. Snapshots every InventJournalTable that is unposted and not of type TagCounting. Tag-counting journals are excluded because the band gate does not cover them.
  5. For each (drainOne):
    1. Re-reads the journal. Posted or gone: skipped.
    2. Announces the journal's JournalGovernance (reversal) hold and JournalReview hold if either is not yet announced (announceHeldJournal).
    3. ReviewState = Rejected (shown as Canceled): skipped. Nothing writes this state; only older rows carry it.
    4. ReviewState = Pending: the stranded path (reRaiseStrandedReview):
      • review route exists in this episode: already routed;
      • lost activations at or above 3: escalates (Critical, per journal, Retry MGCWardenJournalRouteRetry);
      • workflow type written off: not attempted;
      • claim (MGCWardenJournalGovState::claimRoute), re-check, then MGCWardenJournalReviewSubmitManager::submit without re-measuring the step: re-raised;
      • on failure: one Error row per workflow type, counted up.
    5. Otherwise the owed path: resolves the journal policy for the journal name, measures the bands (MGCWardenJournalGuard::reviewRequirement) and compares the required step with the step already approved. Nothing owed: skipped. Workflow type written off: not attempted. Otherwise calls MGCWardenJournalReviewRouter::evaluate (the one routing entry point), then asks the runtime whether the review now exists. Yes: routed, with a DeltaRequested event-log row. No: escalated (the submit manager has already filed its exception).
  6. Writes: Warden journal route drain: N banded review(s) routed, N lost review(s) re-raised, N already routed, N escalated to the exception workbench, N left alone, N not attempted because the approval workflow has been written off.

The owed path measures the journal as it stands. A journal edited below its band since the refused posting owes nothing and is left alone. The stranded path keeps the step that was stamped.

This drain announces reversal holds but does not raise reversal approvals. See Journal reversal router.

Dependencies and prerequisites​

  • Warden Journal Governance switched on.
  • An active Warden journal banded review workflow (MGCWardenJournalReviewTemplate).
  • An Active journal policy with cost bands whose step tag is not None.

Inputs and outputs​

ReadsWrites
InventJournalTable, InventJournalTrans (read only, never for update)MGCWardenJournalGovState (through the router; claim time)
MGCWardenJournalPolicy, MGCWardenJournalPolicyBandMGCWardenHold (JournalReview hold, through the router)
MGCWardenJournalGovStateWorkflow instances (journal banded review)
Workflow tracking (episode-scoped, by workflow type)MGCWardenEventLog (DeltaRequested); MGCWardenExecutionException; MGCWardenHoldPlaced

Logging and monitoring​

  • Batch task log.
  • Journal governance queue (System administration → Setup → Journal governance queue).
  • Execution exceptions, Governance event log, Warden setup gaps (JournalDrain*, StrandedHold).

The JournalDrainOwed count covers only the stranded population (a Pending review with no route). A journal refused on a nested posting path leaves no row until the drain routes it, so it is not counted. The page does not re-measure every open journal; JournalDrainNotScheduled is what tells you to schedule.

Errors, recovery and troubleshooting​

SymptomWhat to do
A journal posted from warehouse counting or another nested path is refused and no work item appearsExpected until the drain runs. Schedule it, or run it now.
Run log says journal governance is offExpected; banded journals are not refused while it is off.
Every count is zeroNo journal policy is Active and effective, or nothing is owed.
Error row The journal route drain could not route the banded reviewConfigure and activate the banded review workflow, then Retry the row.

Impact on other functionality​

  • While it does not run, banded journals posted through nested paths stay unpostable at their current size, with nobody asked.
  • Each pass reads every unposted, non-tag-counting inventory journal and, for each journal under a policy, its lines. Its duration grows with the number of open journals.
  • It reads native journal tables without locks. It writes only Warden rows and workflow instances.