Skip to content
Agentmart
Submit a tool

advpl-pontos-entrada

Pontos de Entrada (PEs) no Protheus — User Function NOME(PARAMIXB[1..N]), naming patterns, retorno por PARAMIXB[última-posição].

Skill by replybr

IndexedMIT
Write a review

Chalk Labs

Need help deploying advpl-pontos-entrada?

Chalk Labs sets up agents like this inside real teams: connected to your tools, tested on your data, with a human in the loop where it matters.

Book a call

Install

Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.

npx agentmarket install skill/replybr-advpl-pontos-entrada

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

Pontos de Entrada (PEs) no Protheus — User Function NOME(PARAMIXB[1..N]), naming patterns, retorno por PARAMIXB[última-posição]. Use ao criar/editar PE.

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/advpl-pontos-entrada

What's inside

Skill name
advpl-pontos-entrada
Description
Pontos de Entrada (PEs) no Protheus — User Function NOME(PARAMIXB[1..N]), naming patterns, retorno por PARAMIXB[última-posição]. Use ao criar/editar PE.
License
MIT
Instructions
178 lines in SKILL.md · view on GitHub

Agent Skills spec issues

  • name: missing

Files (3)

  • SKILL.md
  • A300STRU.prw · exemplos/
  • reference.md

SKILL.md (first lines)

# advpl-pontos-entrada — Customização via PE

**Ponto de Entrada (PE)** é o mecanismo oficial TOTVS para customizar comportamento de rotinas padrão **sem alterar o fonte original**. Toda rotina Protheus principal tem dezenas de PEs cadastrados em pontos estratégicos (antes de validar, antes de gravar, antes de imprimir, etc.).

O cliente implementa uma `User Function` com **nome exato e assinatura esperada** pela rotina TOTVS. Em runtime, o framework chama via reflection se a função existir no RPO.

## Quando usar

- Usuário pede "criar ponto de entrada", "implementar PE", "customizar rotina padrão TOTVS".
- Edit em arquivo cuja função casa com pattern de PE (`^[A-Z]{2,4}\d{2,4}[A-Z_]*$`).
- Investigar comportamento "modificado" de rotina TOTVS — provavelmente há PE ativa.
- Antes de copiar rotina TOTVS inteira para customizar → sempre prefira PE.

## Pattern de naming

Regex que casa a esmagadora maioria dos PEs oficiais:

```
^[A-Z]{2,4}\d{2,4}[A-Z_]*$
```

Exemplos:

- `MT100LOK` — Módulo MT (Faturamento) + 100 (rotina) + LOK (linha OK).
- `M460FIM` — MATA460 — fim do processamento.
- `MA410LOK` — MATA410 — Pedido de venda, line OK.
- `MA410BUT` — MATA410 — botões adicionais.
- `FA080INC` — FINA080 — pós-inclusão.
- `SF2100I` — SF2 + 100 + I (post Insert).

Sufixos comuns:

| Sufixo | Significa                       |
|--------|---------------------------------|
| `LOK`  | Line OK (valida linha em grid)  |
| `TOK`  | TudoOK (validação geral)        |
| `INC`  | Pós-Inclusão                    |
| `ALT`  | Pós-Alteração                   |
| `EXC`  | Pós-Exclusão                    |
| `CAN`  | Cancelamento                    |
| `BUT`  | Botões adicionais               |
| `MNU`  | Menu adicional                  |
| `FIM`  | Final do processamento          |
| `GRV`  | Gravação                        |
| `PRT`  | Impressão                       |
| `VLD`  | Validação                       |

## Assinatura padrão — PARAMIXB

PEs **não recebem parâmetros nomeados**. Recebem uma variável global `PARAMIXB` (array 1-based) preenchida pela rotina chamadora:

```advpl
#include "TOTVS.CH"

/*/{Protheus.doc} MT100LOK
PE Validacao na inclusao de NF de entrada.
Retorna .T. se valido, .F. para bloquear gravacao.
/*/
User Function MT100LOK()
    Local aArea  := GetArea()
    Local lOk    := .T.
    Local cNumNF := SF1->F1_DOC

    // Lógica de validação customizada
    If !MyValida(cNumNF)
        lOk := .F.
        Help(, , "Validacao", , "NF " + cNumNF + " bloqueada por regra interna", 1, 0)
    EndIf

    RestArea(aArea)
Return lOk
```

Quando há parâmetros, eles vêm em `PARAMIXB[N]`:

```advpl
User Function A120GRVC()
    Local aCab := PARAMIXB[1]   // array de cabeçalho do pedido
    Local aItens := PARAMIXB[2] // array de itens

    // Processa
Return Nil
```

## Indexação 1-based

ADVPL usa **arrays 1-based** (não 0-based como C/Python). `PARAMIXB[1]` é o primeiro elemento. **Ler `PARAMIXB[0]` dá erro de runtime.**

`paramixb_count` no lookup `pontos_entrada_padrao` indica quantos parâmetros a PE recebe.

## Retorno via PARAMIXB[última-posição]

Algumas PEs **modificam o último elemento** de `PARAMIXB` para devolver dado ao chamador:

```advpl
User Function MA440PGN()
    // PARAMIXB[1..N-1] são entrada
    // PARAMIXB[N] é o retorno (output)
    Local aSaida := PARAMIXB[Len(PARAMIXB)]

    aSaida[1] := nNovoValor
    PARAMIXB[Len(PARAMIXB)] := aSaida
Return Nil
```

A coluna `retorno_tipo` do lookup indica o tipo esperado: `L` (lógico), `C` (string), `N` (numérico), `A` (array), `O` (objeto), `` (sem retorno).

## Onde a PE é chamada

A rotina TOTVS faz algo como:

```advpl
// Dentro do fonte oficial MATA460
If ExistBlock("M460FIM")
    ExecBlock("M460FIM", .F., .F., {aCabec, aItens})
EndIf
```

`ExistBlock` checa se a User Function existe no RPO; `ExecBlock` invoca passando parâmetros que viram `PARAMIXB`. **Apenas uma User Function com aquele nome pode existir no RPO** — daí a importância de prefixo de cliente em `User Function` regulares (PEs são exceção: o nome é fixo).

From replybr/plugadvpl, MIT.

More from replybr/plugadvpl

Signals

Stars
0
Forks
5
Open issues
0
Last commit (this folder)
May 11, 2026 (5 months ago)

From GitHub (fetched Oct 24, 2026).

Details

License
MIT
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from replybr

Done for you

Rather not set it up yourself?

Chalk Labs scopes, builds and runs agents for your team: the task audit, the eval harness, the integrations and the weekly ops report. Fixed scope, priced before we start.

See how we build AI agents →Read the case studies

Chalk Labs is a two-founder AI and growth studio. We build AI agents, CRMs and MVPs for Web3 and AI companies, and have shipped 50+ product and token launches.

launches shipped
50+
launches shipped
media placements
500+
media placements
founders on every account
2
founders on every account

Press we've placed: Forbes · CoinDesk · Decrypt · Cointelegraph · The Block

Rahil Jain, Co-founder, Chalk Labs. Ex-Goldman Sachs engineer. You talk to the person who builds it.

Get advpl-pontos-entrada running in your business

Tell us what you want to automate. A founder replies within one working day with a plan, not a pitch deck.

Goes to the Chalk Labs founders, not the newsletter. Privacy

Need help deploying advpl-pontos-entrada?

CallGet help
Cite this page

advpl-pontos-entrada skill. Agent Mart. https://agentmart.dev/skills/replybr-advpl-pontos-entrada (last updated 2026-10-24)