Usina BRAdvPL Guide
Sign in
← All topics
PRACTICAL GUIDEUnder review

Protheus Scheduler

Distinguishes scheduling from the routine doing the work.

Protheus SchedulerAdvPL
01 · OVERVIEW

Overview

TOTVS describes Manager for generation/queue, Agent for distribution and Execute for invoking the routine; Execute consumes a license during execution. Schedule controls timing, while routine code determines memory/performance. Verify company, branch, parameters, identity, recurrence and monitoring for the installed scheduler generation. Plan overlapping/repeated runs, cancellation and recovery without reopening a Schedule-provided environment. The example illustrates memory-only deduplication and creates no scheduled task. (Sources: refs. 1–2.)

03 · PRACTICAL EXAMPLE

Commented example

#Include "Protheus.ch"

User Function Ed642()
    Local aCompleted := {}
    Local cKey := "COMPANY_BRANCH_PROCESS_20261027"
    // Local example: neither distributed locking nor persistent tracking.
    If AScan(aCompleted,cKey) == 0
        AAdd(aCompleted,cKey)
    EndIf
    ConOut(Len(aCompleted))
Return Nil
Expected result

Local list with one item. Real retries need persistent tracking and concurrency coordination. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

BEST PRACTICES
  • Use Schedule-compatible routines and monitor failures. Do not generalize Workflow P10 setup to current schedulers.
  • Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

Related content

REFERENCES
  1. TOTVS. Schedule: agendando a execução de rotinas. Accessed on 2026-10-28.
  2. TOTVS. RpcSetEnv: contexto de Schedule. Accessed on 2026-10-28.
Status
Under review
Page created on
Last reviewed on
Original language
Portuguese
Reviewed by
Usina.BR
0 approved comment(s)

Comments

There are no approved comments yet.

Sign in with Google or Microsoft to comment.

Powered by Usina Docs · Alpha